@agent-native/core 0.95.0 → 0.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +35 -0
- package/corpus/core/docs/content/locales/ar-SA/template-design.mdx +13 -0
- package/corpus/core/docs/content/locales/de-DE/template-design.mdx +18 -0
- package/corpus/core/docs/content/locales/es-ES/template-design.mdx +16 -0
- package/corpus/core/docs/content/locales/fr-FR/template-design.mdx +17 -0
- package/corpus/core/docs/content/locales/hi-IN/template-design.mdx +16 -0
- package/corpus/core/docs/content/locales/ja-JP/template-design.mdx +17 -0
- package/corpus/core/docs/content/locales/ko-KR/template-design.mdx +15 -0
- package/corpus/core/docs/content/locales/pt-BR/template-design.mdx +16 -0
- package/corpus/core/docs/content/locales/zh-CN/template-design.mdx +11 -0
- package/corpus/core/docs/content/locales/zh-TW/template-design.mdx +12 -0
- package/corpus/core/docs/content/template-design.mdx +16 -0
- package/corpus/core/package.json +4 -2
- package/corpus/core/src/a2a/client.ts +11 -1
- package/corpus/core/src/agent/production-agent.ts +107 -27
- package/corpus/core/src/agent/thread-data-builder.ts +48 -22
- package/corpus/core/src/chat-threads/store.ts +20 -1
- package/corpus/core/src/cli/code-agent-executor.ts +1 -0
- package/corpus/core/src/cli/code-agent-runs.ts +14 -0
- package/corpus/core/src/client/AgentPanel.tsx +32 -25
- package/corpus/core/src/client/AssistantChat.tsx +286 -45
- package/corpus/core/src/client/MultiTabAssistantChat.tsx +141 -90
- package/corpus/core/src/client/chat/ChatHistoryList.tsx +404 -0
- package/corpus/core/src/client/chat/index.ts +6 -0
- package/corpus/core/src/client/chat/tool-call-display.tsx +38 -4
- package/corpus/core/src/client/chat/use-reconnect-reader-owner.ts +28 -0
- package/corpus/core/src/client/code-agent-chat-adapter.ts +72 -4
- package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +52 -11
- package/corpus/core/src/client/composer/TiptapComposer.tsx +157 -20
- package/corpus/core/src/client/composer/VoiceButton.tsx +28 -0
- package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +5 -0
- package/corpus/core/src/client/conversation/code-agent-transcript.ts +4 -5
- package/corpus/core/src/client/guided-questions.tsx +11 -2
- package/corpus/core/src/client/index.ts +11 -0
- package/corpus/core/src/client/integrations/IntegrationsPanel.tsx +6 -7
- package/corpus/core/src/client/sse-event-processor.ts +90 -21
- package/corpus/core/src/client/use-chat-threads.ts +10 -1
- package/corpus/core/src/client/voice-provider-status.ts +44 -0
- package/corpus/core/src/code-agents/transcript-normalizer.ts +76 -0
- package/corpus/core/src/connections/catalog.ts +2 -2
- package/corpus/core/src/deploy/build.ts +12 -8
- package/corpus/core/src/integrations/a2a-continuation-processor.ts +35 -5
- package/corpus/core/src/integrations/adapters/slack.ts +74 -21
- package/corpus/core/src/integrations/catalog.ts +2 -2
- package/corpus/core/src/integrations/webhook-handler.ts +14 -0
- package/corpus/core/src/localization/default-messages.ts +6 -0
- package/corpus/core/src/observability/hosted-model-experiment.ts +118 -0
- package/corpus/core/src/observability/routes.ts +17 -0
- package/corpus/core/src/observability/store.ts +4 -1
- package/corpus/core/src/observability/traces.ts +41 -2
- package/corpus/core/src/scripts/agent-engines/list-agent-engines.ts +19 -1
- package/corpus/core/src/scripts/call-agent.ts +53 -3
- package/corpus/core/src/scripts/chat/search-chats.ts +11 -8
- package/corpus/core/src/secrets/register-framework-secrets.ts +1 -1
- package/corpus/core/src/server/agent-chat-plugin.ts +41 -6
- package/corpus/core/src/server/auth.ts +1 -1
- package/corpus/core/src/server/core-routes-plugin.ts +15 -0
- package/corpus/core/src/server/credential-provider.ts +7 -3
- package/corpus/core/src/server/realtime-voice.ts +71 -24
- package/corpus/core/src/server/voice-providers-status.ts +4 -3
- package/corpus/core/src/shared/cache-control.ts +4 -4
- package/corpus/core/src/styles/agent-native.css +1 -0
- package/corpus/core/src/styles/chat-history-list.css +313 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
- package/corpus/core/src/vite/client.ts +1 -0
- package/corpus/templates/analytics/AGENTS.md +7 -0
- package/corpus/templates/analytics/actions/bigquery.ts +26 -2
- package/corpus/templates/analytics/actions/data-source-status.ts +18 -0
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +5 -4
- package/corpus/templates/analytics/app/global.css +10 -0
- package/corpus/templates/analytics/app/lib/data-sources.ts +5 -4
- package/corpus/templates/analytics/app/pages/Ask.tsx +25 -2
- package/corpus/templates/analytics/changelog/2026-07-10-analytics-answers-simple-time-bounded-metrics-without-unnece.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-analytics-chat-reliably-uses-connected-data-sources-across-s.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-chat-threads-now-stay-clear-of-top-actions-and-fade-smoothly.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-context-chips-can-now-be-selected-and-removed-one-at-a-time-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-slack-token-setup-marked-legacy.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-the-ask-composer-no-longer-carries-dashboard-or-panel-contex.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-the-ask-section-stays-highlighted-while-its-chat-history-is-.md +6 -0
- package/corpus/templates/analytics/server/lib/bigquery.ts +90 -14
- package/corpus/templates/analytics/server/lib/credential-keys.ts +6 -2
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +82 -7
- package/corpus/templates/brain/changelog/2026-07-10-slack-backfill-token-marked-legacy.md +6 -0
- package/corpus/templates/brain/server/register-secrets.ts +2 -2
- package/corpus/templates/clips/app/components/library/library-layout.tsx +7 -1
- package/corpus/templates/clips/app/components/library/page-header.tsx +19 -3
- package/corpus/templates/clips/app/routes/_app.library._index.tsx +16 -12
- package/corpus/templates/clips/changelog/2026-07-10-new-recording-appears-once-when-the-library-sidebar-is-open.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-slack-token-fallback-guidance.md +6 -0
- package/corpus/templates/clips/server/register-secrets.ts +1 -1
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +0 -66
- package/corpus/templates/content/app/routes/_app.local-files.tsx +7 -47
- package/corpus/templates/content/changelog/2026-07-10-local-folders-now-wait-for-an-explicit-pull-before-content-r.md +6 -0
- package/corpus/templates/content/package.json +1 -1
- package/corpus/templates/design/actions/generate-design.ts +128 -31
- package/corpus/templates/design/actions/present-design-variants.ts +37 -9
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +9 -3
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +32 -10
- package/corpus/templates/design/app/components/design/QuestionFlow.tsx +2 -2
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +9 -1
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +7 -5
- package/corpus/templates/design/app/components/design/multi-screen/types.ts +3 -0
- package/corpus/templates/design/app/global.css +10 -0
- package/corpus/templates/design/app/hooks/use-question-flow.ts +9 -2
- package/corpus/templates/design/app/i18n/zh-TW.ts +1 -0
- package/corpus/templates/design/app/i18n-data.ts +21 -11
- package/corpus/templates/design/changelog/2026-07-10-editor-panels-are-easier-to-distinguish-and-design-intake-qu.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-interact-mode-now-stays-on-the-full-canvas-matches-edit-visu.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-new-web-designs-open-at-desktop-size-and-adapt-across-mobile.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-tweaks-now-link-to-full-documentation.md +6 -0
- package/corpus/templates/design/server/plugins/agent-chat.ts +2 -0
- package/corpus/templates/mail/app/i18n/ar-SA.ts +3 -3
- package/corpus/templates/mail/app/i18n/de-DE.ts +3 -3
- package/corpus/templates/mail/app/i18n/en-US.ts +4 -3
- package/corpus/templates/mail/app/i18n/es-ES.ts +3 -3
- package/corpus/templates/mail/app/i18n/fr-FR.ts +3 -3
- package/corpus/templates/mail/app/i18n/hi-IN.ts +3 -3
- package/corpus/templates/mail/app/i18n/ja-JP.ts +3 -3
- package/corpus/templates/mail/app/i18n/ko-KR.ts +3 -3
- package/corpus/templates/mail/app/i18n/pt-BR.ts +3 -3
- package/corpus/templates/mail/app/i18n/zh-CN.ts +3 -3
- package/corpus/templates/mail/app/i18n/zh-TW.ts +3 -3
- package/corpus/templates/mail/changelog/2026-07-10-slack-intake-marked-legacy.md +6 -0
- package/corpus/templates/mail/server/lib/env-config.ts +5 -4
- package/corpus/templates/plan/package.json +1 -1
- package/dist/a2a/client.d.ts +7 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +2 -1
- package/dist/a2a/client.js.map +1 -1
- package/dist/agent/production-agent.d.ts +6 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +83 -26
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts +1 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +42 -23
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/chat-threads/store.d.ts +10 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +6 -0
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +1 -0
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/code-agent-runs.d.ts +12 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +1 -0
- package/dist/cli/code-agent-runs.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +3 -3
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +14 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +207 -32
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +83 -10
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/chat/ChatHistoryList.d.ts +88 -0
- package/dist/client/chat/ChatHistoryList.d.ts.map +1 -0
- package/dist/client/chat/ChatHistoryList.js +83 -0
- package/dist/client/chat/ChatHistoryList.js.map +1 -0
- package/dist/client/chat/index.d.ts +1 -0
- package/dist/client/chat/index.d.ts.map +1 -1
- package/dist/client/chat/index.js +1 -0
- package/dist/client/chat/index.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +13 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +11 -3
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/chat/use-reconnect-reader-owner.d.ts +11 -0
- package/dist/client/chat/use-reconnect-reader-owner.d.ts.map +1 -0
- package/dist/client/chat/use-reconnect-reader-owner.js +21 -0
- package/dist/client/chat/use-reconnect-reader-owner.js.map +1 -0
- package/dist/client/code-agent-chat-adapter.d.ts +17 -1
- package/dist/client/code-agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/code-agent-chat-adapter.js +47 -3
- package/dist/client/code-agent-chat-adapter.js.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts +11 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.js +5 -3
- package/dist/client/composer/RealtimeVoiceMode.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +25 -2
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +96 -5
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/VoiceButton.d.ts.map +1 -1
- package/dist/client/composer/VoiceButton.js +21 -1
- package/dist/client/composer/VoiceButton.js.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.js +5 -0
- package/dist/client/composer/useRealtimeVoiceMode.js.map +1 -1
- package/dist/client/conversation/code-agent-transcript.d.ts +2 -0
- package/dist/client/conversation/code-agent-transcript.d.ts.map +1 -1
- package/dist/client/conversation/code-agent-transcript.js +3 -5
- package/dist/client/conversation/code-agent-transcript.js.map +1 -1
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +7 -2
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.d.ts.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.js +5 -7
- package/dist/client/integrations/IntegrationsPanel.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +67 -20
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +9 -1
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/voice-provider-status.d.ts +10 -0
- package/dist/client/voice-provider-status.d.ts.map +1 -0
- package/dist/client/voice-provider-status.js +32 -0
- package/dist/client/voice-provider-status.js.map +1 -0
- package/dist/code-agents/transcript-normalizer.d.ts +29 -0
- package/dist/code-agents/transcript-normalizer.d.ts.map +1 -1
- package/dist/code-agents/transcript-normalizer.js +55 -0
- package/dist/code-agents/transcript-normalizer.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/connections/catalog.d.ts +2 -2
- package/dist/connections/catalog.js +2 -2
- package/dist/connections/catalog.js.map +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +12 -8
- package/dist/deploy/build.js.map +1 -1
- package/dist/integrations/a2a-continuation-processor.d.ts.map +1 -1
- package/dist/integrations/a2a-continuation-processor.js +25 -5
- package/dist/integrations/a2a-continuation-processor.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +55 -21
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/catalog.js +2 -2
- package/dist/integrations/catalog.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +11 -0
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/localization/default-messages.d.ts +5 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +5 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/observability/hosted-model-experiment.d.ts +39 -0
- package/dist/observability/hosted-model-experiment.d.ts.map +1 -0
- package/dist/observability/hosted-model-experiment.js +90 -0
- package/dist/observability/hosted-model-experiment.js.map +1 -0
- package/dist/observability/routes.d.ts.map +1 -1
- package/dist/observability/routes.js +16 -0
- package/dist/observability/routes.js.map +1 -1
- package/dist/observability/store.d.ts.map +1 -1
- package/dist/observability/store.js +4 -1
- package/dist/observability/store.js.map +1 -1
- package/dist/observability/traces.d.ts +6 -0
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +28 -2
- package/dist/observability/traces.js.map +1 -1
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.js +19 -1
- package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +43 -3
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/chat/search-chats.d.ts +1 -1
- package/dist/scripts/chat/search-chats.d.ts.map +1 -1
- package/dist/scripts/chat/search-chats.js +11 -8
- package/dist/scripts/chat/search-chats.js.map +1 -1
- package/dist/secrets/register-framework-secrets.js +1 -1
- package/dist/secrets/register-framework-secrets.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +11 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +27 -6
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/auth.js +1 -1
- package/dist/server/auth.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +3 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +13 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/credential-provider.d.ts +5 -3
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +7 -3
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/realtime-voice.d.ts.map +1 -1
- package/dist/server/realtime-voice.js +55 -21
- package/dist/server/realtime-voice.js.map +1 -1
- package/dist/server/voice-providers-status.d.ts.map +1 -1
- package/dist/server/voice-providers-status.js +2 -3
- package/dist/server/voice-providers-status.js.map +1 -1
- package/dist/shared/cache-control.d.ts +6 -6
- package/dist/shared/cache-control.d.ts.map +1 -1
- package/dist/shared/cache-control.js +3 -3
- package/dist/shared/cache-control.js.map +1 -1
- package/dist/styles/agent-native.css +1 -0
- package/dist/styles/chat-history-list.css +313 -0
- package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +1 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/locales/ar-SA/template-design.mdx +13 -0
- package/docs/content/locales/de-DE/template-design.mdx +18 -0
- package/docs/content/locales/es-ES/template-design.mdx +16 -0
- package/docs/content/locales/fr-FR/template-design.mdx +17 -0
- package/docs/content/locales/hi-IN/template-design.mdx +16 -0
- package/docs/content/locales/ja-JP/template-design.mdx +17 -0
- package/docs/content/locales/ko-KR/template-design.mdx +15 -0
- package/docs/content/locales/pt-BR/template-design.mdx +16 -0
- package/docs/content/locales/zh-CN/template-design.mdx +11 -0
- package/docs/content/locales/zh-TW/template-design.mdx +12 -0
- package/docs/content/template-design.mdx +16 -0
- package/package.json +4 -2
- package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-agent-chat-adapter.js","sourceRoot":"","sources":["../../src/client/code-agent-chat-adapter.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,4BAA4B,GAM7B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,gCAAgC,EAChC,oBAAoB,GAErB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AA0ErE,MAAM,UAAU,0BAA0B,CACxC,OAA0C;IAE1C,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC;IACtD,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,IAAI,CAAC;IAC9D,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,CAAC,CAAC;IACzD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC;IAEjD,OAAO;QACL,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAuB;YACvD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;YACvC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,WAAW,CAAC,4CAA4C,CAAC,CAAC;gBAChE,OAAO;YACT,CAAC;YAED,MAAM,eAAe,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YACpD,MAAM,WAAW,GAAG,eAAe;gBACjC,CAAC,CAAC,4CAA4C,CAAC,eAAe,CAAC;gBAC/D,CAAC,CAAC,EAAE,CAAC;YACP,MAAM,MAAM,GACV,cAAc,CAAC,QAAQ,CAAC,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AAC;AAED,SAAS,KAAK,CAAC,EAAU,EAAE,WAAwB;IACjD,IAAI,WAAW,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAClD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACxC,WAAW,CAAC,gBAAgB,CAC1B,OAAO,EACP,GAAG,EAAE;YACH,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,EAAE,CAAC;QACZ,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n ChatModelAdapter,\n ChatModelRunOptions,\n ChatModelRunResult,\n} from \"@assistant-ui/react\";\n\nimport {\n normalizeCodeAgentTranscript,\n type CodeAgentTranscriptEvent as CoreCodeAgentTranscriptEvent,\n type NormalizedCodeAgentStatusEvent,\n type NormalizedCodeAgentThinkingEvent,\n type NormalizedCodeAgentToolEvent,\n type NormalizedCodeAgentTranscriptItem,\n} from \"../code-agents/transcript-normalizer.js\";\nimport {\n compareCodeAgentTranscriptEvents,\n isCodeAgentRunActive,\n type CodeAgentRunStateLike,\n} from \"../code-agents/transcript-order.js\";\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport { unwrapAttachmentEnvelope } from \"./composer/pasted-text.js\";\nimport type { AgentPromptAttachment } from \"./composer/prompt-attachments.js\";\nimport type { ContentPart } from \"./sse-event-processor.js\";\n\nexport type CodeAgentChatFollowUpMode = \"immediate\" | \"queued\";\n\nexport interface CodeAgentChatTranscriptEvent {\n id: string;\n runId: string;\n kind?: CoreCodeAgentTranscriptEvent[\"kind\"];\n type?: CoreCodeAgentTranscriptEvent[\"kind\"] | \"note\";\n message?: string;\n text?: string;\n createdAt: string;\n metadata?: Record<string, unknown>;\n artifactPath?: string;\n artifactUrl?: string;\n}\n\nexport interface CodeAgentChatControlResult {\n ok: boolean;\n run?: CodeAgentRunStateLike | null;\n queued?: boolean;\n message?: string;\n error?: string;\n}\n\nexport interface CodeAgentChatController {\n get(runId: string): Promise<CodeAgentRunStateLike | null>;\n transcript(runId: string): Promise<CodeAgentChatTranscriptEvent[]>;\n sendFollowUp(input: {\n runId: string;\n prompt: string;\n mode?: CodeAgentChatFollowUpMode;\n permissionMode?: string;\n engine?: string;\n model?: string;\n reasoningEffort?: ReasoningEffort;\n source?: string;\n metadata?: Record<string, unknown>;\n }): Promise<CodeAgentChatControlResult>;\n control(input: {\n runId: string;\n command: \"stop\";\n }): Promise<CodeAgentChatControlResult>;\n}\n\nexport interface CreateCodeAgentChatAdapterOptions {\n controller: CodeAgentChatController;\n runIdRef: { current: string | null };\n permissionModeRef?: { current: string | undefined };\n modelRef?: { current: string | undefined };\n engineRef?: { current: string | undefined };\n effortRef?: { current: ReasoningEffort | undefined };\n followUpModeRef?: { current: CodeAgentChatFollowUpMode | undefined };\n attachOnlyRef?: { current: boolean };\n tabId?: string;\n pollIntervalMs?: number;\n idlePollIntervalMs?: number;\n terminalIdlePolls?: number;\n /**\n * Assistant-ui may abort a run for UI lifecycle reasons, such as switching\n * selected sessions. Code sessions keep running unless the host sends an\n * explicit stop command.\n */\n stopOnAbort?: boolean;\n}\n\ntype AssistantUiAttachment = {\n name?: string;\n contentType?: string;\n content?: readonly Record<string, unknown>[];\n};\n\nexport function createCodeAgentChatAdapter(\n options: CreateCodeAgentChatAdapterOptions,\n): ChatModelAdapter {\n const pollIntervalMs = options.pollIntervalMs ?? 1000;\n const idlePollIntervalMs = options.idlePollIntervalMs ?? 5000;\n const terminalIdlePolls = options.terminalIdlePolls ?? 3;\n const stopOnAbort = options.stopOnAbort === true;\n\n return {\n async *run({ messages, abortSignal }: ChatModelRunOptions) {\n const runId = options.runIdRef.current;\n if (!runId) {\n yield errorResult(\"Select an Agent-Native Code session first.\");\n return;\n }\n\n const lastUserMessage = latestUserMessage(messages);\n const attachments = lastUserMessage\n ? extractPromptAttachmentsFromAssistantMessage(lastUserMessage)\n : [];\n const prompt =\n latestUserText(messages).trim() ||\n (attachments.length > 0 ? \"Use the attached context.\" : \"\");\n if (!prompt.trim()) {\n yield errorResult(\"Enter a follow-up prompt.\");\n return;\n }\n\n let stoppedFromAbort = false;\n const stopForAbort = () => {\n stoppedFromAbort = true;\n if (stopOnAbort) {\n void options.controller.control({ runId, command: \"stop\" });\n }\n };\n if (abortSignal.aborted) {\n stopForAbort();\n return;\n }\n abortSignal.addEventListener(\"abort\", stopForAbort, { once: true });\n\n try {\n const initialEvents = await options.controller.transcript(runId);\n const seenEventIds = new Set(initialEvents.map((event) => event.id));\n const tailedEvents: CodeAgentChatTranscriptEvent[] = [];\n\n if (!options.attachOnlyRef?.current) {\n const beforeSendRun = await options.controller.get(runId);\n const response = await options.controller.sendFollowUp({\n runId,\n prompt,\n mode:\n options.followUpModeRef?.current ??\n (beforeSendRun && isCodeAgentRunActive(beforeSendRun)\n ? \"queued\"\n : \"immediate\"),\n permissionMode: options.permissionModeRef?.current,\n engine: options.engineRef?.current,\n model: options.modelRef?.current,\n reasoningEffort: options.effortRef?.current,\n source: \"code-agent-chat\",\n metadata: attachments.length > 0 ? { attachments } : undefined,\n });\n if (!response.ok) {\n yield errorResult(\n response.error ?? response.message ?? \"Could not send follow-up.\",\n runId,\n );\n return;\n }\n }\n\n let yieldedContent = false;\n let idleTerminalPolls = 0;\n while (!abortSignal.aborted) {\n const [events, run] = await Promise.all([\n options.controller.transcript(runId),\n options.controller.get(runId),\n ]);\n const nextEvents = events\n .filter((event) => !seenEventIds.has(event.id))\n .sort(compareCodeAgentTranscriptEvents);\n for (const event of nextEvents) {\n seenEventIds.add(event.id);\n tailedEvents.push(event);\n }\n\n const content = codeAgentTranscriptEventsToContent(tailedEvents);\n const sawClear = nextEvents.some(isAgentChatClearTranscriptEvent);\n if ((content.length > 0 || sawClear) && nextEvents.length > 0) {\n yieldedContent = true;\n yield withRunMetadata({ content: [...content] }, runId);\n }\n\n if (run && isCodeAgentRunActive(run)) {\n idleTerminalPolls = 0;\n } else if (nextEvents.length === 0) {\n idleTerminalPolls += 1;\n } else {\n idleTerminalPolls = 0;\n }\n\n if (idleTerminalPolls >= terminalIdlePolls) {\n if (content.length > 0 && !yieldedContent) {\n yield withRunMetadata({ content: [...content] }, runId);\n }\n return;\n }\n\n await sleep(\n run && isCodeAgentRunActive(run)\n ? pollIntervalMs\n : idlePollIntervalMs,\n abortSignal,\n );\n }\n } finally {\n abortSignal.removeEventListener(\"abort\", stopForAbort);\n if (stoppedFromAbort) {\n return;\n }\n }\n },\n };\n}\n\nexport function codeAgentTranscriptEventsToContent(\n events: readonly CodeAgentChatTranscriptEvent[],\n): ContentPart[] {\n const normalized = normalizeCodeAgentTranscript(\n events.map(toCoreCodeAgentTranscriptEvent),\n );\n const content: ContentPart[] = [];\n\n const appendText = (text: string) => {\n const trimmed = text.trim();\n if (!trimmed) return;\n const last = content.at(-1);\n if (last?.type === \"text\") {\n last.text = `${last.text}${last.text ? \"\\n\\n\" : \"\"}${trimmed}`;\n } else {\n content.push({ type: \"text\", text: trimmed });\n }\n };\n\n for (const item of normalized.items) {\n const part = contentPartForCodeAgentTranscriptItem(item);\n if (!part) continue;\n if (part.type === \"text\") {\n appendText(part.text);\n } else {\n content.push(part);\n }\n }\n\n return content;\n}\n\nfunction isAgentChatClearTranscriptEvent(\n event: CodeAgentChatTranscriptEvent | undefined,\n): boolean {\n return event?.metadata?.agentChatEventType === \"clear\";\n}\n\nfunction latestUserMessage(\n messages: ChatModelRunOptions[\"messages\"],\n): ChatModelRunOptions[\"messages\"][number] | undefined {\n for (let index = messages.length - 1; index >= 0; index--) {\n const message = messages[index];\n if (message.role === \"user\") return message;\n }\n return undefined;\n}\n\nfunction latestUserText(messages: ChatModelRunOptions[\"messages\"]): string {\n const message = latestUserMessage(messages);\n return (\n message?.content\n .filter(\n (part): part is { type: \"text\"; text: string } => part.type === \"text\",\n )\n .map((part) => part.text)\n .join(\"\\n\") ?? \"\"\n );\n}\n\nfunction extractPromptAttachmentsFromAssistantMessage(message: {\n attachments?: readonly AssistantUiAttachment[];\n}): AgentPromptAttachment[] {\n const attachments: AgentPromptAttachment[] = [];\n for (const att of message.attachments ?? []) {\n const name = att.name ?? \"attachment\";\n for (const part of att.content ?? []) {\n if (part.type === \"image\" && typeof part.image === \"string\") {\n attachments.push({\n name,\n type: att.contentType,\n dataUrl: part.image,\n });\n } else if (part.type === \"file\" && typeof part.data === \"string\") {\n attachments.push({\n name,\n type:\n att.contentType ??\n (typeof part.mimeType === \"string\" ? part.mimeType : undefined),\n ...(part.data.startsWith(\"data:\")\n ? { dataUrl: part.data }\n : { text: part.data }),\n });\n } else if (part.type === \"text\" && typeof part.text === \"string\") {\n attachments.push({\n name,\n type: att.contentType,\n text: unwrapAttachmentEnvelope(part.text),\n });\n }\n }\n }\n return attachments;\n}\n\nfunction toCoreCodeAgentTranscriptEvent(\n event: CodeAgentChatTranscriptEvent,\n): CoreCodeAgentTranscriptEvent {\n return {\n schemaVersion: 1,\n id: event.id,\n runId: event.runId,\n kind: (event.kind ??\n event.type ??\n \"status\") as CoreCodeAgentTranscriptEvent[\"kind\"],\n message: event.message ?? event.text ?? \"\",\n createdAt: event.createdAt,\n metadata: {\n ...(event.metadata ?? {}),\n ...(event.artifactPath ? { artifactPath: event.artifactPath } : {}),\n ...(event.artifactUrl ? { artifactUrl: event.artifactUrl } : {}),\n },\n };\n}\n\nfunction contentPartForCodeAgentTranscriptItem(\n item: NormalizedCodeAgentTranscriptItem,\n): ContentPart | null {\n if (item.type === \"assistant\") {\n return item.text.trim() ? { type: \"text\", text: item.text.trim() } : null;\n }\n if (item.type === \"tool\") {\n return toolContentPartForCodeAgentTranscriptItem(item);\n }\n if (item.type === \"thinking\") {\n return thinkingContentPartForCodeAgentTranscriptItem(item);\n }\n if (item.type === \"status\") {\n const text = statusTextForCodeAgentTranscriptItem(item);\n return text ? { type: \"text\", text } : null;\n }\n return null;\n}\n\nfunction thinkingContentPartForCodeAgentTranscriptItem(\n item: NormalizedCodeAgentThinkingEvent,\n): ContentPart | null {\n const text = item.text.trim();\n if (!text) return null;\n return {\n type: \"reasoning\",\n text,\n };\n}\n\nfunction toolContentPartForCodeAgentTranscriptItem(\n item: NormalizedCodeAgentToolEvent,\n): ContentPart {\n return {\n type: \"tool-call\",\n toolCallId: `code-tool-${item.id}`,\n toolName: item.tool ?? item.label ?? \"code-agent\",\n argsText: previewValue(item.input) ?? \"\",\n args: recordArgs(item.input),\n ...(item.result !== undefined\n ? { result: previewValue(item.result) ?? \"\" }\n : {}),\n ...(item.mcpApp ? { mcpApp: item.mcpApp } : {}),\n ...(item.structuredMeta ? { structuredMeta: item.structuredMeta } : {}),\n };\n}\n\nfunction statusTextForCodeAgentTranscriptItem(\n item: NormalizedCodeAgentStatusEvent,\n): string | null {\n if (item.statusKind === \"artifact\") {\n const event = item.events[0];\n const path =\n stringMetadata(event?.metadata, \"artifactPath\") ??\n stringMetadata(event?.metadata, \"path\");\n const url = stringMetadata(event?.metadata, \"artifactUrl\");\n const target = url ?? path;\n return target\n ? `Artifact: ${item.text}\\n${target}`\n : `Artifact: ${item.text}`;\n }\n if (item.level === \"info\" && item.statusKind !== \"note\") return null;\n return item.text;\n}\n\nfunction recordArgs(value: unknown): Record<string, string> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return {};\n const result: Record<string, string> = {};\n for (const [key, entry] of Object.entries(value)) {\n result[key] =\n typeof entry === \"string\" ? entry : (previewValue(entry) ?? \"\");\n }\n return result;\n}\n\nfunction previewValue(value: unknown): string | undefined {\n if (value === undefined || value === null) return undefined;\n const text =\n typeof value === \"string\" ? value : (JSON.stringify(value, null, 2) ?? \"\");\n const trimmed = text.trim();\n if (!trimmed) return undefined;\n return trimmed.length > 4000 ? `${trimmed.slice(0, 4000)}\\n...` : trimmed;\n}\n\nfunction stringMetadata(\n metadata: Record<string, unknown> | undefined,\n key: string,\n): string | undefined {\n const value = metadata?.[key];\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction withRunMetadata(\n result: ChatModelRunResult,\n runId: string,\n): ChatModelRunResult {\n const metadata = (result.metadata ?? {}) as Record<string, unknown>;\n const custom =\n metadata.custom && typeof metadata.custom === \"object\"\n ? (metadata.custom as Record<string, unknown>)\n : {};\n return {\n ...result,\n metadata: {\n ...metadata,\n custom: { ...custom, runId },\n },\n };\n}\n\nfunction errorResult(message: string, runId?: string): ChatModelRunResult {\n return withRunMetadata(\n {\n content: [{ type: \"text\", text: message }],\n status: { type: \"incomplete\", reason: \"error\" },\n } as ChatModelRunResult,\n runId ?? \"code-agent\",\n );\n}\n\nfunction sleep(ms: number, abortSignal: AbortSignal): Promise<void> {\n if (abortSignal.aborted) return Promise.resolve();\n return new Promise((resolve) => {\n const timeout = setTimeout(resolve, ms);\n abortSignal.addEventListener(\n \"abort\",\n () => {\n clearTimeout(timeout);\n resolve();\n },\n { once: true },\n );\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"code-agent-chat-adapter.js","sourceRoot":"","sources":["../../src/client/code-agent-chat-adapter.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,4BAA4B,GAM7B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,gCAAgC,EAChC,oBAAoB,GAErB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAiFrE,MAAM,UAAU,0BAA0B,CACxC,OAA0C;IAE1C,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC;IACtD,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,IAAI,CAAC;IAC9D,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,CAAC,CAAC;IACzD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC;IAEjD,OAAO;QACL,KAAK,CAAC,CAAC,GAAG,CAAC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,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n ChatModelAdapter,\n ChatModelRunOptions,\n ChatModelRunResult,\n} from \"@assistant-ui/react\";\n\nimport {\n normalizeCodeAgentTranscript,\n type CodeAgentTranscriptEvent as CoreCodeAgentTranscriptEvent,\n type NormalizedCodeAgentStatusEvent,\n type NormalizedCodeAgentThinkingEvent,\n type NormalizedCodeAgentToolEvent,\n type NormalizedCodeAgentTranscriptItem,\n} from \"../code-agents/transcript-normalizer.js\";\nimport {\n compareCodeAgentTranscriptEvents,\n isCodeAgentRunActive,\n type CodeAgentRunStateLike,\n} from \"../code-agents/transcript-order.js\";\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport { unwrapAttachmentEnvelope } from \"./composer/pasted-text.js\";\nimport type { AgentPromptAttachment } from \"./composer/prompt-attachments.js\";\nimport type { ContentPart } from \"./sse-event-processor.js\";\n\nexport type CodeAgentChatFollowUpMode = \"immediate\" | \"queued\";\n\nexport interface CodeAgentChatTranscriptEvent {\n id: string;\n runId: string;\n kind?: CoreCodeAgentTranscriptEvent[\"kind\"];\n type?: CoreCodeAgentTranscriptEvent[\"kind\"] | \"note\";\n message?: string;\n text?: string;\n createdAt: string;\n metadata?: Record<string, unknown>;\n artifactPath?: string;\n artifactUrl?: string;\n}\n\nexport interface CodeAgentChatControlResult {\n ok: boolean;\n run?: CodeAgentRunStateLike | null;\n queued?: boolean;\n message?: string;\n error?: string;\n}\n\nexport interface CodeAgentChatController {\n get(runId: string): Promise<CodeAgentRunStateLike | null>;\n transcript(runId: string): Promise<CodeAgentChatTranscriptEvent[]>;\n sendFollowUp(input: {\n runId: string;\n prompt: string;\n mode?: CodeAgentChatFollowUpMode;\n permissionMode?: string;\n engine?: string;\n model?: string;\n reasoningEffort?: ReasoningEffort;\n source?: string;\n metadata?: Record<string, unknown>;\n }): Promise<CodeAgentChatControlResult>;\n control(input: {\n runId: string;\n /**\n * `\"approve\"` resolves the run's current pending `needsApproval` gate\n * (see `requestCodeAgentApproval` in `cli/code-agent-executor.ts`) — the\n * same effect as the host UI's \"Approve\" control. Deny / always-allow are\n * intentionally NOT routed through this method; hosts wire those directly\n * via `AssistantChatProps.approvalActions` instead (see CodeAgentsApp).\n */\n command: \"stop\" | \"approve\";\n }): Promise<CodeAgentChatControlResult>;\n}\n\nexport interface CreateCodeAgentChatAdapterOptions {\n controller: CodeAgentChatController;\n runIdRef: { current: string | null };\n permissionModeRef?: { current: string | undefined };\n modelRef?: { current: string | undefined };\n engineRef?: { current: string | undefined };\n effortRef?: { current: ReasoningEffort | undefined };\n followUpModeRef?: { current: CodeAgentChatFollowUpMode | undefined };\n attachOnlyRef?: { current: boolean };\n tabId?: string;\n pollIntervalMs?: number;\n idlePollIntervalMs?: number;\n terminalIdlePolls?: number;\n /**\n * Assistant-ui may abort a run for UI lifecycle reasons, such as switching\n * selected sessions. Code sessions keep running unless the host sends an\n * explicit stop command.\n */\n stopOnAbort?: boolean;\n}\n\ntype AssistantUiAttachment = {\n name?: string;\n contentType?: string;\n content?: readonly Record<string, unknown>[];\n};\n\nexport function createCodeAgentChatAdapter(\n options: CreateCodeAgentChatAdapterOptions,\n): ChatModelAdapter {\n const pollIntervalMs = options.pollIntervalMs ?? 1000;\n const idlePollIntervalMs = options.idlePollIntervalMs ?? 5000;\n const terminalIdlePolls = options.terminalIdlePolls ?? 3;\n const stopOnAbort = options.stopOnAbort === true;\n\n return {\n async *run({ messages, abortSignal, runConfig }: ChatModelRunOptions) {\n const runId = options.runIdRef.current;\n if (!runId) {\n yield errorResult(\"Select an Agent-Native Code session first.\");\n return;\n }\n\n // Human-in-the-loop: `ApprovalContext.onApprove` (tool-call-display.tsx)\n // re-issues the turn carrying the pending approval's key in\n // `approvedToolCalls`, the same mechanism regular SSE agent-chat\n // approvals use. For Code sessions there is no server-side gate to\n // notify — resolve the run's own pending approval directly instead of\n // treating the accompanying \"Approved...\" text as a new prompt.\n const approvedToolCalls = extractApprovedToolCalls(runConfig);\n const isApprovalTurn = Boolean(\n approvedToolCalls && approvedToolCalls.length > 0,\n );\n\n const lastUserMessage = latestUserMessage(messages);\n const attachments = lastUserMessage\n ? extractPromptAttachmentsFromAssistantMessage(lastUserMessage)\n : [];\n const prompt =\n latestUserText(messages).trim() ||\n (attachments.length > 0 ? \"Use the attached context.\" : \"\");\n if (!isApprovalTurn && !prompt.trim()) {\n yield errorResult(\"Enter a follow-up prompt.\");\n return;\n }\n\n let stoppedFromAbort = false;\n const stopForAbort = () => {\n stoppedFromAbort = true;\n if (stopOnAbort) {\n void options.controller.control({ runId, command: \"stop\" });\n }\n };\n if (abortSignal.aborted) {\n stopForAbort();\n return;\n }\n abortSignal.addEventListener(\"abort\", stopForAbort, { once: true });\n\n try {\n const initialEvents = await options.controller.transcript(runId);\n const seenEventIds = new Set(initialEvents.map((event) => event.id));\n const tailedEvents: CodeAgentChatTranscriptEvent[] = [];\n\n if (isApprovalTurn) {\n const response = await options.controller.control({\n runId,\n command: \"approve\",\n });\n if (!response.ok) {\n yield errorResult(\n response.error ?? response.message ?? \"Could not approve.\",\n runId,\n );\n return;\n }\n } else if (!options.attachOnlyRef?.current) {\n const beforeSendRun = await options.controller.get(runId);\n const response = await options.controller.sendFollowUp({\n runId,\n prompt,\n mode:\n options.followUpModeRef?.current ??\n (beforeSendRun && isCodeAgentRunActive(beforeSendRun)\n ? \"queued\"\n : \"immediate\"),\n permissionMode: options.permissionModeRef?.current,\n engine: options.engineRef?.current,\n model: options.modelRef?.current,\n reasoningEffort: options.effortRef?.current,\n source: \"code-agent-chat\",\n metadata: attachments.length > 0 ? { attachments } : undefined,\n });\n if (!response.ok) {\n yield errorResult(\n response.error ?? response.message ?? \"Could not send follow-up.\",\n runId,\n );\n return;\n }\n }\n\n let yieldedContent = false;\n let idleTerminalPolls = 0;\n while (!abortSignal.aborted) {\n const [events, run] = await Promise.all([\n options.controller.transcript(runId),\n options.controller.get(runId),\n ]);\n const nextEvents = events\n .filter((event) => !seenEventIds.has(event.id))\n .sort(compareCodeAgentTranscriptEvents);\n for (const event of nextEvents) {\n seenEventIds.add(event.id);\n tailedEvents.push(event);\n }\n\n const content = codeAgentTranscriptEventsToContent(tailedEvents);\n const sawClear = nextEvents.some(isAgentChatClearTranscriptEvent);\n if ((content.length > 0 || sawClear) && nextEvents.length > 0) {\n yieldedContent = true;\n yield withRunMetadata({ content: [...content] }, runId);\n }\n\n if (run && isCodeAgentRunActive(run)) {\n idleTerminalPolls = 0;\n } else if (nextEvents.length === 0) {\n idleTerminalPolls += 1;\n } else {\n idleTerminalPolls = 0;\n }\n\n if (idleTerminalPolls >= terminalIdlePolls) {\n if (content.length > 0 && !yieldedContent) {\n yield withRunMetadata({ content: [...content] }, runId);\n }\n return;\n }\n\n await sleep(\n run && isCodeAgentRunActive(run)\n ? pollIntervalMs\n : idlePollIntervalMs,\n abortSignal,\n );\n }\n } finally {\n abortSignal.removeEventListener(\"abort\", stopForAbort);\n if (stoppedFromAbort) {\n return;\n }\n }\n },\n };\n}\n\nfunction extractApprovedToolCalls(\n runConfig: ChatModelRunOptions[\"runConfig\"] | undefined,\n): string[] | undefined {\n const raw =\n runConfig?.custom &&\n typeof runConfig.custom === \"object\" &&\n \"approvedToolCalls\" in runConfig.custom\n ? (runConfig.custom as { approvedToolCalls?: unknown }).approvedToolCalls\n : undefined;\n if (!Array.isArray(raw)) return undefined;\n const keys = raw.filter(\n (key): key is string => typeof key === \"string\" && key.length > 0,\n );\n return keys.length > 0 ? keys : undefined;\n}\n\n/**\n * Whether any tool-call in this Code transcript currently carries an\n * unresolved approval (see `NormalizedCodeAgentToolEvent.pendingApprovalKey`).\n * Hosts (e.g. `CodeAgentsApp`) use this to keep their standalone approval\n * banner as a fallback only for transcripts where the inline\n * `ApprovalAffordance` cannot be joined to a tool-call part, instead of\n * showing both at once.\n */\nexport function codeAgentTranscriptHasPendingApproval(\n events: readonly CodeAgentChatTranscriptEvent[],\n): boolean {\n const normalized = normalizeCodeAgentTranscript(\n events.map(toCoreCodeAgentTranscriptEvent),\n );\n return normalized.items.some(\n (item) => item.type === \"tool\" && Boolean(item.pendingApprovalKey),\n );\n}\n\nexport function codeAgentTranscriptEventsToContent(\n events: readonly CodeAgentChatTranscriptEvent[],\n): ContentPart[] {\n const normalized = normalizeCodeAgentTranscript(\n events.map(toCoreCodeAgentTranscriptEvent),\n );\n const content: ContentPart[] = [];\n\n const appendText = (text: string) => {\n const trimmed = text.trim();\n if (!trimmed) return;\n const last = content.at(-1);\n if (last?.type === \"text\") {\n last.text = `${last.text}${last.text ? \"\\n\\n\" : \"\"}${trimmed}`;\n } else {\n content.push({ type: \"text\", text: trimmed });\n }\n };\n\n for (const item of normalized.items) {\n const part = contentPartForCodeAgentTranscriptItem(item);\n if (!part) continue;\n if (part.type === \"text\") {\n appendText(part.text);\n } else {\n content.push(part);\n }\n }\n\n return content;\n}\n\nfunction isAgentChatClearTranscriptEvent(\n event: CodeAgentChatTranscriptEvent | undefined,\n): boolean {\n return event?.metadata?.agentChatEventType === \"clear\";\n}\n\nfunction latestUserMessage(\n messages: ChatModelRunOptions[\"messages\"],\n): ChatModelRunOptions[\"messages\"][number] | undefined {\n for (let index = messages.length - 1; index >= 0; index--) {\n const message = messages[index];\n if (message.role === \"user\") return message;\n }\n return undefined;\n}\n\nfunction latestUserText(messages: ChatModelRunOptions[\"messages\"]): string {\n const message = latestUserMessage(messages);\n return (\n message?.content\n .filter(\n (part): part is { type: \"text\"; text: string } => part.type === \"text\",\n )\n .map((part) => part.text)\n .join(\"\\n\") ?? \"\"\n );\n}\n\nfunction extractPromptAttachmentsFromAssistantMessage(message: {\n attachments?: readonly AssistantUiAttachment[];\n}): AgentPromptAttachment[] {\n const attachments: AgentPromptAttachment[] = [];\n for (const att of message.attachments ?? []) {\n const name = att.name ?? \"attachment\";\n for (const part of att.content ?? []) {\n if (part.type === \"image\" && typeof part.image === \"string\") {\n attachments.push({\n name,\n type: att.contentType,\n dataUrl: part.image,\n });\n } else if (part.type === \"file\" && typeof part.data === \"string\") {\n attachments.push({\n name,\n type:\n att.contentType ??\n (typeof part.mimeType === \"string\" ? part.mimeType : undefined),\n ...(part.data.startsWith(\"data:\")\n ? { dataUrl: part.data }\n : { text: part.data }),\n });\n } else if (part.type === \"text\" && typeof part.text === \"string\") {\n attachments.push({\n name,\n type: att.contentType,\n text: unwrapAttachmentEnvelope(part.text),\n });\n }\n }\n }\n return attachments;\n}\n\nfunction toCoreCodeAgentTranscriptEvent(\n event: CodeAgentChatTranscriptEvent,\n): CoreCodeAgentTranscriptEvent {\n return {\n schemaVersion: 1,\n id: event.id,\n runId: event.runId,\n kind: (event.kind ??\n event.type ??\n \"status\") as CoreCodeAgentTranscriptEvent[\"kind\"],\n message: event.message ?? event.text ?? \"\",\n createdAt: event.createdAt,\n metadata: {\n ...(event.metadata ?? {}),\n ...(event.artifactPath ? { artifactPath: event.artifactPath } : {}),\n ...(event.artifactUrl ? { artifactUrl: event.artifactUrl } : {}),\n },\n };\n}\n\nfunction contentPartForCodeAgentTranscriptItem(\n item: NormalizedCodeAgentTranscriptItem,\n): ContentPart | null {\n if (item.type === \"assistant\") {\n return item.text.trim() ? { type: \"text\", text: item.text.trim() } : null;\n }\n if (item.type === \"tool\") {\n return toolContentPartForCodeAgentTranscriptItem(item);\n }\n if (item.type === \"thinking\") {\n return thinkingContentPartForCodeAgentTranscriptItem(item);\n }\n if (item.type === \"status\") {\n const text = statusTextForCodeAgentTranscriptItem(item);\n return text ? { type: \"text\", text } : null;\n }\n return null;\n}\n\nfunction thinkingContentPartForCodeAgentTranscriptItem(\n item: NormalizedCodeAgentThinkingEvent,\n): ContentPart | null {\n const text = item.text.trim();\n if (!text) return null;\n return {\n type: \"reasoning\",\n text,\n };\n}\n\nfunction toolContentPartForCodeAgentTranscriptItem(\n item: NormalizedCodeAgentToolEvent,\n): ContentPart {\n return {\n type: \"tool-call\",\n toolCallId: `code-tool-${item.id}`,\n toolName: item.tool ?? item.label ?? \"code-agent\",\n argsText: previewValue(item.input) ?? \"\",\n args: recordArgs(item.input),\n ...(item.result !== undefined\n ? { result: previewValue(item.result) ?? \"\" }\n : {}),\n ...(item.mcpApp ? { mcpApp: item.mcpApp } : {}),\n ...(item.structuredMeta ? { structuredMeta: item.structuredMeta } : {}),\n ...(item.pendingApprovalKey\n ? { approval: { approvalKey: item.pendingApprovalKey } }\n : {}),\n };\n}\n\nfunction statusTextForCodeAgentTranscriptItem(\n item: NormalizedCodeAgentStatusEvent,\n): string | null {\n if (item.statusKind === \"artifact\") {\n const event = item.events[0];\n const path =\n stringMetadata(event?.metadata, \"artifactPath\") ??\n stringMetadata(event?.metadata, \"path\");\n const url = stringMetadata(event?.metadata, \"artifactUrl\");\n const target = url ?? path;\n return target\n ? `Artifact: ${item.text}\\n${target}`\n : `Artifact: ${item.text}`;\n }\n if (item.level === \"info\" && item.statusKind !== \"note\") return null;\n return item.text;\n}\n\nfunction recordArgs(value: unknown): Record<string, string> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return {};\n const result: Record<string, string> = {};\n for (const [key, entry] of Object.entries(value)) {\n result[key] =\n typeof entry === \"string\" ? entry : (previewValue(entry) ?? \"\");\n }\n return result;\n}\n\nfunction previewValue(value: unknown): string | undefined {\n if (value === undefined || value === null) return undefined;\n const text =\n typeof value === \"string\" ? value : (JSON.stringify(value, null, 2) ?? \"\");\n const trimmed = text.trim();\n if (!trimmed) return undefined;\n return trimmed.length > 4000 ? `${trimmed.slice(0, 4000)}\\n...` : trimmed;\n}\n\nfunction stringMetadata(\n metadata: Record<string, unknown> | undefined,\n key: string,\n): string | undefined {\n const value = metadata?.[key];\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction withRunMetadata(\n result: ChatModelRunResult,\n runId: string,\n): ChatModelRunResult {\n const metadata = (result.metadata ?? {}) as Record<string, unknown>;\n const custom =\n metadata.custom && typeof metadata.custom === \"object\"\n ? (metadata.custom as Record<string, unknown>)\n : {};\n return {\n ...result,\n metadata: {\n ...metadata,\n custom: { ...custom, runId },\n },\n };\n}\n\nfunction errorResult(message: string, runId?: string): ChatModelRunResult {\n return withRunMetadata(\n {\n content: [{ type: \"text\", text: message }],\n status: { type: \"incomplete\", reason: \"error\" },\n } as ChatModelRunResult,\n runId ?? \"code-agent\",\n );\n}\n\nfunction sleep(ms: number, abortSignal: AbortSignal): Promise<void> {\n if (abortSignal.aborted) return Promise.resolve();\n return new Promise((resolve) => {\n const timeout = setTimeout(resolve, ms);\n abortSignal.addEventListener(\n \"abort\",\n () => {\n clearTimeout(timeout);\n resolve();\n },\n { once: true },\n );\n });\n}\n"]}
|
|
@@ -8,6 +8,11 @@ export interface RealtimeVoiceModeCopy {
|
|
|
8
8
|
entryButtonLabel: string;
|
|
9
9
|
promptTitle: string;
|
|
10
10
|
promptDescription: string;
|
|
11
|
+
setupTitle: string;
|
|
12
|
+
setupDescription: string;
|
|
13
|
+
connectBuilder: string;
|
|
14
|
+
useOpenAiKey: string;
|
|
15
|
+
startWithOpenAiKey: string;
|
|
11
16
|
startVoiceMode: string;
|
|
12
17
|
keepDictating: string;
|
|
13
18
|
showChat: string;
|
|
@@ -30,6 +35,11 @@ export interface RealtimeVoiceModeEntryProps {
|
|
|
30
35
|
onOpenChange?: (open: boolean) => void;
|
|
31
36
|
onStartVoiceMode: () => void;
|
|
32
37
|
onKeepDictating: () => void;
|
|
38
|
+
setupRequired?: boolean;
|
|
39
|
+
openAiConfigured?: boolean;
|
|
40
|
+
connectingBuilder?: boolean;
|
|
41
|
+
onConnectBuilder?: () => void;
|
|
42
|
+
onUseOpenAiKey?: () => void;
|
|
33
43
|
className?: string;
|
|
34
44
|
}
|
|
35
45
|
/**
|
|
@@ -37,7 +47,7 @@ export interface RealtimeVoiceModeEntryProps {
|
|
|
37
47
|
* The first click offers voice mode without silently changing the existing
|
|
38
48
|
* editable-dictation behavior.
|
|
39
49
|
*/
|
|
40
|
-
export declare function RealtimeVoiceModeEntry({ copy, disabled, open: controlledOpen, onOpenChange, onStartVoiceMode, onKeepDictating, className, }: RealtimeVoiceModeEntryProps): import("react").JSX.Element;
|
|
50
|
+
export declare function RealtimeVoiceModeEntry({ copy, disabled, open: controlledOpen, onOpenChange, onStartVoiceMode, onKeepDictating, setupRequired, openAiConfigured, connectingBuilder, onConnectBuilder, onUseOpenAiKey, className, }: RealtimeVoiceModeEntryProps): import("react").JSX.Element;
|
|
41
51
|
export interface RealtimeVoiceModeDockProps {
|
|
42
52
|
state: RealtimeVoiceModeState;
|
|
43
53
|
copy: RealtimeVoiceModeCopy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealtimeVoiceMode.d.ts","sourceRoot":"","sources":["../../../src/client/composer/RealtimeVoiceMode.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,iCAAiC,CAAC;AAEzC,MAAM,MAAM,sBAAsB,GAC9B,YAAY,GACZ,WAAW,GACX,UAAU,GACV,SAAS,GACT,OAAO,GACP,QAAQ,CAAC;AAEb;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,gBAAgB,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,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;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA8ED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,IAAI,EACJ,WAAW,EACX,WAAiC,EACjC,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,SAAS,GACV,EAAE,0BAA0B,+BAiG5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button } from "@agent-native/toolkit/ui/button";
|
|
3
3
|
import { IconAlertTriangle, IconLoader2, IconMicrophone, IconPhoneOff, IconVolume, } from "@tabler/icons-react";
|
|
4
4
|
import { useEffect, useId, useState, useSyncExternalStore } from "react";
|
|
@@ -11,7 +11,7 @@ import { createRealtimeVoiceAudioLevelStore, } from "./realtime-voice-audio-leve
|
|
|
11
11
|
* The first click offers voice mode without silently changing the existing
|
|
12
12
|
* editable-dictation behavior.
|
|
13
13
|
*/
|
|
14
|
-
export function RealtimeVoiceModeEntry({ copy, disabled, open: controlledOpen, onOpenChange, onStartVoiceMode, onKeepDictating, className, }) {
|
|
14
|
+
export function RealtimeVoiceModeEntry({ copy, disabled, open: controlledOpen, onOpenChange, onStartVoiceMode, onKeepDictating, setupRequired = false, openAiConfigured = false, connectingBuilder = false, onConnectBuilder, onUseOpenAiKey, className, }) {
|
|
15
15
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
16
16
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
17
17
|
const titleId = useId();
|
|
@@ -25,7 +25,9 @@ export function RealtimeVoiceModeEntry({ copy, disabled, open: controlledOpen, o
|
|
|
25
25
|
setOpen(false);
|
|
26
26
|
callback();
|
|
27
27
|
};
|
|
28
|
-
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { type: "button", variant: "ghost", size: "icon", disabled: disabled, "aria-label": copy.entryButtonLabel, "aria-expanded": open, className: cn("size-7 shrink-0 text-muted-foreground hover:text-foreground", className), children: _jsx(IconMicrophone, {}) }) }) }), _jsx(TooltipContent, { children: copy.entryButtonLabel })] }), _jsx(PopoverContent, { side: "top", align: "end", sideOffset: 10, className: "w-[min(22rem,calc(100vw-2rem))] p-4", "aria-labelledby": titleId, "aria-describedby": descriptionId, children: _jsxs("div", { className: "grid gap-3", children: [_jsxs("div", { className: "grid gap-1", children: [_jsx("h2", { id: titleId, className: "text-sm font-semibold text-foreground", children: copy.promptTitle }), _jsx("p", { id: descriptionId, className: "text-sm leading-relaxed text-muted-foreground", children: copy.promptDescription })] }), _jsxs("div", { className: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", children: [_jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => choose(onKeepDictating), children: copy.keepDictating }), _jsxs(Button, { type: "button", size: "sm", onClick: () => choose(onStartVoiceMode), children:
|
|
28
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { type: "button", variant: "ghost", size: "icon", disabled: disabled, "aria-label": copy.entryButtonLabel, "aria-expanded": open, className: cn("size-7 shrink-0 text-muted-foreground hover:text-foreground", className), children: _jsx(IconMicrophone, {}) }) }) }), _jsx(TooltipContent, { children: copy.entryButtonLabel })] }), _jsx(PopoverContent, { side: "top", align: "end", sideOffset: 10, className: "w-[min(22rem,calc(100vw-2rem))] p-4", "aria-labelledby": titleId, "aria-describedby": descriptionId, children: _jsxs("div", { className: "grid gap-3", children: [_jsxs("div", { className: "grid gap-1", children: [_jsx("h2", { id: titleId, className: "text-sm font-semibold text-foreground", children: setupRequired ? copy.setupTitle : copy.promptTitle }), _jsx("p", { id: descriptionId, className: "text-sm leading-relaxed text-muted-foreground", children: setupRequired ? copy.setupDescription : copy.promptDescription })] }), _jsxs("div", { className: "flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:justify-end", children: [_jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => choose(onKeepDictating), children: copy.keepDictating }), setupRequired ? (_jsxs(_Fragment, { children: [_jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => choose(onUseOpenAiKey ?? onStartVoiceMode), children: openAiConfigured
|
|
29
|
+
? copy.startWithOpenAiKey
|
|
30
|
+
: copy.useOpenAiKey }), _jsxs(Button, { type: "button", size: "sm", disabled: connectingBuilder, onClick: () => choose(onConnectBuilder ?? onStartVoiceMode), children: [connectingBuilder ? (_jsx(IconLoader2, { className: "animate-spin" })) : null, copy.connectBuilder] })] })) : (_jsxs(Button, { type: "button", size: "sm", onClick: () => choose(onStartVoiceMode), children: [_jsx(IconMicrophone, {}), copy.startVoiceMode] }))] })] }) })] }));
|
|
29
31
|
}
|
|
30
32
|
const SILENT_AUDIO_LEVELS = createRealtimeVoiceAudioLevelStore();
|
|
31
33
|
const WAVEFORM_WEIGHTS = [0.55, 0.82, 1, 0.82, 0.55];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealtimeVoiceMode.js","sourceRoot":"","sources":["../../../src/client/composer/RealtimeVoiceMode.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,YAAY,EACZ,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,6BAA6B,CAAC;AACr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AK,CAAC,CACzB,YAEA,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CACrB,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,GAAI,CACjC,CAAC,CAAC,CAAC,CACF,KAAC,aAAa,IACZ,KAAK,EAAE,aAAa,EACpB,aAAa,EAAE,aAAa,GAC5B,CACH,GACM,GACM,EACjB,KAAC,cAAc,cAAE,WAAW,GAAkB,IACtC,IACN,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Button } from \"@agent-native/toolkit/ui/button\";\nimport {\n IconAlertTriangle,\n IconLoader2,\n IconMicrophone,\n IconPhoneOff,\n IconVolume,\n} from \"@tabler/icons-react\";\nimport { useEffect, useId, useState, useSyncExternalStore } from \"react\";\n\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"../components/ui/popover.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../components/ui/tooltip.js\";\nimport { cn } from \"../utils.js\";\nimport {\n createRealtimeVoiceAudioLevelStore,\n type RealtimeVoiceAudioLevelStore,\n} from \"./realtime-voice-audio-level.js\";\n\nexport type RealtimeVoiceModeState =\n | \"connecting\"\n | \"listening\"\n | \"speaking\"\n | \"working\"\n | \"error\"\n | \"ending\";\n\n/**\n * User-visible copy stays outside the shared component so host catalogs remain\n * the source of truth. Callers should provide these values through `useT()`.\n */\nexport interface RealtimeVoiceModeCopy {\n entryButtonLabel: string;\n promptTitle: string;\n promptDescription: string;\n startVoiceMode: string;\n keepDictating: string;\n showChat: string;\n hideChat: string;\n endVoiceMode: string;\n status: Record<RealtimeVoiceModeState, string>;\n errors: {\n unsupported: string;\n responseFailed: string;\n sessionFailed: string;\n channelDisconnected: string;\n connectionFailed: string;\n offerFailed: string;\n };\n}\n\nexport interface RealtimeVoiceModeEntryProps {\n copy: RealtimeVoiceModeCopy;\n disabled?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n onStartVoiceMode: () => void;\n onKeepDictating: () => void;\n className?: string;\n}\n\n/**\n * Composer mic entry point for apps that support a full-duplex voice session.\n * The first click offers voice mode without silently changing the existing\n * editable-dictation behavior.\n */\nexport function RealtimeVoiceModeEntry({\n copy,\n disabled,\n open: controlledOpen,\n onOpenChange,\n onStartVoiceMode,\n onKeepDictating,\n className,\n}: RealtimeVoiceModeEntryProps) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(false);\n const open = controlledOpen ?? uncontrolledOpen;\n const titleId = useId();\n const descriptionId = useId();\n\n const setOpen = (nextOpen: boolean) => {\n if (controlledOpen === undefined) setUncontrolledOpen(nextOpen);\n onOpenChange?.(nextOpen);\n };\n\n const choose = (callback: () => void) => {\n setOpen(false);\n callback();\n };\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <Tooltip>\n <TooltipTrigger asChild>\n <PopoverTrigger asChild>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n disabled={disabled}\n aria-label={copy.entryButtonLabel}\n aria-expanded={open}\n className={cn(\n \"size-7 shrink-0 text-muted-foreground hover:text-foreground\",\n className,\n )}\n >\n <IconMicrophone />\n </Button>\n </PopoverTrigger>\n </TooltipTrigger>\n <TooltipContent>{copy.entryButtonLabel}</TooltipContent>\n </Tooltip>\n\n <PopoverContent\n side=\"top\"\n align=\"end\"\n sideOffset={10}\n className=\"w-[min(22rem,calc(100vw-2rem))] p-4\"\n aria-labelledby={titleId}\n aria-describedby={descriptionId}\n >\n <div className=\"grid gap-3\">\n <div className=\"grid gap-1\">\n <h2 id={titleId} className=\"text-sm font-semibold text-foreground\">\n {copy.promptTitle}\n </h2>\n <p\n id={descriptionId}\n className=\"text-sm leading-relaxed text-muted-foreground\"\n >\n {copy.promptDescription}\n </p>\n </div>\n\n <div className=\"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => choose(onKeepDictating)}\n >\n {copy.keepDictating}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={() => choose(onStartVoiceMode)}\n >\n <IconMicrophone />\n {copy.startVoiceMode}\n </Button>\n </div>\n </div>\n </PopoverContent>\n </Popover>\n );\n}\n\nexport interface RealtimeVoiceModeDockProps {\n state: RealtimeVoiceModeState;\n copy: RealtimeVoiceModeCopy;\n chatVisible: boolean;\n audioLevels?: RealtimeVoiceAudioLevelStore;\n onToggleChat: () => void;\n onEndVoiceMode: () => void;\n errorMessage?: string | null;\n className?: string;\n}\n\nconst SILENT_AUDIO_LEVELS = createRealtimeVoiceAudioLevelStore();\nconst WAVEFORM_WEIGHTS = [0.55, 0.82, 1, 0.82, 0.55];\nconst AUDIO_ACTIVITY_THRESHOLD = 0.035;\n\nfunction usePrefersReducedMotion(): boolean {\n const [reduced, setReduced] = useState(false);\n useEffect(() => {\n if (typeof window === \"undefined\" || !window.matchMedia) return;\n const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n const update = () => setReduced(query.matches);\n update();\n query.addEventListener?.(\"change\", update);\n return () => query.removeEventListener?.(\"change\", update);\n }, []);\n return reduced;\n}\n\nfunction VoiceWaveform({\n level,\n reducedMotion,\n}: {\n level: number;\n reducedMotion: boolean;\n}) {\n const visibleLevel = reducedMotion ? 0.45 : level;\n return (\n <span\n aria-hidden=\"true\"\n className=\"flex h-6 items-center justify-center gap-0.5\"\n data-realtime-voice-waveform=\"true\"\n >\n {WAVEFORM_WEIGHTS.map((weight, index) => (\n <span\n key={index}\n className=\"w-0.5 rounded-full bg-current transition-[height] duration-75 ease-out motion-reduce:transition-none\"\n style={{ height: `${4 + visibleLevel * 16 * weight}px` }}\n />\n ))}\n </span>\n );\n}\n\nconst ORB_STATE_CLASSES: Record<RealtimeVoiceModeState, string> = {\n connecting:\n \"bg-secondary text-secondary-foreground ring-4 ring-secondary/40 hover:bg-secondary/80\",\n listening:\n \"bg-primary text-primary-foreground ring-4 ring-primary/15 hover:bg-primary/90\",\n speaking:\n \"bg-foreground text-background ring-4 ring-foreground/15 hover:bg-foreground/90\",\n working:\n \"bg-secondary text-secondary-foreground ring-4 ring-secondary/40 hover:bg-secondary/80\",\n error:\n \"bg-destructive text-destructive-foreground ring-4 ring-destructive/15 hover:bg-destructive/90\",\n ending: \"bg-muted text-muted-foreground ring-4 ring-muted/40 cursor-wait\",\n};\n\nfunction VoiceStateIcon({ state }: { state: RealtimeVoiceModeState }) {\n switch (state) {\n case \"connecting\":\n return (\n <IconLoader2 className=\"animate-spin motion-reduce:animate-none\" />\n );\n case \"listening\":\n return <IconMicrophone />;\n case \"speaking\":\n return <IconVolume />;\n case \"working\":\n case \"ending\":\n return (\n <IconLoader2 className=\"animate-spin motion-reduce:animate-none\" />\n );\n case \"error\":\n return <IconAlertTriangle />;\n }\n}\n\n/**\n * Persistent voice-session control. Toggling the main orb only changes chat\n * visibility; ending the realtime session is intentionally a separate action.\n */\nexport function RealtimeVoiceModeDock({\n state,\n copy,\n chatVisible,\n audioLevels = SILENT_AUDIO_LEVELS,\n onToggleChat,\n onEndVoiceMode,\n errorMessage,\n className,\n}: RealtimeVoiceModeDockProps) {\n const statusId = useId();\n const levels = useSyncExternalStore(\n audioLevels.subscribe,\n audioLevels.getSnapshot,\n audioLevels.getSnapshot,\n );\n const reducedMotion = usePrefersReducedMotion();\n const activity =\n levels.output > AUDIO_ACTIVITY_THRESHOLD\n ? \"assistant\"\n : levels.input > AUDIO_ACTIVITY_THRESHOLD\n ? \"user\"\n : \"idle\";\n const activityLevel = activity === \"assistant\" ? levels.output : levels.input;\n const toggleLabel = chatVisible ? copy.hideChat : copy.showChat;\n const ending = state === \"ending\";\n const errorDetailVisible = state === \"error\" && Boolean(errorMessage);\n\n return (\n <div\n className={cn(\n \"pointer-events-none fixed bottom-4 end-4 flex max-w-[calc(100vw-2rem)] flex-col items-end gap-2\",\n className,\n )}\n style={{ zIndex: 270 }}\n data-realtime-voice-state={state}\n data-realtime-voice-activity={activity}\n >\n {errorDetailVisible ? (\n <div\n role=\"alert\"\n className=\"pointer-events-auto max-w-xs rounded-lg border border-destructive/30 bg-background px-3 py-2 text-sm text-destructive shadow-md\"\n >\n {errorMessage}\n </div>\n ) : null}\n\n <div\n id={statusId}\n role={state === \"error\" && !errorDetailVisible ? \"alert\" : \"status\"}\n aria-live={\n state === \"error\" && !errorDetailVisible ? \"assertive\" : \"polite\"\n }\n className=\"rounded-full border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground shadow-sm\"\n >\n {copy.status[state]}\n </div>\n\n <div className=\"pointer-events-auto flex items-center gap-2\">\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"icon\"\n disabled={ending}\n onClick={onEndVoiceMode}\n aria-label={copy.endVoiceMode}\n className=\"size-10 rounded-full bg-background shadow-md\"\n >\n <IconPhoneOff />\n </Button>\n </TooltipTrigger>\n <TooltipContent>{copy.endVoiceMode}</TooltipContent>\n </Tooltip>\n\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n size=\"icon\"\n disabled={ending}\n onClick={onToggleChat}\n aria-label={toggleLabel}\n aria-pressed={chatVisible}\n aria-describedby={statusId}\n className={cn(\n \"size-14 rounded-full shadow-lg\",\n ORB_STATE_CLASSES[state],\n )}\n >\n {activity === \"idle\" ? (\n <VoiceStateIcon state={state} />\n ) : (\n <VoiceWaveform\n level={activityLevel}\n reducedMotion={reducedMotion}\n />\n )}\n </Button>\n </TooltipTrigger>\n <TooltipContent>{toggleLabel}</TooltipContent>\n </Tooltip>\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RealtimeVoiceMode.js","sourceRoot":"","sources":["../../../src/client/composer/RealtimeVoiceMode.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,YAAY,EACZ,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,KAA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AAW,GAAkB,IACtC,IACN,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Button } from \"@agent-native/toolkit/ui/button\";\nimport {\n IconAlertTriangle,\n IconLoader2,\n IconMicrophone,\n IconPhoneOff,\n IconVolume,\n} from \"@tabler/icons-react\";\nimport { useEffect, useId, useState, useSyncExternalStore } from \"react\";\n\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"../components/ui/popover.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../components/ui/tooltip.js\";\nimport { cn } from \"../utils.js\";\nimport {\n createRealtimeVoiceAudioLevelStore,\n type RealtimeVoiceAudioLevelStore,\n} from \"./realtime-voice-audio-level.js\";\n\nexport type RealtimeVoiceModeState =\n | \"connecting\"\n | \"listening\"\n | \"speaking\"\n | \"working\"\n | \"error\"\n | \"ending\";\n\n/**\n * User-visible copy stays outside the shared component so host catalogs remain\n * the source of truth. Callers should provide these values through `useT()`.\n */\nexport interface RealtimeVoiceModeCopy {\n entryButtonLabel: string;\n promptTitle: string;\n promptDescription: string;\n setupTitle: string;\n setupDescription: string;\n connectBuilder: string;\n useOpenAiKey: string;\n startWithOpenAiKey: string;\n startVoiceMode: string;\n keepDictating: string;\n showChat: string;\n hideChat: string;\n endVoiceMode: string;\n status: Record<RealtimeVoiceModeState, string>;\n errors: {\n unsupported: string;\n responseFailed: string;\n sessionFailed: string;\n channelDisconnected: string;\n connectionFailed: string;\n offerFailed: string;\n };\n}\n\nexport interface RealtimeVoiceModeEntryProps {\n copy: RealtimeVoiceModeCopy;\n disabled?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n onStartVoiceMode: () => void;\n onKeepDictating: () => void;\n setupRequired?: boolean;\n openAiConfigured?: boolean;\n connectingBuilder?: boolean;\n onConnectBuilder?: () => void;\n onUseOpenAiKey?: () => void;\n className?: string;\n}\n\n/**\n * Composer mic entry point for apps that support a full-duplex voice session.\n * The first click offers voice mode without silently changing the existing\n * editable-dictation behavior.\n */\nexport function RealtimeVoiceModeEntry({\n copy,\n disabled,\n open: controlledOpen,\n onOpenChange,\n onStartVoiceMode,\n onKeepDictating,\n setupRequired = false,\n openAiConfigured = false,\n connectingBuilder = false,\n onConnectBuilder,\n onUseOpenAiKey,\n className,\n}: RealtimeVoiceModeEntryProps) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState(false);\n const open = controlledOpen ?? uncontrolledOpen;\n const titleId = useId();\n const descriptionId = useId();\n\n const setOpen = (nextOpen: boolean) => {\n if (controlledOpen === undefined) setUncontrolledOpen(nextOpen);\n onOpenChange?.(nextOpen);\n };\n\n const choose = (callback: () => void) => {\n setOpen(false);\n callback();\n };\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <Tooltip>\n <TooltipTrigger asChild>\n <PopoverTrigger asChild>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n disabled={disabled}\n aria-label={copy.entryButtonLabel}\n aria-expanded={open}\n className={cn(\n \"size-7 shrink-0 text-muted-foreground hover:text-foreground\",\n className,\n )}\n >\n <IconMicrophone />\n </Button>\n </PopoverTrigger>\n </TooltipTrigger>\n <TooltipContent>{copy.entryButtonLabel}</TooltipContent>\n </Tooltip>\n\n <PopoverContent\n side=\"top\"\n align=\"end\"\n sideOffset={10}\n className=\"w-[min(22rem,calc(100vw-2rem))] p-4\"\n aria-labelledby={titleId}\n aria-describedby={descriptionId}\n >\n <div className=\"grid gap-3\">\n <div className=\"grid gap-1\">\n <h2 id={titleId} className=\"text-sm font-semibold text-foreground\">\n {setupRequired ? copy.setupTitle : copy.promptTitle}\n </h2>\n <p\n id={descriptionId}\n className=\"text-sm leading-relaxed text-muted-foreground\"\n >\n {setupRequired ? copy.setupDescription : copy.promptDescription}\n </p>\n </div>\n\n <div className=\"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:justify-end\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => choose(onKeepDictating)}\n >\n {copy.keepDictating}\n </Button>\n {setupRequired ? (\n <>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => choose(onUseOpenAiKey ?? onStartVoiceMode)}\n >\n {openAiConfigured\n ? copy.startWithOpenAiKey\n : copy.useOpenAiKey}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n disabled={connectingBuilder}\n onClick={() => choose(onConnectBuilder ?? onStartVoiceMode)}\n >\n {connectingBuilder ? (\n <IconLoader2 className=\"animate-spin\" />\n ) : null}\n {copy.connectBuilder}\n </Button>\n </>\n ) : (\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={() => choose(onStartVoiceMode)}\n >\n <IconMicrophone />\n {copy.startVoiceMode}\n </Button>\n )}\n </div>\n </div>\n </PopoverContent>\n </Popover>\n );\n}\n\nexport interface RealtimeVoiceModeDockProps {\n state: RealtimeVoiceModeState;\n copy: RealtimeVoiceModeCopy;\n chatVisible: boolean;\n audioLevels?: RealtimeVoiceAudioLevelStore;\n onToggleChat: () => void;\n onEndVoiceMode: () => void;\n errorMessage?: string | null;\n className?: string;\n}\n\nconst SILENT_AUDIO_LEVELS = createRealtimeVoiceAudioLevelStore();\nconst WAVEFORM_WEIGHTS = [0.55, 0.82, 1, 0.82, 0.55];\nconst AUDIO_ACTIVITY_THRESHOLD = 0.035;\n\nfunction usePrefersReducedMotion(): boolean {\n const [reduced, setReduced] = useState(false);\n useEffect(() => {\n if (typeof window === \"undefined\" || !window.matchMedia) return;\n const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n const update = () => setReduced(query.matches);\n update();\n query.addEventListener?.(\"change\", update);\n return () => query.removeEventListener?.(\"change\", update);\n }, []);\n return reduced;\n}\n\nfunction VoiceWaveform({\n level,\n reducedMotion,\n}: {\n level: number;\n reducedMotion: boolean;\n}) {\n const visibleLevel = reducedMotion ? 0.45 : level;\n return (\n <span\n aria-hidden=\"true\"\n className=\"flex h-6 items-center justify-center gap-0.5\"\n data-realtime-voice-waveform=\"true\"\n >\n {WAVEFORM_WEIGHTS.map((weight, index) => (\n <span\n key={index}\n className=\"w-0.5 rounded-full bg-current transition-[height] duration-75 ease-out motion-reduce:transition-none\"\n style={{ height: `${4 + visibleLevel * 16 * weight}px` }}\n />\n ))}\n </span>\n );\n}\n\nconst ORB_STATE_CLASSES: Record<RealtimeVoiceModeState, string> = {\n connecting:\n \"bg-secondary text-secondary-foreground ring-4 ring-secondary/40 hover:bg-secondary/80\",\n listening:\n \"bg-primary text-primary-foreground ring-4 ring-primary/15 hover:bg-primary/90\",\n speaking:\n \"bg-foreground text-background ring-4 ring-foreground/15 hover:bg-foreground/90\",\n working:\n \"bg-secondary text-secondary-foreground ring-4 ring-secondary/40 hover:bg-secondary/80\",\n error:\n \"bg-destructive text-destructive-foreground ring-4 ring-destructive/15 hover:bg-destructive/90\",\n ending: \"bg-muted text-muted-foreground ring-4 ring-muted/40 cursor-wait\",\n};\n\nfunction VoiceStateIcon({ state }: { state: RealtimeVoiceModeState }) {\n switch (state) {\n case \"connecting\":\n return (\n <IconLoader2 className=\"animate-spin motion-reduce:animate-none\" />\n );\n case \"listening\":\n return <IconMicrophone />;\n case \"speaking\":\n return <IconVolume />;\n case \"working\":\n case \"ending\":\n return (\n <IconLoader2 className=\"animate-spin motion-reduce:animate-none\" />\n );\n case \"error\":\n return <IconAlertTriangle />;\n }\n}\n\n/**\n * Persistent voice-session control. Toggling the main orb only changes chat\n * visibility; ending the realtime session is intentionally a separate action.\n */\nexport function RealtimeVoiceModeDock({\n state,\n copy,\n chatVisible,\n audioLevels = SILENT_AUDIO_LEVELS,\n onToggleChat,\n onEndVoiceMode,\n errorMessage,\n className,\n}: RealtimeVoiceModeDockProps) {\n const statusId = useId();\n const levels = useSyncExternalStore(\n audioLevels.subscribe,\n audioLevels.getSnapshot,\n audioLevels.getSnapshot,\n );\n const reducedMotion = usePrefersReducedMotion();\n const activity =\n levels.output > AUDIO_ACTIVITY_THRESHOLD\n ? \"assistant\"\n : levels.input > AUDIO_ACTIVITY_THRESHOLD\n ? \"user\"\n : \"idle\";\n const activityLevel = activity === \"assistant\" ? levels.output : levels.input;\n const toggleLabel = chatVisible ? copy.hideChat : copy.showChat;\n const ending = state === \"ending\";\n const errorDetailVisible = state === \"error\" && Boolean(errorMessage);\n\n return (\n <div\n className={cn(\n \"pointer-events-none fixed bottom-4 end-4 flex max-w-[calc(100vw-2rem)] flex-col items-end gap-2\",\n className,\n )}\n style={{ zIndex: 270 }}\n data-realtime-voice-state={state}\n data-realtime-voice-activity={activity}\n >\n {errorDetailVisible ? (\n <div\n role=\"alert\"\n className=\"pointer-events-auto max-w-xs rounded-lg border border-destructive/30 bg-background px-3 py-2 text-sm text-destructive shadow-md\"\n >\n {errorMessage}\n </div>\n ) : null}\n\n <div\n id={statusId}\n role={state === \"error\" && !errorDetailVisible ? \"alert\" : \"status\"}\n aria-live={\n state === \"error\" && !errorDetailVisible ? \"assertive\" : \"polite\"\n }\n className=\"rounded-full border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground shadow-sm\"\n >\n {copy.status[state]}\n </div>\n\n <div className=\"pointer-events-auto flex items-center gap-2\">\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"icon\"\n disabled={ending}\n onClick={onEndVoiceMode}\n aria-label={copy.endVoiceMode}\n className=\"size-10 rounded-full bg-background shadow-md\"\n >\n <IconPhoneOff />\n </Button>\n </TooltipTrigger>\n <TooltipContent>{copy.endVoiceMode}</TooltipContent>\n </Tooltip>\n\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n size=\"icon\"\n disabled={ending}\n onClick={onToggleChat}\n aria-label={toggleLabel}\n aria-pressed={chatVisible}\n aria-describedby={statusId}\n className={cn(\n \"size-14 rounded-full shadow-lg\",\n ORB_STATE_CLASSES[state],\n )}\n >\n {activity === \"idle\" ? (\n <VoiceStateIcon state={state} />\n ) : (\n <VoiceWaveform\n level={activityLevel}\n reducedMotion={reducedMotion}\n />\n )}\n </Button>\n </TooltipTrigger>\n <TooltipContent>{toggleLabel}</TooltipContent>\n </Tooltip>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -18,6 +18,22 @@ export declare function canSubmitComposerContent(options: {
|
|
|
18
18
|
attachmentCount: number;
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
}): boolean;
|
|
21
|
+
export declare function resolveComposerPrimaryAction(options: {
|
|
22
|
+
canSubmit: boolean;
|
|
23
|
+
hasStopButton: boolean;
|
|
24
|
+
}): "send" | "stop";
|
|
25
|
+
export type ContextChipBackspaceAction = {
|
|
26
|
+
type: "select";
|
|
27
|
+
key: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: "remove";
|
|
30
|
+
key: string;
|
|
31
|
+
} | null;
|
|
32
|
+
export declare function resolveContextChipBackspaceAction(options: {
|
|
33
|
+
contextItemKeys: string[];
|
|
34
|
+
selectedKey: string | null;
|
|
35
|
+
cursorAtStart: boolean;
|
|
36
|
+
}): ContextChipBackspaceAction;
|
|
21
37
|
export declare function getOversizedDocumentAttachmentError(attachments: ReadonlyArray<unknown>): string | null;
|
|
22
38
|
export declare function getComposerSubmitIntentForEnterKey(event: Pick<KeyboardEvent, "key" | "shiftKey" | "metaKey" | "ctrlKey">, isMac: boolean): ComposerSubmitIntent | null;
|
|
23
39
|
export declare function insertComposerHardBreakAndScrollIntoView(view: Pick<EditorView, "state" | "dispatch">): boolean;
|
|
@@ -61,8 +77,13 @@ export interface TiptapComposerProps {
|
|
|
61
77
|
onTextChange?: (text: string) => void;
|
|
62
78
|
/** Custom action button (e.g. stop button) to render instead of the default send button. */
|
|
63
79
|
actionButton?: React.ReactNode;
|
|
64
|
-
/** Extra button to render alongside the
|
|
80
|
+
/** Extra button to render alongside the primary action. */
|
|
65
81
|
extraActionButton?: React.ReactNode;
|
|
82
|
+
/**
|
|
83
|
+
* Stop control shown instead of the disabled send button while the composer
|
|
84
|
+
* has no sendable content. Typing or attaching content restores send.
|
|
85
|
+
*/
|
|
86
|
+
stopButton?: React.ReactNode;
|
|
66
87
|
/** Custom attachment button to render instead of ComposerPrimitive.AddAttachment. */
|
|
67
88
|
attachButton?: React.ReactNode;
|
|
68
89
|
/** Custom host-owned control rendered next to the attachment affordance. */
|
|
@@ -157,6 +178,8 @@ export declare const MODEL_SELECTOR_POPOVER_STYLE: {
|
|
|
157
178
|
fontSize: number;
|
|
158
179
|
maxHeight: string;
|
|
159
180
|
};
|
|
181
|
+
export declare function compactComposerModelName(model: string): string;
|
|
182
|
+
export declare function compactComposerReasoningEffortLabel(effort: ReasoningEffort): string;
|
|
160
183
|
/**
|
|
161
184
|
* Optional secondary model menu for apps that drive a separate generation model
|
|
162
185
|
* alongside the chat LLM (e.g. the Assets app's image-generation model). When
|
|
@@ -178,6 +201,6 @@ export interface ComposerImageModelMenu {
|
|
|
178
201
|
label?: string;
|
|
179
202
|
}
|
|
180
203
|
export declare function getComposerReasoningEffortOptions(model: string): ReasoningEffort[];
|
|
181
|
-
export declare function TiptapComposer({ placeholder, disabled, focusRef, initialText, initialTextKey, onSubmit, onBeforeSubmit, clearOnSubmit, onTextChange, actionButton, extraActionButton, attachButton, modeControl, toolbarSlot, layoutVariant, slashCommands, slashSkills, includeDefaultSlashCommands, includeDefaultSlashSkills, onSlashCommand, execMode, onExecModeChange, planModeDisabled, planModeDisabledReason, voiceEnabled, selectedModel, selectedEffort, availableModels, onModelChange, onEffortChange, providerConnectStatusEnabled, onConnectProvider, imageModelMenu, draftScope, contextItems, onRemoveContextItem, plusMenuMode, interceptBuildRequestsForBuilder, onAttachmentError, }: TiptapComposerProps): React.JSX.Element;
|
|
204
|
+
export declare function TiptapComposer({ placeholder, disabled, focusRef, initialText, initialTextKey, onSubmit, onBeforeSubmit, clearOnSubmit, onTextChange, actionButton, extraActionButton, stopButton, attachButton, modeControl, toolbarSlot, layoutVariant, slashCommands, slashSkills, includeDefaultSlashCommands, includeDefaultSlashSkills, onSlashCommand, execMode, onExecModeChange, planModeDisabled, planModeDisabledReason, voiceEnabled, selectedModel, selectedEffort, availableModels, onModelChange, onEffortChange, providerConnectStatusEnabled, onConnectProvider, imageModelMenu, draftScope, contextItems, onRemoveContextItem, plusMenuMode, interceptBuildRequestsForBuilder, onAttachmentError, }: TiptapComposerProps): React.JSX.Element;
|
|
182
205
|
export {};
|
|
183
206
|
//# sourceMappingURL=TiptapComposer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TiptapComposer.d.ts","sourceRoot":"","sources":["../../../src/client/composer/TiptapComposer.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,KAON,MAAM,OAAO,CAAC;AAEf,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,sBAAsB,EAItB,KAAK,oBAAoB,EAI1B,MAAM,kBAAkB,CAAC;AA0B1B,OAAO,KAAK,EAEV,WAAW,EACX,SAAS,EACT,YAAY,EAEZ,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAMpB,MAAM,WAAW,oBAAoB;IACnC,KAAK,IAAI,IAAI,CAAC;IACd,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,CAAC,GAAG,EAAE,sBAAsB,GAAG,IAAI,CAAC;CACpD;AAED,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D,eAAO,MAAM,+BAA+B,QAAQ,CAAC;AAErD,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAKV;AAoID,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,aAAa,C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DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,sDAAsD;IACtD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,MAAM,GACZ,eAAe,EAAE,CAInB;AA8WD,wBAAgB,cAAc,CAAC,EAC7B,WAAgC,EAChC,QAAgB,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,QAAQ,EACR,cAAc,EACd,aAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,aAAyB,EACzB,aAAkB,EAClB,WAAgB,EAChB,2BAAkC,EAClC,yBAAgC,EAChC,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,gBAAwB,EACxB,sBAAsB,EACtB,YAA8C,EAC9C,aAAa,EACb,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,4BAA4B,EAC5B,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,YAAiB,EACjB,mBAAmB,EACnB,YAAqB,EACrB,gCAAwC,EACxC,iBAAiB,GAClB,EAAE,mBAAmB,qBA+5CrB"}
|
|
@@ -30,6 +30,22 @@ export function canSubmitComposerContent(options) {
|
|
|
30
30
|
return (!options.disabled &&
|
|
31
31
|
(options.hasEditorContent || options.attachmentCount > 0));
|
|
32
32
|
}
|
|
33
|
+
export function resolveComposerPrimaryAction(options) {
|
|
34
|
+
return !options.canSubmit && options.hasStopButton ? "stop" : "send";
|
|
35
|
+
}
|
|
36
|
+
export function resolveContextChipBackspaceAction(options) {
|
|
37
|
+
if (!options.cursorAtStart || options.contextItemKeys.length === 0) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (options.selectedKey &&
|
|
41
|
+
options.contextItemKeys.includes(options.selectedKey)) {
|
|
42
|
+
return { type: "remove", key: options.selectedKey };
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
type: "select",
|
|
46
|
+
key: options.contextItemKeys[options.contextItemKeys.length - 1],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
33
49
|
const MAX_DOCUMENT_ATTACHMENT_BYTES = 4 * 1024 * 1024;
|
|
34
50
|
function composerReferenceFromMentionItem(item) {
|
|
35
51
|
return {
|
|
@@ -446,6 +462,22 @@ function friendlyModelName(model) {
|
|
|
446
462
|
}
|
|
447
463
|
return model;
|
|
448
464
|
}
|
|
465
|
+
export function compactComposerModelName(model) {
|
|
466
|
+
const gpt56Variant = model.match(/^(?:openai\/)?gpt-5[.-]6[.-](sol|terra|luna)$/i)?.[1];
|
|
467
|
+
if (gpt56Variant) {
|
|
468
|
+
return gpt56Variant[0].toUpperCase() + gpt56Variant.slice(1).toLowerCase();
|
|
469
|
+
}
|
|
470
|
+
return friendlyModelName(model);
|
|
471
|
+
}
|
|
472
|
+
export function compactComposerReasoningEffortLabel(effort) {
|
|
473
|
+
if (effort === "medium" || effort === "auto")
|
|
474
|
+
return "Med";
|
|
475
|
+
if (effort === "minimal")
|
|
476
|
+
return "Min";
|
|
477
|
+
if (effort === "xhigh")
|
|
478
|
+
return "XHigh";
|
|
479
|
+
return reasoningEffortLabel(effort);
|
|
480
|
+
}
|
|
449
481
|
/**
|
|
450
482
|
* Deduplicate models to only the latest version per family.
|
|
451
483
|
* e.g. [opus-4-7, opus-4-6, opus-4-5] → [opus-4-7]
|
|
@@ -554,7 +586,9 @@ function ModelSelector({ model, effort = DEFAULT_REASONING_EFFORT, engines, onCh
|
|
|
554
586
|
window.dispatchEvent(new CustomEvent("agent-panel:open-settings"));
|
|
555
587
|
setOpen(false);
|
|
556
588
|
}, []);
|
|
557
|
-
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", "data-agent-composer-slot": "model-button",
|
|
589
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", "data-agent-composer-slot": "model-button", "aria-label": `Model: ${friendlyModelName(model)}${effortOptions.length > 0
|
|
590
|
+
? `. Reasoning: ${reasoningEffortLabel(selectedEffort)}`
|
|
591
|
+
: ""}`, className: "agent-composer-model-button flex min-w-0 max-w-[10.5rem] shrink items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-muted-foreground hover:bg-accent/50 hover:text-foreground", children: [_jsx("span", { className: "min-w-0 truncate", children: compactComposerModelName(model) }), effortOptions.length > 0 && (_jsxs("span", { className: "agent-composer-model-effort min-w-0 shrink truncate text-muted-foreground/70", children: ["\u00B7 ", compactComposerReasoningEffortLabel(selectedEffort)] })), _jsx(IconChevronDown, { className: "h-3 w-3 shrink-0 opacity-60" })] }) }), _jsxs(PopoverContent, { side: "top", align: "end", sideOffset: 6, collisionPadding: 8, "data-agent-native-composer-popover": "true", className: "z-[260] box-border w-72 overflow-y-auto rounded-lg border-border p-0 py-1 shadow-lg", style: MODEL_SELECTOR_POPOVER_STYLE, children: [showBuilderCta && (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", onClick: () => {
|
|
558
592
|
if (onConnectProvider) {
|
|
559
593
|
onConnectProvider();
|
|
560
594
|
}
|
|
@@ -594,7 +628,7 @@ function ModelSelector({ model, effort = DEFAULT_REASONING_EFFORT, engines, onCh
|
|
|
594
628
|
}), effortOptions.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-1 border-t border-border" }), _jsx("div", { className: "flex items-center hover:bg-accent/30", children: _jsxs("button", { type: "button", "aria-expanded": reasoningExpanded, onClick: () => setReasoningExpanded((prev) => !prev), className: "flex flex-1 min-w-0 items-center gap-1.5 px-2 py-1.5 cursor-pointer text-start", children: [reasoningExpanded ? (_jsx(IconChevronDown, { className: "h-3 w-3 shrink-0 text-muted-foreground" })) : (_jsx(IconChevronRight, { className: "h-3 w-3 shrink-0 text-muted-foreground rtl:-scale-x-100" })), _jsx("span", { className: "text-[11px] font-medium text-muted-foreground uppercase tracking-wide shrink-0", children: "Reasoning" }), !reasoningExpanded && (_jsx("span", { className: "text-[11px] text-muted-foreground/80 truncate", children: reasoningEffortLabel(selectedEffort) }))] }) }), reasoningExpanded &&
|
|
595
629
|
effortOptions.map((option) => (_jsxs("button", { type: "button", onClick: () => onEffortChange?.(option), className: "flex w-full items-center gap-3 ps-7 pe-3 py-1.5 text-start hover:bg-accent/50", children: [_jsx("span", { className: "flex-1 min-w-0 text-[13px] text-foreground truncate", children: reasoningEffortLabel(option) }), option === selectedEffort && (_jsx(IconCheck, { className: "h-3.5 w-3.5 shrink-0 text-blue-500" }))] }, option)))] }))] })] }));
|
|
596
630
|
}
|
|
597
|
-
export function TiptapComposer({ placeholder = "Message agent...", disabled = false, focusRef, initialText, initialTextKey, onSubmit, onBeforeSubmit, clearOnSubmit = true, onTextChange, actionButton, extraActionButton, attachButton, modeControl, toolbarSlot, layoutVariant = "default", slashCommands = [], slashSkills = [], includeDefaultSlashCommands = true, includeDefaultSlashSkills = true, onSlashCommand, execMode, onExecModeChange, planModeDisabled = false, planModeDisabledReason, voiceEnabled = DEFAULT_VOICE_DICTATION_ENABLED, selectedModel, selectedEffort, availableModels, onModelChange, onEffortChange, providerConnectStatusEnabled, onConnectProvider, imageModelMenu, draftScope, contextItems = [], onRemoveContextItem, plusMenuMode = "full", interceptBuildRequestsForBuilder = false, onAttachmentError, }) {
|
|
631
|
+
export function TiptapComposer({ placeholder = "Message agent...", disabled = false, focusRef, initialText, initialTextKey, onSubmit, onBeforeSubmit, clearOnSubmit = true, onTextChange, actionButton, extraActionButton, stopButton, attachButton, modeControl, toolbarSlot, layoutVariant = "default", slashCommands = [], slashSkills = [], includeDefaultSlashCommands = true, includeDefaultSlashSkills = true, onSlashCommand, execMode, onExecModeChange, planModeDisabled = false, planModeDisabledReason, voiceEnabled = DEFAULT_VOICE_DICTATION_ENABLED, selectedModel, selectedEffort, availableModels, onModelChange, onEffortChange, providerConnectStatusEnabled, onConnectProvider, imageModelMenu, draftScope, contextItems = [], onRemoveContextItem, plusMenuMode = "full", interceptBuildRequestsForBuilder = false, onAttachmentError, }) {
|
|
598
632
|
const [popover, setPopover] = useState(null);
|
|
599
633
|
const popoverRef = useRef(null);
|
|
600
634
|
const composerRuntime = useComposerRuntime();
|
|
@@ -602,6 +636,7 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
|
|
|
602
636
|
const submitInFlightRef = useRef(false);
|
|
603
637
|
const [editorHasText, setEditorHasText] = useState(false);
|
|
604
638
|
const [slotReferences, setSlotReferences] = useState([]);
|
|
639
|
+
const [selectedContextItemKey, setSelectedContextItemKey] = useState(null);
|
|
605
640
|
const composerText = useComposer((state) => state.text);
|
|
606
641
|
const composerAttachments = useComposer((state) => state.attachments);
|
|
607
642
|
const canSend = canSubmitComposerContent({
|
|
@@ -609,6 +644,10 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
|
|
|
609
644
|
attachmentCount: composerAttachments.length,
|
|
610
645
|
disabled,
|
|
611
646
|
});
|
|
647
|
+
const primaryAction = resolveComposerPrimaryAction({
|
|
648
|
+
canSubmit: canSend,
|
|
649
|
+
hasStopButton: Boolean(stopButton),
|
|
650
|
+
});
|
|
612
651
|
const hasContextRows = contextItems.length > 0 || slotReferences.length > 0;
|
|
613
652
|
const [composerMode, setComposerMode] = useState(null);
|
|
614
653
|
const composerModeRef = useRef(null);
|
|
@@ -664,8 +703,21 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
|
|
|
664
703
|
onSlashCommandRef.current = onSlashCommand;
|
|
665
704
|
const onTextChangeRef = useRef(onTextChange);
|
|
666
705
|
onTextChangeRef.current = onTextChange;
|
|
706
|
+
const contextItemsRef = useRef(contextItems);
|
|
707
|
+
contextItemsRef.current = contextItems;
|
|
708
|
+
const onRemoveContextItemRef = useRef(onRemoveContextItem);
|
|
709
|
+
onRemoveContextItemRef.current = onRemoveContextItem;
|
|
710
|
+
const selectedContextItemKeyRef = useRef(null);
|
|
711
|
+
selectedContextItemKeyRef.current = selectedContextItemKey;
|
|
667
712
|
const initialTextKeyRef = useRef(undefined);
|
|
668
713
|
const seenReferenceInsertIdsRef = useRef(new Set());
|
|
714
|
+
useEffect(() => {
|
|
715
|
+
if (selectedContextItemKey &&
|
|
716
|
+
!contextItems.some((item) => item.key === selectedContextItemKey)) {
|
|
717
|
+
selectedContextItemKeyRef.current = null;
|
|
718
|
+
setSelectedContextItemKey(null);
|
|
719
|
+
}
|
|
720
|
+
}, [contextItems, selectedContextItemKey]);
|
|
669
721
|
const closePopover = useCallback(() => {
|
|
670
722
|
setPopover(null);
|
|
671
723
|
popoverStateRef.current = null;
|
|
@@ -734,6 +786,13 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
|
|
|
734
786
|
catch { }
|
|
735
787
|
}, 300);
|
|
736
788
|
},
|
|
789
|
+
onSelectionUpdate: ({ editor: ed }) => {
|
|
790
|
+
const { from, to } = ed.state.selection;
|
|
791
|
+
if (selectedContextItemKeyRef.current && (from !== to || from > 1)) {
|
|
792
|
+
selectedContextItemKeyRef.current = null;
|
|
793
|
+
setSelectedContextItemKey(null);
|
|
794
|
+
}
|
|
795
|
+
},
|
|
737
796
|
editorProps: {
|
|
738
797
|
attributes: {
|
|
739
798
|
"data-agent-composer-variant": layoutVariant,
|
|
@@ -855,9 +914,35 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
|
|
|
855
914
|
return false;
|
|
856
915
|
}
|
|
857
916
|
}
|
|
917
|
+
const { from, to } = view.state.selection;
|
|
918
|
+
const cursorAtStart = from === to && from <= 1;
|
|
919
|
+
if (event.key === "Backspace" && onRemoveContextItemRef.current) {
|
|
920
|
+
const chipAction = resolveContextChipBackspaceAction({
|
|
921
|
+
contextItemKeys: contextItemsRef.current.map((item) => item.key),
|
|
922
|
+
selectedKey: selectedContextItemKeyRef.current,
|
|
923
|
+
cursorAtStart,
|
|
924
|
+
});
|
|
925
|
+
if (chipAction) {
|
|
926
|
+
event.preventDefault();
|
|
927
|
+
if (chipAction.type === "select") {
|
|
928
|
+
selectedContextItemKeyRef.current = chipAction.key;
|
|
929
|
+
setSelectedContextItemKey(chipAction.key);
|
|
930
|
+
}
|
|
931
|
+
else {
|
|
932
|
+
selectedContextItemKeyRef.current = null;
|
|
933
|
+
setSelectedContextItemKey(null);
|
|
934
|
+
contextItemsRef.current = contextItemsRef.current.filter((item) => item.key !== chipAction.key);
|
|
935
|
+
onRemoveContextItemRef.current?.(chipAction.key);
|
|
936
|
+
}
|
|
937
|
+
return true;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
if (selectedContextItemKeyRef.current) {
|
|
941
|
+
selectedContextItemKeyRef.current = null;
|
|
942
|
+
setSelectedContextItemKey(null);
|
|
943
|
+
}
|
|
858
944
|
// Backspace removes composer mode chip when editor is empty
|
|
859
945
|
if (event.key === "Backspace" && composerModeRef.current) {
|
|
860
|
-
const { from, to } = view.state.selection;
|
|
861
946
|
if (view.state.doc.textContent.trim() === "" &&
|
|
862
947
|
from === to &&
|
|
863
948
|
from <= 1) {
|
|
@@ -1655,7 +1740,13 @@ export function TiptapComposer({ placeholder = "Message agent...", disabled = fa
|
|
|
1655
1740
|
} }) })), hasContextRows && (_jsxs("div", { "data-agent-composer-variant": layoutVariant, "data-agent-composer-slot": "context-row", className: "agent-composer-context-row flex flex-wrap gap-1.5 px-2.5 pt-2 pb-0", children: [slotReferences.map((ref) => (_jsxs("span", { className: "inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1 text-[11px] font-medium text-foreground shadow-sm", children: [_jsx(IconClipboardList, { className: "h-3 w-3 shrink-0 text-muted-foreground" }), ref.slotLabel && (_jsx("span", { className: "shrink-0 text-muted-foreground", children: ref.slotLabel })), _jsx("span", { className: "min-w-0 truncate", children: ref.label }), _jsx("button", { type: "button", onClick: () => {
|
|
1656
1741
|
setSlotReferences((current) => removeSlotReference(current, ref));
|
|
1657
1742
|
editor?.commands.focus("end");
|
|
1658
|
-
}, "aria-label": `Remove ${slotReferenceTitle(ref)} reference`, className: "ms-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground", children: _jsx(IconX, { className: "h-3 w-3" }) })] }, ref.slotKey))), contextItems.map((item) => (_jsxs("span", { className:
|
|
1659
|
-
|
|
1743
|
+
}, "aria-label": `Remove ${slotReferenceTitle(ref)} reference`, className: "ms-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground", children: _jsx(IconX, { className: "h-3 w-3" }) })] }, ref.slotKey))), contextItems.map((item) => (_jsxs("span", { "data-state": selectedContextItemKey === item.key ? "selected" : undefined, className: `inline-flex max-w-full items-center gap-1.5 rounded-md border px-2 py-1 text-[11px] font-medium text-foreground ${selectedContextItemKey === item.key
|
|
1744
|
+
? "border-ring bg-accent ring-2 ring-ring/40"
|
|
1745
|
+
: "border-border bg-muted/50"}`, children: [_jsx(IconClipboardList, { className: "h-3 w-3 shrink-0 text-muted-foreground" }), _jsx("span", { className: "min-w-0 truncate", children: item.title }), _jsx("button", { type: "button", onClick: () => {
|
|
1746
|
+
selectedContextItemKeyRef.current = null;
|
|
1747
|
+
setSelectedContextItemKey(null);
|
|
1748
|
+
onRemoveContextItem?.(item.key);
|
|
1749
|
+
}, "aria-label": `Remove ${item.title} context`, className: "ms-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground", children: _jsx(IconX, { className: "h-3 w-3" }) })] }, item.key)))] })), _jsx("div", { "data-agent-composer-variant": layoutVariant, "data-agent-composer-slot": "editor-wrap", className: `agent-composer-editor-wrap ${composerMode || hasContextRows ? "px-2 pt-1 pb-1" : "px-2 pt-2 pb-1"}`, children: _jsx(EditorContent, { editor: editor, "data-agent-composer-variant": layoutVariant, "data-agent-composer-slot": "editor", className: "agent-composer-editor aui-composer flex-1 min-w-0 [&_.ProseMirror]:outline-none [&_.ProseMirror_p]:m-0 px-0.5" }) }), voiceEnabled && _jsx(VoiceRecordingOverlay, { voice: voice }), _jsxs("div", { "data-agent-composer-variant": layoutVariant, "data-agent-composer-slot": "toolbar", className: "agent-composer-toolbar flex items-center gap-1 px-2 py-1.5", children: [attachButton ??
|
|
1750
|
+
(plusMenuMode === "hidden" ? null : (_jsx(ComposerPlusMenu, { onSelectMode: handleSelectMode, mode: plusMenuMode, onAttachmentError: onAttachmentError }))), toolbarSlot ?? modeControl, _jsx("div", { "data-agent-composer-slot": "toolbar-spacer", className: "flex-1" }), selectedModel && availableModels && onModelChange && (_jsx(ModelSelector, { model: selectedModel, effort: selectedEffort, engines: availableModels, onChange: onModelChange, onEffortChange: onEffortChange, providerConnectStatusEnabled: providerConnectStatusEnabled, onConnectProvider: onConnectProvider, imageModel: imageModelMenu })), execMode && onExecModeChange && (_jsx(ModeSelector, { mode: execMode, onChange: onExecModeChange, planModeDisabled: planModeDisabled, planModeDisabledReason: planModeDisabledReason })), actionButton ?? (_jsxs(_Fragment, { children: [extraActionButton, voiceEnabled && (_jsx(VoiceButton, { voice: voice, isMac: isMac, disabled: disabled })), primaryAction === "stop" ? (stopButton) : (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: () => void submitComposer("immediate"), disabled: !canSend, "data-agent-composer-slot": "send-button", className: "agent-composer-send-button shrink-0 flex h-7 w-7 items-center justify-center rounded-md bg-primary text-primary-foreground hover:opacity-90 disabled:opacity-30 disabled:cursor-not-allowed", children: _jsx(IconArrowUp, { className: "h-3.5 w-3.5" }) }) }), _jsx(TooltipContent, { children: "Send message" })] }))] }))] }), _jsx(MentionPopover, { ref: popoverRef, type: popover?.type ?? "@", position: popover?.position ?? null, mentionItems: filteredMentionItems, skills: filteredSkills, commands: filteredCommands, hint: hint, isLoading: popover?.type === "@" ? mentionsLoading : skillsLoading, query: popover?.query ?? "", onSelectMention: handleSelectMention, onSelectSkill: handleSelectSkill, onSelectCommand: handleSelectCommand, onClose: closePopover })] }));
|
|
1660
1751
|
}
|
|
1661
1752
|
//# sourceMappingURL=TiptapComposer.js.map
|