@agent-native/core 0.111.4 → 0.113.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 +4 -2
- package/corpus/core/CHANGELOG.md +34 -0
- package/corpus/core/docs/AGENTS.md +7 -0
- package/corpus/core/docs/content/integrations.mdx +63 -2
- package/corpus/core/docs/design/provider-integration-authority.md +117 -0
- package/corpus/core/package.json +8 -1
- package/corpus/core/scripts/materialize-source-corpus.mjs +9 -2
- package/corpus/core/src/cli/atomic-json-file.ts +324 -0
- package/corpus/core/src/cli/claude-code-participant.ts +515 -0
- package/corpus/core/src/cli/code-agent-executor.ts +35 -15
- package/corpus/core/src/cli/code-agent-runs.concurrent-worker.ts +33 -0
- package/corpus/core/src/cli/code-agent-runs.ts +70 -36
- package/corpus/core/src/cli/codex-cli-participant.ts +496 -0
- package/corpus/core/src/cli/multi-frontier-runs.ts +1952 -0
- package/corpus/core/src/client/chat/ChatHistoryList.tsx +7 -404
- package/corpus/core/src/coding-tools/index.ts +27 -8
- package/corpus/core/src/embeddings/index.ts +233 -0
- package/corpus/core/src/index.ts +2 -0
- package/corpus/core/src/integrations/index.ts +10 -0
- package/corpus/core/src/integrations/slack-oauth.ts +1 -0
- package/corpus/core/src/integrations/webhook-delivery.ts +55 -0
- package/corpus/core/src/notifications/channels.ts +4 -10
- package/corpus/core/src/provider-api/actions/custom-provider-registration.ts +197 -0
- package/corpus/core/src/provider-api/actions/delete-staged-dataset.ts +3 -42
- package/corpus/core/src/provider-api/actions/list-staged-datasets.ts +3 -45
- package/corpus/core/src/provider-api/actions/provider-api-audit.ts +88 -0
- package/corpus/core/src/provider-api/actions/provider-api.ts +460 -0
- package/corpus/core/src/provider-api/actions/query-staged-dataset.ts +3 -140
- package/corpus/core/src/provider-api/actions/staged-datasets.ts +359 -0
- package/corpus/core/src/provider-api/gong.ts +108 -0
- package/corpus/core/src/scripts/docs/source-search.ts +2 -1
- package/corpus/core/src/search/index.ts +413 -0
- package/corpus/core/src/server/google-oauth-credentials.ts +80 -3
- package/corpus/core/src/server/index.ts +6 -0
- package/corpus/core/src/styles/chat-history-list.css +1 -313
- package/corpus/core/src/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/core/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/core/src/templates/default/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/core/src/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/corpus/core/src/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/corpus/core/src/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/corpus/core/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/core/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/default/AGENTS.md +25 -18
- package/corpus/core/src/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/corpus/core/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/core/src/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/core/src/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/corpus/core/src/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/corpus/core/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/headless/AGENTS.md +7 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/workspace-core/AGENTS.md +4 -0
- package/corpus/core/src/templates/workspace-root/AGENTS.md +4 -0
- package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/analytics/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/analytics/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/analytics/actions/delete-staged-dataset.ts +3 -23
- package/corpus/templates/analytics/actions/list-staged-datasets.ts +3 -27
- package/corpus/templates/analytics/actions/provider-api-catalog.ts +16 -19
- package/corpus/templates/analytics/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/analytics/actions/provider-api-request.ts +162 -185
- package/corpus/templates/analytics/actions/query-staged-dataset.ts +3 -47
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +52 -161
- package/corpus/templates/assets/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/assets/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/assets/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +63 -160
- package/corpus/templates/brain/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/brain/.agents/skills/brain/RUNBOOK.md +48 -5
- package/corpus/templates/brain/.agents/skills/brain/SKILL.md +46 -14
- package/corpus/templates/brain/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/brain/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/brain/README.md +34 -3
- package/corpus/templates/brain/actions/_schemas.ts +13 -7
- package/corpus/templates/brain/actions/approve-proposal.ts +2 -0
- package/corpus/templates/brain/actions/claim-distillation.ts +24 -27
- package/corpus/templates/brain/actions/create-source.ts +1 -1
- package/corpus/templates/brain/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/brain/actions/get-knowledge.ts +6 -2
- package/corpus/templates/brain/actions/get-pilot-report.ts +44 -8
- package/corpus/templates/brain/actions/import-capture.ts +21 -9
- package/corpus/templates/brain/actions/import-transcript.ts +42 -14
- package/corpus/templates/brain/actions/list-captures.ts +10 -1
- package/corpus/templates/brain/actions/list-distillation-queue.ts +39 -14
- package/corpus/templates/brain/actions/list-projects.ts +51 -0
- package/corpus/templates/brain/actions/list-proposals.ts +80 -4
- package/corpus/templates/brain/actions/list-sources.ts +17 -3
- package/corpus/templates/brain/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/brain/actions/manage-project.ts +118 -0
- package/corpus/templates/brain/actions/mark-capture-distilled.ts +68 -20
- package/corpus/templates/brain/actions/navigate.ts +1 -0
- package/corpus/templates/brain/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/brain/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/brain/actions/provider-api-request.ts +3 -37
- package/corpus/templates/brain/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/brain/actions/reject-proposal.ts +6 -1
- package/corpus/templates/brain/actions/resanitize-captures.ts +159 -33
- package/corpus/templates/brain/actions/review-proposal.ts +2 -0
- package/corpus/templates/brain/actions/search-everything.ts +10 -1
- package/corpus/templates/brain/actions/search-knowledge.ts +1 -1
- package/corpus/templates/brain/actions/set-settings.ts +36 -1
- package/corpus/templates/brain/actions/update-proposal.ts +2 -0
- package/corpus/templates/brain/actions/update-source.ts +5 -1
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +48 -154
- package/corpus/templates/brain/app/hooks/use-distillation-bridge.ts +18 -9
- package/corpus/templates/brain/app/hooks/use-navigation-state.ts +3 -0
- package/corpus/templates/brain/app/i18n-data.ts +731 -2
- package/corpus/templates/brain/app/lib/brain.ts +88 -1
- package/corpus/templates/brain/app/lib/ingest-handoff.ts +35 -0
- package/corpus/templates/brain/app/routes/ops.tsx +47 -0
- package/corpus/templates/brain/app/routes/review.tsx +41 -2
- package/corpus/templates/brain/app/routes/search.tsx +33 -2
- package/corpus/templates/brain/app/routes/settings.tsx +158 -0
- package/corpus/templates/brain/app/routes/sources.tsx +31 -0
- package/corpus/templates/brain/changelog/2026-07-19-added-private-source-safe-semantic-search.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-can-now-join-configured-public-channels-befo.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-now-continue-across-the-configured-number-of.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-now-start-with-a-safe-four-week-window-and-r.md +6 -0
- package/corpus/templates/brain/jobs/process-ingest-queue.ts +270 -36
- package/corpus/templates/brain/package.json +1 -0
- package/corpus/templates/brain/server/db/index.ts +18 -0
- package/corpus/templates/brain/server/db/schema.ts +197 -1
- package/corpus/templates/brain/server/jobs/distillation-queue.ts +12 -5
- package/corpus/templates/brain/server/lib/audiences.ts +708 -0
- package/corpus/templates/brain/server/lib/brain-health.ts +251 -38
- package/corpus/templates/brain/server/lib/brain.ts +877 -50
- package/corpus/templates/brain/server/lib/capture-sanitization.ts +217 -53
- package/corpus/templates/brain/server/lib/connectors.ts +609 -72
- package/corpus/templates/brain/server/lib/demo.ts +17 -4
- package/corpus/templates/brain/server/lib/hybrid-search.ts +363 -0
- package/corpus/templates/brain/server/lib/ingest-queue.ts +104 -0
- package/corpus/templates/brain/server/lib/privacy-readiness.ts +24 -0
- package/corpus/templates/brain/server/lib/search-index-contracts.ts +72 -0
- package/corpus/templates/brain/server/lib/search-index.ts +714 -0
- package/corpus/templates/brain/server/lib/search.ts +120 -4
- package/corpus/templates/brain/server/lib/sensitivity-policy.ts +174 -0
- package/corpus/templates/brain/server/lib/slack-channel-membership.ts +44 -0
- package/corpus/templates/brain/server/lib/slack-events.ts +281 -0
- package/corpus/templates/brain/server/onboarding.ts +29 -0
- package/corpus/templates/brain/server/plugins/db.ts +204 -0
- package/corpus/templates/brain/server/register-secrets.ts +46 -0
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +36 -16
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/slack-events.post.ts +28 -0
- package/corpus/templates/brain/shared/slack-source-config.ts +60 -0
- package/corpus/templates/brain/shared/types.ts +10 -0
- package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/calendar/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/calendar/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/calendar/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/calendar/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/calendar/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/calendar/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/calendar/actions/provider-api-request.ts +3 -37
- package/corpus/templates/calendar/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/calendar/server/handlers/gong.ts +6 -61
- package/corpus/templates/calendar/server/handlers/google-auth.ts +10 -8
- package/corpus/templates/calendar/server/lib/google-calendar.ts +7 -45
- package/corpus/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/chat/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/chat/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/chat/AGENTS.md +5 -2
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/corpus/templates/clips/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/clips/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/clips/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/clips/AGENTS.md +11 -0
- package/corpus/templates/clips/actions/export-to-brain.ts +505 -171
- package/corpus/templates/clips/changelog/2026-07-19-ready-clips-transcripts-can-be-backfilled-to-brain-for-a-bou.md +6 -0
- package/corpus/templates/clips/server/lib/calendar-event-meetings.ts +1 -1
- package/corpus/templates/clips/server/lib/google-calendar-client.ts +12 -22
- package/corpus/templates/clips/server/lib/google-calendar-oauth.ts +9 -6
- package/corpus/templates/clips/server/lib/slack-oauth.ts +12 -47
- package/corpus/templates/clips/server/routes/_agent-native/google/auth-url.get.ts +2 -6
- package/corpus/templates/clips/server/routes/api/auth/google-calendar.get.ts +4 -4
- package/corpus/templates/content/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/content/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/content/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/content/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/content/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/content/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/content/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/content/actions/provider-api-request.ts +3 -37
- package/corpus/templates/content/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/design/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/design/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/design/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/design/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/design/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/design/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/design/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/design/actions/provider-api-request.ts +140 -164
- package/corpus/templates/design/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/dispatch/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/dispatch/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/dispatch/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/dispatch/actions/list-staged-datasets.ts +4 -30
- package/corpus/templates/dispatch/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/dispatch/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/dispatch/actions/provider-api-request.ts +138 -163
- package/corpus/templates/dispatch/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/forms/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/forms/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/forms/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/forms/server/lib/integrations.ts +23 -22
- package/corpus/templates/macros/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/mail/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/mail/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/mail/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/mail/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/mail/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/mail/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/mail/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/mail/actions/provider-api-request.ts +146 -173
- package/corpus/templates/mail/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/mail/server/handlers/gong.ts +6 -61
- package/corpus/templates/mail/server/lib/google-auth.ts +10 -13
- package/corpus/templates/plan/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/plan/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/plan/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +47 -156
- package/corpus/templates/slides/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/slides/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/slides/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/slides/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/slides/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/slides/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/slides/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/slides/actions/provider-api-request.ts +145 -172
- package/corpus/templates/slides/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/slides/server/lib/google-docs-oauth.ts +11 -36
- package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/templates/tasks/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/tasks/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/toolkit/CHANGELOG.md +125 -0
- package/corpus/toolkit/README.md +60 -0
- package/corpus/toolkit/export-snapshot.json +35 -0
- package/corpus/toolkit/migration-manifest.json +4 -0
- package/corpus/toolkit/package.json +281 -0
- package/corpus/toolkit/scripts/finalize-build.mjs +55 -0
- package/corpus/toolkit/src/app-shell/header-actions.tsx +84 -0
- package/corpus/toolkit/src/app-shell/index.ts +1 -0
- package/corpus/toolkit/src/chat-history/ChatHistoryList.tsx +469 -0
- package/corpus/toolkit/src/chat-history/index.ts +7 -0
- package/corpus/toolkit/src/chat-history.css +314 -0
- package/corpus/toolkit/src/collab-ui/AgentPresenceChip.tsx +69 -0
- package/corpus/toolkit/src/collab-ui/LiveCursorOverlay.tsx +241 -0
- package/corpus/toolkit/src/collab-ui/PresenceBar.tsx +346 -0
- package/corpus/toolkit/src/collab-ui/RecentEditHighlights.tsx +225 -0
- package/corpus/toolkit/src/collab-ui/RemoteSelectionRings.tsx +227 -0
- package/corpus/toolkit/src/collab-ui/agent-identity.ts +16 -0
- package/corpus/toolkit/src/collab-ui/index.ts +39 -0
- package/corpus/toolkit/src/collab-ui/lead-client.ts +32 -0
- package/corpus/toolkit/src/collab-ui/types.ts +96 -0
- package/corpus/toolkit/src/composer/AgentComposerFrame.tsx +59 -0
- package/corpus/toolkit/src/composer/ComposerPlusMenu.tsx +983 -0
- package/corpus/toolkit/src/composer/MentionPopover.tsx +412 -0
- package/corpus/toolkit/src/composer/PastedTextChip.tsx +150 -0
- package/corpus/toolkit/src/composer/PromptComposer.tsx +718 -0
- package/corpus/toolkit/src/composer/RealtimeVoiceMode.tsx +856 -0
- package/corpus/toolkit/src/composer/TiptapComposer.tsx +2936 -0
- package/corpus/toolkit/src/composer/VoiceButton.tsx +255 -0
- package/corpus/toolkit/src/composer/asset-picker-url.ts +80 -0
- package/corpus/toolkit/src/composer/attachment-accept.ts +71 -0
- package/corpus/toolkit/src/composer/draft-key.ts +7 -0
- package/corpus/toolkit/src/composer/extensions/FileReference.tsx +55 -0
- package/corpus/toolkit/src/composer/extensions/MentionReference.tsx +93 -0
- package/corpus/toolkit/src/composer/extensions/SkillReference.tsx +56 -0
- package/corpus/toolkit/src/composer/index.ts +79 -0
- package/corpus/toolkit/src/composer/pasted-text.ts +160 -0
- package/corpus/toolkit/src/composer/prompt-attachments.ts +93 -0
- package/corpus/toolkit/src/composer/realtime-voice-audio-level.ts +64 -0
- package/corpus/toolkit/src/composer/realtime-voice-transcript.ts +134 -0
- package/corpus/toolkit/src/composer/runtime-adapters.tsx +343 -0
- package/corpus/toolkit/src/composer/types.ts +66 -0
- package/corpus/toolkit/src/composer/use-file-search.ts +64 -0
- package/corpus/toolkit/src/composer/use-mention-search.ts +90 -0
- package/corpus/toolkit/src/composer/use-skills.ts +45 -0
- package/corpus/toolkit/src/composer/useRealtimeVoiceMode.tsx +2117 -0
- package/corpus/toolkit/src/composer/useVoiceDictation.ts +1191 -0
- package/corpus/toolkit/src/context-ui/ContextMeter.tsx +101 -0
- package/corpus/toolkit/src/context-ui/ContextSegmentRow.tsx +184 -0
- package/corpus/toolkit/src/context-ui/ContextTreemap.tsx +125 -0
- package/corpus/toolkit/src/context-ui/ContextXRayPanel.tsx +377 -0
- package/corpus/toolkit/src/context-ui/format.ts +42 -0
- package/corpus/toolkit/src/context-ui/index.ts +15 -0
- package/corpus/toolkit/src/context-ui/types.ts +43 -0
- package/corpus/toolkit/src/design-tweaks/index.ts +1 -0
- package/corpus/toolkit/src/design-tweaks/visual-style-controls.tsx +1084 -0
- package/corpus/toolkit/src/editor/BubbleToolbar.tsx +253 -0
- package/corpus/toolkit/src/editor/CodeBlockNode.tsx +254 -0
- package/corpus/toolkit/src/editor/DragHandle.ts +1437 -0
- package/corpus/toolkit/src/editor/ImageExtension.ts +306 -0
- package/corpus/toolkit/src/editor/RegistryBlockContext.tsx +107 -0
- package/corpus/toolkit/src/editor/RegistryBlockNode.tsx +652 -0
- package/corpus/toolkit/src/editor/RichMarkdownEditor.tsx +81 -0
- package/corpus/toolkit/src/editor/RunId.ts +61 -0
- package/corpus/toolkit/src/editor/SharedRichEditor.tsx +321 -0
- package/corpus/toolkit/src/editor/SlashCommandMenu.tsx +310 -0
- package/corpus/toolkit/src/editor/extensions.ts +402 -0
- package/corpus/toolkit/src/editor/gfmDoc.ts +92 -0
- package/corpus/toolkit/src/editor/index.ts +93 -0
- package/corpus/toolkit/src/editor/registrySlashCommands.ts +131 -0
- package/corpus/toolkit/src/editor/surgical-apply.ts +192 -0
- package/corpus/toolkit/src/editor/useCollabReconcile.ts +589 -0
- package/corpus/toolkit/src/editor.css +510 -0
- package/corpus/toolkit/src/hooks/index.ts +2 -0
- package/corpus/toolkit/src/hooks/use-mobile.tsx +21 -0
- package/corpus/toolkit/src/hooks/use-toast.ts +188 -0
- package/corpus/toolkit/src/index.ts +8 -0
- package/corpus/toolkit/src/onboarding/index.ts +1 -0
- package/corpus/toolkit/src/provider.tsx +47 -0
- package/corpus/toolkit/src/sharing/VisibilityBadge.tsx +37 -0
- package/corpus/toolkit/src/sharing/index.ts +4 -0
- package/corpus/toolkit/src/styles.css +21 -0
- package/corpus/toolkit/src/ui/accordion.tsx +56 -0
- package/corpus/toolkit/src/ui/alert-dialog.tsx +141 -0
- package/corpus/toolkit/src/ui/alert.tsx +59 -0
- package/corpus/toolkit/src/ui/aspect-ratio.tsx +5 -0
- package/corpus/toolkit/src/ui/avatar.tsx +48 -0
- package/corpus/toolkit/src/ui/badge.tsx +37 -0
- package/corpus/toolkit/src/ui/breadcrumb.tsx +115 -0
- package/corpus/toolkit/src/ui/button.tsx +78 -0
- package/corpus/toolkit/src/ui/calendar.tsx +214 -0
- package/corpus/toolkit/src/ui/card.tsx +86 -0
- package/corpus/toolkit/src/ui/carousel.tsx +260 -0
- package/corpus/toolkit/src/ui/chart.tsx +375 -0
- package/corpus/toolkit/src/ui/checkbox.tsx +28 -0
- package/corpus/toolkit/src/ui/collapsible.tsx +9 -0
- package/corpus/toolkit/src/ui/command.tsx +174 -0
- package/corpus/toolkit/src/ui/context-menu.tsx +202 -0
- package/corpus/toolkit/src/ui/date-picker.tsx +64 -0
- package/corpus/toolkit/src/ui/dialog.tsx +146 -0
- package/corpus/toolkit/src/ui/drawer.tsx +126 -0
- package/corpus/toolkit/src/ui/dropdown-menu.tsx +218 -0
- package/corpus/toolkit/src/ui/form.tsx +177 -0
- package/corpus/toolkit/src/ui/hover-card.tsx +27 -0
- package/corpus/toolkit/src/ui/index.ts +52 -0
- package/corpus/toolkit/src/ui/input-otp.tsx +69 -0
- package/corpus/toolkit/src/ui/input.tsx +22 -0
- package/corpus/toolkit/src/ui/label.tsx +24 -0
- package/corpus/toolkit/src/ui/logo.tsx +36 -0
- package/corpus/toolkit/src/ui/menubar.tsx +235 -0
- package/corpus/toolkit/src/ui/navigation-menu.tsx +128 -0
- package/corpus/toolkit/src/ui/pagination.tsx +121 -0
- package/corpus/toolkit/src/ui/popover.tsx +44 -0
- package/corpus/toolkit/src/ui/progress.tsx +26 -0
- package/corpus/toolkit/src/ui/radio-group.tsx +42 -0
- package/corpus/toolkit/src/ui/resizable.tsx +43 -0
- package/corpus/toolkit/src/ui/scroll-area.tsx +46 -0
- package/corpus/toolkit/src/ui/select.tsx +158 -0
- package/corpus/toolkit/src/ui/separator.tsx +29 -0
- package/corpus/toolkit/src/ui/sheet.tsx +160 -0
- package/corpus/toolkit/src/ui/sidebar.tsx +777 -0
- package/corpus/toolkit/src/ui/skeleton.tsx +18 -0
- package/corpus/toolkit/src/ui/slider.tsx +26 -0
- package/corpus/toolkit/src/ui/sonner.tsx +58 -0
- package/corpus/toolkit/src/ui/spinner.tsx +17 -0
- package/corpus/toolkit/src/ui/switch.tsx +27 -0
- package/corpus/toolkit/src/ui/table.tsx +117 -0
- package/corpus/toolkit/src/ui/tabs.tsx +53 -0
- package/corpus/toolkit/src/ui/textarea.tsx +23 -0
- package/corpus/toolkit/src/ui/toast.tsx +127 -0
- package/corpus/toolkit/src/ui/toaster.tsx +33 -0
- package/corpus/toolkit/src/ui/toggle-group.tsx +59 -0
- package/corpus/toolkit/src/ui/toggle.tsx +43 -0
- package/corpus/toolkit/src/ui/tooltip.tsx +53 -0
- package/corpus/toolkit/src/ui/use-toast.ts +3 -0
- package/corpus/toolkit/src/utils.ts +8 -0
- package/corpus/toolkit/tsconfig.json +23 -0
- package/dist/cli/atomic-json-file.d.ts +30 -0
- package/dist/cli/atomic-json-file.d.ts.map +1 -0
- package/dist/cli/atomic-json-file.js +240 -0
- package/dist/cli/atomic-json-file.js.map +1 -0
- package/dist/cli/claude-code-participant.d.ts +77 -0
- package/dist/cli/claude-code-participant.d.ts.map +1 -0
- package/dist/cli/claude-code-participant.js +355 -0
- package/dist/cli/claude-code-participant.js.map +1 -0
- package/dist/cli/code-agent-executor.d.ts +8 -9
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +27 -13
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/code-agent-runs.concurrent-worker.d.ts +2 -0
- package/dist/cli/code-agent-runs.concurrent-worker.d.ts.map +1 -0
- package/dist/cli/code-agent-runs.concurrent-worker.js +32 -0
- package/dist/cli/code-agent-runs.concurrent-worker.js.map +1 -0
- package/dist/cli/code-agent-runs.d.ts +5 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +51 -33
- package/dist/cli/code-agent-runs.js.map +1 -1
- package/dist/cli/codex-cli-participant.d.ts +77 -0
- package/dist/cli/codex-cli-participant.d.ts.map +1 -0
- package/dist/cli/codex-cli-participant.js +354 -0
- package/dist/cli/codex-cli-participant.js.map +1 -0
- package/dist/cli/multi-frontier-runs.d.ts +246 -0
- package/dist/cli/multi-frontier-runs.d.ts.map +1 -0
- package/dist/cli/multi-frontier-runs.js +1247 -0
- package/dist/cli/multi-frontier-runs.js.map +1 -0
- package/dist/client/chat/ChatHistoryList.d.ts +1 -87
- package/dist/client/chat/ChatHistoryList.d.ts.map +1 -1
- package/dist/client/chat/ChatHistoryList.js +1 -82
- package/dist/client/chat/ChatHistoryList.js.map +1 -1
- package/dist/coding-tools/index.d.ts +1 -0
- package/dist/coding-tools/index.d.ts.map +1 -1
- package/dist/coding-tools/index.js +25 -7
- package/dist/coding-tools/index.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/embeddings/index.d.ts +24 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +172 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations/index.d.ts +2 -1
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +2 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/slack-manifest.d.ts +1 -1
- package/dist/integrations/slack-oauth.d.ts +1 -1
- package/dist/integrations/slack-oauth.d.ts.map +1 -1
- package/dist/integrations/slack-oauth.js +1 -0
- package/dist/integrations/slack-oauth.js.map +1 -1
- package/dist/integrations/webhook-delivery.d.ts +23 -0
- package/dist/integrations/webhook-delivery.d.ts.map +1 -0
- package/dist/integrations/webhook-delivery.js +32 -0
- package/dist/integrations/webhook-delivery.js.map +1 -0
- package/dist/notifications/channels.d.ts.map +1 -1
- package/dist/notifications/channels.js +4 -9
- package/dist/notifications/channels.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +136 -0
- package/dist/provider-api/actions/custom-provider-registration.d.ts.map +1 -0
- package/dist/provider-api/actions/custom-provider-registration.js +154 -0
- package/dist/provider-api/actions/custom-provider-registration.js.map +1 -0
- package/dist/provider-api/actions/delete-staged-dataset.d.ts +1 -1
- package/dist/provider-api/actions/delete-staged-dataset.d.ts.map +1 -1
- package/dist/provider-api/actions/delete-staged-dataset.js +3 -34
- package/dist/provider-api/actions/delete-staged-dataset.js.map +1 -1
- package/dist/provider-api/actions/list-staged-datasets.d.ts +2 -3
- package/dist/provider-api/actions/list-staged-datasets.d.ts.map +1 -1
- package/dist/provider-api/actions/list-staged-datasets.js +3 -40
- package/dist/provider-api/actions/list-staged-datasets.js.map +1 -1
- package/dist/provider-api/actions/provider-api-audit.d.ts +7 -0
- package/dist/provider-api/actions/provider-api-audit.d.ts.map +1 -0
- package/dist/provider-api/actions/provider-api-audit.js +74 -0
- package/dist/provider-api/actions/provider-api-audit.js.map +1 -0
- package/dist/provider-api/actions/provider-api.d.ts +370 -0
- package/dist/provider-api/actions/provider-api.d.ts.map +1 -0
- package/dist/provider-api/actions/provider-api.js +280 -0
- package/dist/provider-api/actions/provider-api.js.map +1 -0
- package/dist/provider-api/actions/query-staged-dataset.d.ts +1 -1
- package/dist/provider-api/actions/query-staged-dataset.d.ts.map +1 -1
- package/dist/provider-api/actions/query-staged-dataset.js +3 -116
- package/dist/provider-api/actions/query-staged-dataset.js.map +1 -1
- package/dist/provider-api/actions/staged-datasets.d.ts +190 -0
- package/dist/provider-api/actions/staged-datasets.d.ts.map +1 -0
- package/dist/provider-api/actions/staged-datasets.js +210 -0
- package/dist/provider-api/actions/staged-datasets.js.map +1 -0
- package/dist/provider-api/gong.d.ts +44 -0
- package/dist/provider-api/gong.d.ts.map +1 -0
- package/dist/provider-api/gong.js +56 -0
- package/dist/provider-api/gong.js.map +1 -0
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/docs/source-search.d.ts +2 -1
- package/dist/scripts/docs/source-search.d.ts.map +1 -1
- package/dist/scripts/docs/source-search.js +2 -1
- package/dist/scripts/docs/source-search.js.map +1 -1
- package/dist/search/index.d.ts +88 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +267 -0
- package/dist/search/index.js.map +1 -0
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/google-oauth-credentials.d.ts +35 -0
- package/dist/server/google-oauth-credentials.d.ts.map +1 -1
- package/dist/server/google-oauth-credentials.js +48 -2
- package/dist/server/google-oauth-credentials.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/styles/chat-history-list.css +1 -313
- package/dist/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/chat/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/chat/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/dist/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/chat/AGENTS.md +5 -2
- package/dist/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/dist/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/default/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/default/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/dist/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/dist/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/default/AGENTS.md +25 -18
- package/dist/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/dist/templates/headless/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/dist/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/headless/AGENTS.md +7 -0
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/dist/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/workspace-core/AGENTS.md +4 -0
- package/dist/templates/workspace-root/AGENTS.md +4 -0
- package/docs/AGENTS.md +7 -0
- package/docs/content/integrations.mdx +63 -2
- package/docs/design/provider-integration-authority.md +117 -0
- package/package.json +9 -2
- package/src/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/chat/AGENTS.md +5 -2
- package/src/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/src/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/default/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/src/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/src/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/default/AGENTS.md +25 -18
- package/src/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/src/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/headless/AGENTS.md +7 -0
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/src/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/workspace-core/AGENTS.md +4 -0
- package/src/templates/workspace-root/AGENTS.md +4 -0
|
@@ -0,0 +1,718 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssistantRuntimeProvider,
|
|
3
|
+
ThreadPrimitive,
|
|
4
|
+
useAui,
|
|
5
|
+
useComposer,
|
|
6
|
+
useLocalRuntime,
|
|
7
|
+
} from "@assistant-ui/react";
|
|
8
|
+
import type {
|
|
9
|
+
Attachment,
|
|
10
|
+
AttachmentAdapter,
|
|
11
|
+
ChatModelAdapter,
|
|
12
|
+
CompleteAttachment,
|
|
13
|
+
PendingAttachment,
|
|
14
|
+
} from "@assistant-ui/react";
|
|
15
|
+
import {
|
|
16
|
+
CompositeAttachmentAdapter,
|
|
17
|
+
SimpleImageAttachmentAdapter,
|
|
18
|
+
} from "@assistant-ui/react";
|
|
19
|
+
import { IconX } from "@tabler/icons-react";
|
|
20
|
+
import {
|
|
21
|
+
useCallback,
|
|
22
|
+
useEffect,
|
|
23
|
+
useMemo,
|
|
24
|
+
useRef,
|
|
25
|
+
useState,
|
|
26
|
+
type CSSProperties,
|
|
27
|
+
type Ref,
|
|
28
|
+
type ReactNode,
|
|
29
|
+
} from "react";
|
|
30
|
+
|
|
31
|
+
import { TooltipProvider } from "../ui/tooltip.js";
|
|
32
|
+
import { cn } from "../utils.js";
|
|
33
|
+
import { AgentComposerFrame } from "./AgentComposerFrame.js";
|
|
34
|
+
import { IMAGE_ATTACHMENT_ACCEPT } from "./attachment-accept.js";
|
|
35
|
+
import {
|
|
36
|
+
PROMPT_DOCUMENT_ATTACHMENT_ACCEPT,
|
|
37
|
+
TextAttachmentAdapter,
|
|
38
|
+
} from "./attachment-accept.js";
|
|
39
|
+
import { isPastedTextAttachmentName } from "./pasted-text.js";
|
|
40
|
+
import { PastedTextChip } from "./PastedTextChip.js";
|
|
41
|
+
import { escapePromptAttachmentAttribute } from "./prompt-attachments.js";
|
|
42
|
+
import {
|
|
43
|
+
type EngineModelGroup,
|
|
44
|
+
type ReasoningEffort,
|
|
45
|
+
useComposerRuntimeAdapters,
|
|
46
|
+
} from "./runtime-adapters.js";
|
|
47
|
+
import {
|
|
48
|
+
DEFAULT_VOICE_DICTATION_ENABLED,
|
|
49
|
+
TiptapComposer,
|
|
50
|
+
type ComposerSubmitIntent,
|
|
51
|
+
type TiptapComposerHandle,
|
|
52
|
+
type TiptapComposerSubmitOptions,
|
|
53
|
+
} from "./TiptapComposer.js";
|
|
54
|
+
import type {
|
|
55
|
+
AgentComposerLayoutVariant,
|
|
56
|
+
Reference,
|
|
57
|
+
SkillResult,
|
|
58
|
+
SlashCommand,
|
|
59
|
+
} from "./types.js";
|
|
60
|
+
|
|
61
|
+
const MAX_INLINE_TEXT_FILE_CHARS = 60_000;
|
|
62
|
+
const SUBMIT_ENGINE_STATUS_TIMEOUT_MS = 1000;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Files the user attached via the "+" button in PromptComposer. The host owns
|
|
66
|
+
* what to do with them — typically POST to a per-app upload endpoint and pass
|
|
67
|
+
* the resulting URLs/paths into the prompt that gets sent to the agent.
|
|
68
|
+
*/
|
|
69
|
+
export type PromptComposerFile = File;
|
|
70
|
+
|
|
71
|
+
export interface PromptComposerSubmitOptions {
|
|
72
|
+
intent?: ComposerSubmitIntent;
|
|
73
|
+
model?: string;
|
|
74
|
+
engine?: string;
|
|
75
|
+
effort?: ReasoningEffort;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface PromptComposerProps {
|
|
79
|
+
/** Called when the user submits the composer. */
|
|
80
|
+
onSubmit: (
|
|
81
|
+
text: string,
|
|
82
|
+
files: PromptComposerFile[],
|
|
83
|
+
references: Reference[],
|
|
84
|
+
options: PromptComposerSubmitOptions,
|
|
85
|
+
) => void;
|
|
86
|
+
placeholder?: string;
|
|
87
|
+
disabled?: boolean;
|
|
88
|
+
autoFocus?: boolean;
|
|
89
|
+
className?: string;
|
|
90
|
+
style?: CSSProperties;
|
|
91
|
+
rootClassName?: string;
|
|
92
|
+
rootStyle?: CSSProperties;
|
|
93
|
+
/** Forwarded to TiptapComposer for draft persistence. */
|
|
94
|
+
draftScope?: string;
|
|
95
|
+
/** Keep the submitted prompt in the editor. Default: false. */
|
|
96
|
+
preserveDraftOnSubmit?: boolean;
|
|
97
|
+
/** Show the model selector (default: true). */
|
|
98
|
+
showModelSelector?: boolean;
|
|
99
|
+
/** Show the voice dictation button. Defaults to DEFAULT_VOICE_DICTATION_ENABLED. */
|
|
100
|
+
voiceEnabled?: boolean;
|
|
101
|
+
/** Show file upload controls and pass submitted files to onSubmit (default: true). */
|
|
102
|
+
attachmentsEnabled?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Controls the shared "+" affordance. Defaults to upload-only for standalone
|
|
105
|
+
* prompt forms; chat surfaces can opt into the full sidebar menu.
|
|
106
|
+
*/
|
|
107
|
+
plusMenuMode?: "full" | "upload-only" | "hidden";
|
|
108
|
+
/** Programmatically seed the composer with plain text. */
|
|
109
|
+
initialText?: string;
|
|
110
|
+
/** Stable key used to re-apply `initialText` when the host picks a preset. */
|
|
111
|
+
initialTextKey?: string | number;
|
|
112
|
+
/** Optional host-owned control rendered directly after the "+" button. */
|
|
113
|
+
modeControl?: ReactNode;
|
|
114
|
+
/** Explicit host-owned toolbar slot rendered directly after the "+" button. */
|
|
115
|
+
toolbarSlot?: ReactNode;
|
|
116
|
+
/** Custom attachment button to render instead of the default "+" affordance. */
|
|
117
|
+
attachButton?: ReactNode;
|
|
118
|
+
/** Custom action button to render instead of the default send button. */
|
|
119
|
+
actionButton?: ReactNode;
|
|
120
|
+
/** Extra button rendered alongside the default send button. */
|
|
121
|
+
extraActionButton?: ReactNode;
|
|
122
|
+
/** Shared sizing/layout variant for host surfaces. Default keeps sidebar behavior. */
|
|
123
|
+
layoutVariant?: AgentComposerLayoutVariant;
|
|
124
|
+
/** Additional slash commands surfaced in the shared / menu. */
|
|
125
|
+
slashCommands?: SlashCommand[];
|
|
126
|
+
/** Additional slash skills surfaced in the shared / menu. */
|
|
127
|
+
slashSkills?: SkillResult[];
|
|
128
|
+
/** Include built-in sidebar slash commands like /clear and /help. Default true. */
|
|
129
|
+
includeDefaultSlashCommands?: boolean;
|
|
130
|
+
/** Include app-discovered skills from the default agent endpoint. Default true. */
|
|
131
|
+
includeDefaultSlashSkills?: boolean;
|
|
132
|
+
/** Called when a slash command from the shared / menu is executed. */
|
|
133
|
+
onSlashCommand?: (command: string) => void;
|
|
134
|
+
/** External model list for hosts that already resolve models outside the app. */
|
|
135
|
+
availableModels?: EngineModelGroup[];
|
|
136
|
+
/** Whether the external model list is still being resolved. */
|
|
137
|
+
modelListLoading?: boolean;
|
|
138
|
+
selectedModel?: string;
|
|
139
|
+
selectedEngine?: string;
|
|
140
|
+
selectedEffort?: ReasoningEffort;
|
|
141
|
+
onModelChange?: (model: string, engine: string) => void;
|
|
142
|
+
onEffortChange?: (effort: ReasoningEffort) => void;
|
|
143
|
+
/**
|
|
144
|
+
* Enable server-backed model/provider status checks. Defaults off when the
|
|
145
|
+
* host supplies model state and callbacks, otherwise on.
|
|
146
|
+
*/
|
|
147
|
+
modelStatusChecksEnabled?: boolean;
|
|
148
|
+
/** Called whenever the plain editor text changes. */
|
|
149
|
+
onTextChange?: (text: string) => void;
|
|
150
|
+
/**
|
|
151
|
+
* Override the Builder.io connect action in the model picker. When provided,
|
|
152
|
+
* clicking "Connect Builder.io" calls this instead of opening a browser popup.
|
|
153
|
+
* Used by the Electron desktop app to route through the native IPC handler.
|
|
154
|
+
*/
|
|
155
|
+
onConnectProvider?: () => void;
|
|
156
|
+
/** Called when a local runtime needs its native sign-in/setup flow. */
|
|
157
|
+
onConnectLocalRuntime?: (engine: string) => void;
|
|
158
|
+
/** Imperative handle for focusing the composer. */
|
|
159
|
+
composerRef?: Ref<TiptapComposerHandle>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Minimal pass-through adapter. PromptComposer always submits through
|
|
163
|
+
// onSubmitOverride, so the runtime never actually calls this — but
|
|
164
|
+
// `useLocalRuntime` needs *something* shaped like a ChatModelAdapter.
|
|
165
|
+
const NOOP_ADAPTER: ChatModelAdapter = {
|
|
166
|
+
async *run() {
|
|
167
|
+
return;
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Local binary document adapter so reference PDFs, decks, and docs can be
|
|
173
|
+
* attached without dragging the whole assistant chat module into bundles that
|
|
174
|
+
* just want a prompt popover.
|
|
175
|
+
*/
|
|
176
|
+
class BinaryDocumentAttachmentAdapter implements AttachmentAdapter {
|
|
177
|
+
public accept = PROMPT_DOCUMENT_ATTACHMENT_ACCEPT;
|
|
178
|
+
|
|
179
|
+
public async add(state: { file: File }): Promise<PendingAttachment> {
|
|
180
|
+
return {
|
|
181
|
+
id: state.file.name,
|
|
182
|
+
type: "document",
|
|
183
|
+
name: state.file.name,
|
|
184
|
+
contentType: state.file.type || "application/octet-stream",
|
|
185
|
+
file: state.file,
|
|
186
|
+
status: { type: "requires-action", reason: "composer-send" },
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public async send(
|
|
191
|
+
attachment: PendingAttachment,
|
|
192
|
+
): Promise<CompleteAttachment> {
|
|
193
|
+
return {
|
|
194
|
+
...attachment,
|
|
195
|
+
status: { type: "complete" },
|
|
196
|
+
content: [],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public async remove() {
|
|
201
|
+
/* noop */
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
class RasterImageAttachmentAdapter extends SimpleImageAttachmentAdapter {
|
|
206
|
+
public accept = IMAGE_ATTACHMENT_ACCEPT;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function isInlineableTextFile(file: File): boolean {
|
|
210
|
+
if (file.type.startsWith("text/")) return true;
|
|
211
|
+
if (file.type === "application/json") return true;
|
|
212
|
+
return /\.(txt|md|markdown|csv|json|yaml|yml|html?|css|xml)$/i.test(
|
|
213
|
+
file.name,
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function formatInlineTextFile(name: string, text: string): string {
|
|
218
|
+
const truncated = text.length > MAX_INLINE_TEXT_FILE_CHARS;
|
|
219
|
+
const body = truncated ? text.slice(0, MAX_INLINE_TEXT_FILE_CHARS) : text;
|
|
220
|
+
return [
|
|
221
|
+
`<uploaded-text-file name="${escapePromptAttachmentAttribute(name)}">`,
|
|
222
|
+
body,
|
|
223
|
+
truncated
|
|
224
|
+
? `[Truncated after ${MAX_INLINE_TEXT_FILE_CHARS} characters.]`
|
|
225
|
+
: "",
|
|
226
|
+
"</uploaded-text-file>",
|
|
227
|
+
]
|
|
228
|
+
.filter(Boolean)
|
|
229
|
+
.join("\n");
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export async function buildPromptComposerSubmission(options: {
|
|
233
|
+
text: string;
|
|
234
|
+
attachments?: ReadonlyArray<unknown>;
|
|
235
|
+
}): Promise<{ text: string; files: File[] }> {
|
|
236
|
+
const files: File[] = [];
|
|
237
|
+
const pastedTextBlocks: string[] = [];
|
|
238
|
+
const rawText = options.text;
|
|
239
|
+
|
|
240
|
+
for (const att of options.attachments ?? []) {
|
|
241
|
+
const a = att as Attachment;
|
|
242
|
+
if ("file" in a && a.file instanceof File) {
|
|
243
|
+
const file = a.file;
|
|
244
|
+
if (isPastedTextAttachmentName(file.name)) {
|
|
245
|
+
try {
|
|
246
|
+
pastedTextBlocks.push(await file.text());
|
|
247
|
+
} catch {
|
|
248
|
+
files.push(file);
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
if (isInlineableTextFile(file)) {
|
|
252
|
+
try {
|
|
253
|
+
pastedTextBlocks.push(
|
|
254
|
+
formatInlineTextFile(file.name, await file.text()),
|
|
255
|
+
);
|
|
256
|
+
} catch {
|
|
257
|
+
// Keep the upload path fallback below.
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Note: images are NOT inlined into the prompt text even when small.
|
|
261
|
+
// Inlining a base64 data-URL into a text string consumes an enormous
|
|
262
|
+
// number of tokens (≈ 700 K per MB) and most hosts handle images via
|
|
263
|
+
// proper attachment channels. The `files` array below carries the image
|
|
264
|
+
// for the host to process through a dedicated attachment pipeline.
|
|
265
|
+
files.push(file);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
text: pastedTextBlocks.length
|
|
272
|
+
? [rawText.trim(), ...pastedTextBlocks].filter(Boolean).join("\n\n")
|
|
273
|
+
: rawText,
|
|
274
|
+
files,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function getImageSrc(attachment: Attachment): string | null {
|
|
279
|
+
if (attachment.type !== "image") return null;
|
|
280
|
+
if ("file" in attachment && attachment.file) {
|
|
281
|
+
return URL.createObjectURL(attachment.file);
|
|
282
|
+
}
|
|
283
|
+
const imagePart = attachment.content?.find((part) => part.type === "image");
|
|
284
|
+
return imagePart && "image" in imagePart ? imagePart.image : null;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function ImagePreviewLightbox({
|
|
288
|
+
src,
|
|
289
|
+
alt,
|
|
290
|
+
onClose,
|
|
291
|
+
}: {
|
|
292
|
+
src: string;
|
|
293
|
+
alt: string;
|
|
294
|
+
onClose: () => void;
|
|
295
|
+
}) {
|
|
296
|
+
useEffect(() => {
|
|
297
|
+
const handler = (e: KeyboardEvent) => {
|
|
298
|
+
if (e.key === "Escape") onClose();
|
|
299
|
+
};
|
|
300
|
+
document.addEventListener("keydown", handler);
|
|
301
|
+
document.body.style.overflow = "hidden";
|
|
302
|
+
return () => {
|
|
303
|
+
document.removeEventListener("keydown", handler);
|
|
304
|
+
document.body.style.overflow = "";
|
|
305
|
+
};
|
|
306
|
+
}, [onClose]);
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<div
|
|
310
|
+
role="dialog"
|
|
311
|
+
aria-label="Image preview"
|
|
312
|
+
onClick={onClose}
|
|
313
|
+
className="fixed inset-0 z-[300] flex items-center justify-center bg-black/80 p-6 cursor-zoom-out"
|
|
314
|
+
>
|
|
315
|
+
<img
|
|
316
|
+
src={src}
|
|
317
|
+
alt={alt}
|
|
318
|
+
onClick={(e) => e.stopPropagation()}
|
|
319
|
+
className="max-h-full max-w-full object-contain rounded-md shadow-2xl cursor-default"
|
|
320
|
+
/>
|
|
321
|
+
<button
|
|
322
|
+
type="button"
|
|
323
|
+
onClick={onClose}
|
|
324
|
+
aria-label="Close preview"
|
|
325
|
+
className="absolute end-4 top-4 flex h-8 w-8 cursor-pointer items-center justify-center rounded-full border border-white/30 bg-black/40 text-white hover:bg-black/60"
|
|
326
|
+
>
|
|
327
|
+
<IconX className="h-4 w-4" />
|
|
328
|
+
</button>
|
|
329
|
+
</div>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function AttachmentChip({
|
|
334
|
+
attachment,
|
|
335
|
+
onRemove,
|
|
336
|
+
}: {
|
|
337
|
+
attachment: Attachment;
|
|
338
|
+
onRemove: (id: string) => void;
|
|
339
|
+
}) {
|
|
340
|
+
const src = useMemo(() => getImageSrc(attachment), [attachment]);
|
|
341
|
+
const [previewOpen, setPreviewOpen] = useState(false);
|
|
342
|
+
useEffect(
|
|
343
|
+
() => () => {
|
|
344
|
+
if (src?.startsWith("blob:")) URL.revokeObjectURL(src);
|
|
345
|
+
},
|
|
346
|
+
[src],
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
if (isPastedTextAttachmentName(attachment.name)) {
|
|
350
|
+
return <PastedTextChip attachment={attachment} onRemove={onRemove} />;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (src) {
|
|
354
|
+
return (
|
|
355
|
+
<>
|
|
356
|
+
<button
|
|
357
|
+
type="button"
|
|
358
|
+
onClick={() => setPreviewOpen(true)}
|
|
359
|
+
aria-label={`Preview ${attachment.name}`}
|
|
360
|
+
className="agent-composer-attachment-image group relative flex h-16 min-w-16 max-w-28 cursor-zoom-in items-center justify-center overflow-hidden rounded-lg border border-border/70 bg-muted/50"
|
|
361
|
+
>
|
|
362
|
+
<img
|
|
363
|
+
src={src}
|
|
364
|
+
alt={attachment.name}
|
|
365
|
+
className="max-h-full max-w-full object-contain p-1"
|
|
366
|
+
/>
|
|
367
|
+
<span
|
|
368
|
+
role="button"
|
|
369
|
+
tabIndex={0}
|
|
370
|
+
onClick={(e) => {
|
|
371
|
+
e.stopPropagation();
|
|
372
|
+
onRemove(attachment.id);
|
|
373
|
+
}}
|
|
374
|
+
onKeyDown={(e) => {
|
|
375
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
376
|
+
e.preventDefault();
|
|
377
|
+
e.stopPropagation();
|
|
378
|
+
onRemove(attachment.id);
|
|
379
|
+
}
|
|
380
|
+
}}
|
|
381
|
+
aria-label={`Remove ${attachment.name}`}
|
|
382
|
+
className="absolute end-1 top-1 flex h-5 w-5 cursor-pointer items-center justify-center rounded-full border border-border/60 bg-background/90 text-muted-foreground hover:text-foreground"
|
|
383
|
+
>
|
|
384
|
+
<IconX className="h-3 w-3" />
|
|
385
|
+
</span>
|
|
386
|
+
</button>
|
|
387
|
+
{previewOpen ? (
|
|
388
|
+
<ImagePreviewLightbox
|
|
389
|
+
src={src}
|
|
390
|
+
alt={attachment.name}
|
|
391
|
+
onClose={() => setPreviewOpen(false)}
|
|
392
|
+
/>
|
|
393
|
+
) : null}
|
|
394
|
+
</>
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return (
|
|
399
|
+
<div className="agent-composer-attachment-chip group relative inline-flex max-w-[200px] items-center gap-2 rounded-md border border-border/70 bg-muted/50 px-2 py-1.5 text-xs">
|
|
400
|
+
<div className="flex h-6 w-6 shrink-0 items-center justify-center rounded bg-background text-[9px] font-semibold uppercase text-muted-foreground">
|
|
401
|
+
{attachment.name.split(".").pop() || "file"}
|
|
402
|
+
</div>
|
|
403
|
+
<span className="min-w-0 truncate font-medium">{attachment.name}</span>
|
|
404
|
+
<button
|
|
405
|
+
type="button"
|
|
406
|
+
onClick={() => onRemove(attachment.id)}
|
|
407
|
+
aria-label={`Remove ${attachment.name}`}
|
|
408
|
+
className="flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded text-muted-foreground hover:text-foreground"
|
|
409
|
+
>
|
|
410
|
+
<IconX className="h-3 w-3" />
|
|
411
|
+
</button>
|
|
412
|
+
</div>
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function PromptAttachmentStrip() {
|
|
417
|
+
const attachments = useComposer((state) => state.attachments);
|
|
418
|
+
const aui = useAui();
|
|
419
|
+
|
|
420
|
+
const handleRemove = useCallback(
|
|
421
|
+
(id: string) => {
|
|
422
|
+
void aui.composer().attachment({ id }).remove();
|
|
423
|
+
},
|
|
424
|
+
[aui],
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
if (attachments.length === 0) return null;
|
|
428
|
+
return (
|
|
429
|
+
<div className="agent-composer-attachment-strip flex flex-wrap gap-2 px-2 pt-2">
|
|
430
|
+
{attachments.map((attachment) => (
|
|
431
|
+
<AttachmentChip
|
|
432
|
+
key={attachment.id}
|
|
433
|
+
attachment={attachment}
|
|
434
|
+
onRemove={handleRemove}
|
|
435
|
+
/>
|
|
436
|
+
))}
|
|
437
|
+
</div>
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function PromptComposerInner({
|
|
442
|
+
onSubmit,
|
|
443
|
+
placeholder,
|
|
444
|
+
disabled,
|
|
445
|
+
autoFocus,
|
|
446
|
+
className,
|
|
447
|
+
style,
|
|
448
|
+
rootClassName,
|
|
449
|
+
rootStyle,
|
|
450
|
+
draftScope,
|
|
451
|
+
preserveDraftOnSubmit = false,
|
|
452
|
+
showModelSelector = true,
|
|
453
|
+
voiceEnabled = DEFAULT_VOICE_DICTATION_ENABLED,
|
|
454
|
+
attachmentsEnabled = true,
|
|
455
|
+
plusMenuMode,
|
|
456
|
+
initialText,
|
|
457
|
+
initialTextKey,
|
|
458
|
+
modeControl,
|
|
459
|
+
toolbarSlot,
|
|
460
|
+
attachButton,
|
|
461
|
+
actionButton,
|
|
462
|
+
extraActionButton,
|
|
463
|
+
layoutVariant,
|
|
464
|
+
slashCommands,
|
|
465
|
+
slashSkills,
|
|
466
|
+
includeDefaultSlashCommands,
|
|
467
|
+
includeDefaultSlashSkills,
|
|
468
|
+
onSlashCommand,
|
|
469
|
+
availableModels,
|
|
470
|
+
modelListLoading,
|
|
471
|
+
selectedModel,
|
|
472
|
+
selectedEngine,
|
|
473
|
+
selectedEffort,
|
|
474
|
+
onModelChange,
|
|
475
|
+
onEffortChange,
|
|
476
|
+
modelStatusChecksEnabled,
|
|
477
|
+
onTextChange,
|
|
478
|
+
onConnectProvider,
|
|
479
|
+
onConnectLocalRuntime,
|
|
480
|
+
composerRef,
|
|
481
|
+
}: PromptComposerProps) {
|
|
482
|
+
const adapters = useComposerRuntimeAdapters();
|
|
483
|
+
const modelsAdapter = adapters.models!;
|
|
484
|
+
const BuilderSetupCard = modelsAdapter.BuilderSetupCard;
|
|
485
|
+
const BuilderSetupContent = modelsAdapter.BuilderSetupContent;
|
|
486
|
+
const localRef = useRef<TiptapComposerHandle>(null);
|
|
487
|
+
const handleRef = composerRef ?? localRef;
|
|
488
|
+
const hostManagedModels = Boolean(
|
|
489
|
+
availableModels && selectedModel && onModelChange,
|
|
490
|
+
);
|
|
491
|
+
const resolvedModelStatusChecksEnabled =
|
|
492
|
+
modelStatusChecksEnabled ?? !hostManagedModels;
|
|
493
|
+
const models = modelsAdapter.useChatModels!({
|
|
494
|
+
enabled: showModelSelector && resolvedModelStatusChecksEnabled,
|
|
495
|
+
});
|
|
496
|
+
const composerModel = showModelSelector
|
|
497
|
+
? (selectedModel ?? models.selectedModel)
|
|
498
|
+
: undefined;
|
|
499
|
+
const composerEngine = showModelSelector
|
|
500
|
+
? (selectedEngine ?? models.selectedEngine)
|
|
501
|
+
: undefined;
|
|
502
|
+
const composerEffort = showModelSelector
|
|
503
|
+
? (selectedEffort ?? models.selectedEffort)
|
|
504
|
+
: undefined;
|
|
505
|
+
const composerModelGroups = showModelSelector
|
|
506
|
+
? (availableModels ?? models.availableModels)
|
|
507
|
+
: undefined;
|
|
508
|
+
const composerModelListLoading =
|
|
509
|
+
showModelSelector &&
|
|
510
|
+
(modelListLoading ??
|
|
511
|
+
(availableModels ? availableModels.length === 0 : models.isLoading));
|
|
512
|
+
const handleModelChange = showModelSelector
|
|
513
|
+
? (onModelChange ?? models.onModelChange)
|
|
514
|
+
: undefined;
|
|
515
|
+
const handleEffortChange = showModelSelector
|
|
516
|
+
? (onEffortChange ?? models.onEffortChange)
|
|
517
|
+
: undefined;
|
|
518
|
+
const agentEngineConfigured = modelsAdapter.useAgentEngineConfigured!(
|
|
519
|
+
resolvedModelStatusChecksEnabled,
|
|
520
|
+
);
|
|
521
|
+
const missingApiKey = agentEngineConfigured.missing;
|
|
522
|
+
const [missingKeyBouncePulse, setMissingKeyBouncePulse] = useState(0);
|
|
523
|
+
const bounceMissingKeySetup = useCallback(() => {
|
|
524
|
+
setMissingKeyBouncePulse((pulse) => pulse + 1);
|
|
525
|
+
if (typeof window !== "undefined") {
|
|
526
|
+
window.dispatchEvent(new Event("agent-chat:missing-api-key"));
|
|
527
|
+
}
|
|
528
|
+
}, []);
|
|
529
|
+
const handleBuilderConnected = useCallback(() => {
|
|
530
|
+
if (typeof window !== "undefined") {
|
|
531
|
+
window.dispatchEvent(new Event("agent-engine:configured-changed"));
|
|
532
|
+
}
|
|
533
|
+
}, []);
|
|
534
|
+
const ensureAgentEngineReadyForSubmit = useCallback(async () => {
|
|
535
|
+
if (!resolvedModelStatusChecksEnabled) return true;
|
|
536
|
+
const state =
|
|
537
|
+
agentEngineConfigured.state === "missing"
|
|
538
|
+
? "missing"
|
|
539
|
+
: await modelsAdapter.fetchAgentEngineConfiguredState!(
|
|
540
|
+
resolvedModelStatusChecksEnabled,
|
|
541
|
+
{
|
|
542
|
+
timeoutMs: SUBMIT_ENGINE_STATUS_TIMEOUT_MS,
|
|
543
|
+
},
|
|
544
|
+
);
|
|
545
|
+
if (state !== "missing") return true;
|
|
546
|
+
bounceMissingKeySetup();
|
|
547
|
+
return false;
|
|
548
|
+
}, [
|
|
549
|
+
agentEngineConfigured.state,
|
|
550
|
+
bounceMissingKeySetup,
|
|
551
|
+
modelsAdapter,
|
|
552
|
+
resolvedModelStatusChecksEnabled,
|
|
553
|
+
]);
|
|
554
|
+
|
|
555
|
+
useEffect(() => {
|
|
556
|
+
if (!autoFocus) return;
|
|
557
|
+
const id = window.setTimeout(() => {
|
|
558
|
+
const target =
|
|
559
|
+
typeof handleRef === "object" && handleRef && "current" in handleRef
|
|
560
|
+
? handleRef.current
|
|
561
|
+
: null;
|
|
562
|
+
target?.focus();
|
|
563
|
+
}, 50);
|
|
564
|
+
return () => window.clearTimeout(id);
|
|
565
|
+
}, [autoFocus, handleRef]);
|
|
566
|
+
|
|
567
|
+
const handleSubmit = useCallback(
|
|
568
|
+
async (
|
|
569
|
+
text: string,
|
|
570
|
+
references: Reference[],
|
|
571
|
+
attachments?: ReadonlyArray<unknown>,
|
|
572
|
+
submitOptions?: TiptapComposerSubmitOptions,
|
|
573
|
+
) => {
|
|
574
|
+
// PromptComposer hosts (NewWorkspaceAppFlow, create-extension, create-deck,
|
|
575
|
+
// …) submit a single string prompt — they don't run the assistant-ui
|
|
576
|
+
// attachment send pipeline. TiptapComposer auto-converts large pastes
|
|
577
|
+
// into a "Pasted text" chip, which would otherwise disappear into an
|
|
578
|
+
// unprocessed File. Inline the chip body back into the prompt text so
|
|
579
|
+
// newlines and full content survive the round-trip.
|
|
580
|
+
const { text: finalText, files } = await buildPromptComposerSubmission({
|
|
581
|
+
text,
|
|
582
|
+
attachments,
|
|
583
|
+
});
|
|
584
|
+
onSubmit(finalText, files, references, {
|
|
585
|
+
intent: submitOptions?.intent ?? "immediate",
|
|
586
|
+
model: composerModel,
|
|
587
|
+
engine: composerEngine,
|
|
588
|
+
effort: composerEffort,
|
|
589
|
+
});
|
|
590
|
+
},
|
|
591
|
+
[composerEffort, composerEngine, composerModel, onSubmit],
|
|
592
|
+
);
|
|
593
|
+
const useInlineMissingKeySetup = layoutVariant === "compact";
|
|
594
|
+
|
|
595
|
+
return (
|
|
596
|
+
<>
|
|
597
|
+
{missingApiKey && !useInlineMissingKeySetup && BuilderSetupCard ? (
|
|
598
|
+
<BuilderSetupCard
|
|
599
|
+
onConnected={handleBuilderConnected}
|
|
600
|
+
bouncePulse={missingKeyBouncePulse}
|
|
601
|
+
fullWidth
|
|
602
|
+
layout="sidebar"
|
|
603
|
+
/>
|
|
604
|
+
) : null}
|
|
605
|
+
{missingApiKey && useInlineMissingKeySetup && BuilderSetupContent ? (
|
|
606
|
+
<div className="mb-2 rounded-md border border-border/80 bg-background/80 p-2.5 text-start shadow-sm">
|
|
607
|
+
<BuilderSetupContent
|
|
608
|
+
onConnected={handleBuilderConnected}
|
|
609
|
+
layout="sidebar"
|
|
610
|
+
/>
|
|
611
|
+
</div>
|
|
612
|
+
) : null}
|
|
613
|
+
<AgentComposerFrame
|
|
614
|
+
className={cn(
|
|
615
|
+
"text-start",
|
|
616
|
+
missingApiKey && "cursor-pointer",
|
|
617
|
+
className,
|
|
618
|
+
)}
|
|
619
|
+
rootClassName={rootClassName}
|
|
620
|
+
style={style}
|
|
621
|
+
rootStyle={rootStyle}
|
|
622
|
+
layoutVariant={layoutVariant}
|
|
623
|
+
onClick={missingApiKey ? bounceMissingKeySetup : undefined}
|
|
624
|
+
>
|
|
625
|
+
<PromptAttachmentStrip />
|
|
626
|
+
<TiptapComposer
|
|
627
|
+
focusRef={handleRef}
|
|
628
|
+
disabled={disabled || missingApiKey}
|
|
629
|
+
placeholder={
|
|
630
|
+
missingApiKey ? "Connect AI above to continue..." : placeholder
|
|
631
|
+
}
|
|
632
|
+
initialText={initialText}
|
|
633
|
+
initialTextKey={initialTextKey}
|
|
634
|
+
onSubmit={handleSubmit}
|
|
635
|
+
onBeforeSubmit={ensureAgentEngineReadyForSubmit}
|
|
636
|
+
clearOnSubmit={!preserveDraftOnSubmit}
|
|
637
|
+
plusMenuMode={
|
|
638
|
+
plusMenuMode ?? (attachmentsEnabled ? "upload-only" : "hidden")
|
|
639
|
+
}
|
|
640
|
+
attachButton={attachButton}
|
|
641
|
+
modeControl={modeControl}
|
|
642
|
+
toolbarSlot={toolbarSlot}
|
|
643
|
+
actionButton={actionButton}
|
|
644
|
+
extraActionButton={extraActionButton}
|
|
645
|
+
layoutVariant={layoutVariant}
|
|
646
|
+
slashCommands={slashCommands}
|
|
647
|
+
slashSkills={slashSkills}
|
|
648
|
+
includeDefaultSlashCommands={includeDefaultSlashCommands}
|
|
649
|
+
includeDefaultSlashSkills={includeDefaultSlashSkills}
|
|
650
|
+
onSlashCommand={onSlashCommand}
|
|
651
|
+
voiceEnabled={voiceEnabled}
|
|
652
|
+
onTextChange={onTextChange}
|
|
653
|
+
draftScope={draftScope}
|
|
654
|
+
selectedModel={composerModel}
|
|
655
|
+
selectedEffort={composerEffort}
|
|
656
|
+
availableModels={composerModelGroups}
|
|
657
|
+
modelListLoading={composerModelListLoading}
|
|
658
|
+
onModelChange={handleModelChange}
|
|
659
|
+
onEffortChange={handleEffortChange}
|
|
660
|
+
providerConnectStatusEnabled={resolvedModelStatusChecksEnabled}
|
|
661
|
+
onConnectProvider={onConnectProvider}
|
|
662
|
+
onConnectLocalRuntime={onConnectLocalRuntime}
|
|
663
|
+
/>
|
|
664
|
+
</AgentComposerFrame>
|
|
665
|
+
</>
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Standalone composer that mirrors the agent sidebar's input experience —
|
|
671
|
+
* voice dictation, file upload, model selector, submit-on-Enter — for use in
|
|
672
|
+
* popovers and inline prompt forms (create tool, create deck, create dashboard,
|
|
673
|
+
* the Dispatch new-app flow, etc.).
|
|
674
|
+
*
|
|
675
|
+
* The host owns submission: when the user presses Enter or clicks submit,
|
|
676
|
+
* `onSubmit(text, files, references, options)` is called. PromptComposer runs
|
|
677
|
+
* its own minimal assistant-ui runtime so it can be dropped into any subtree
|
|
678
|
+
* without needing the outer chat to be mounted.
|
|
679
|
+
*/
|
|
680
|
+
export function PromptComposer(props: PromptComposerProps) {
|
|
681
|
+
const StaleIndexBoundary =
|
|
682
|
+
useComposerRuntimeAdapters().agentChat!.StaleIndexBoundary!;
|
|
683
|
+
const attachmentAdapter = useMemo(
|
|
684
|
+
() =>
|
|
685
|
+
new CompositeAttachmentAdapter([
|
|
686
|
+
new RasterImageAttachmentAdapter(),
|
|
687
|
+
new BinaryDocumentAttachmentAdapter(),
|
|
688
|
+
new TextAttachmentAdapter(),
|
|
689
|
+
]),
|
|
690
|
+
[],
|
|
691
|
+
);
|
|
692
|
+
const runtime = useLocalRuntime(NOOP_ADAPTER, {
|
|
693
|
+
adapters: { attachments: attachmentAdapter },
|
|
694
|
+
});
|
|
695
|
+
const resetKey = [
|
|
696
|
+
props.draftScope ?? "",
|
|
697
|
+
props.initialTextKey ?? "",
|
|
698
|
+
props.initialText ?? "",
|
|
699
|
+
].join(":");
|
|
700
|
+
|
|
701
|
+
return (
|
|
702
|
+
<TooltipProvider delayDuration={200}>
|
|
703
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
704
|
+
<ThreadPrimitive.Root
|
|
705
|
+
className="contents"
|
|
706
|
+
style={{ display: "contents" }}
|
|
707
|
+
>
|
|
708
|
+
<StaleIndexBoundary
|
|
709
|
+
resetKey={resetKey}
|
|
710
|
+
componentName="PromptComposer"
|
|
711
|
+
>
|
|
712
|
+
<PromptComposerInner {...props} />
|
|
713
|
+
</StaleIndexBoundary>
|
|
714
|
+
</ThreadPrimitive.Root>
|
|
715
|
+
</AssistantRuntimeProvider>
|
|
716
|
+
</TooltipProvider>
|
|
717
|
+
);
|
|
718
|
+
}
|