@crievo/omni 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +41 -0
- package/README.md +2 -2
- package/bin/omni.mjs +18 -0
- package/docs/onboarding/clone-voice.png +0 -0
- package/docs/onboarding/getting-started.png +0 -0
- package/docs/onboarding/new-video.png +0 -0
- package/docs/onboarding/providers.png +0 -0
- package/docs/onboarding/publish.png +0 -0
- package/docs/onboarding/references.png +0 -0
- package/docs/onboarding.md +212 -0
- package/omnivideo.config.example.json +437 -0
- package/package.json +40 -4
- package/reference/captions.md +156 -0
- package/reference/carousel-contract.md +91 -0
- package/reference/cloud.md +96 -0
- package/reference/learnings.md +792 -0
- package/reference/omnichat.md +305 -0
- package/reference/premiere-mcp.md +91 -0
- package/reference/publish.md +305 -0
- package/reference/scenes-contract.md +109 -0
- package/reference/studio.md +666 -0
- package/reference/voicestudio.md +81 -0
- package/reference/writing-for-voice.md +67 -0
- package/requirements.txt +3 -0
- package/studio/api/app.ts +87 -0
- package/studio/api/lib/errors.ts +33 -0
- package/studio/api/lib/files.ts +41 -0
- package/studio/api/lib/hono.ts +9 -0
- package/studio/api/lib/result.ts +14 -0
- package/studio/api/lib/validate.ts +31 -0
- package/studio/api/lib/video.ts +10 -0
- package/studio/api/middleware/json-charset.ts +11 -0
- package/studio/api/middleware/local-only.ts +32 -0
- package/studio/api/middleware/no-timeout.ts +10 -0
- package/studio/api/routes/admin.ts +18 -0
- package/studio/api/routes/agent-cascade.ts +100 -0
- package/studio/api/routes/agent-history.ts +23 -0
- package/studio/api/routes/agent.ts +162 -0
- package/studio/api/routes/analytics.ts +31 -0
- package/studio/api/routes/approval.ts +60 -0
- package/studio/api/routes/archive.ts +12 -0
- package/studio/api/routes/captions.ts +28 -0
- package/studio/api/routes/carousel.ts +38 -0
- package/studio/api/routes/clone.ts +27 -0
- package/studio/api/routes/create.ts +19 -0
- package/studio/api/routes/events.ts +11 -0
- package/studio/api/routes/export.ts +14 -0
- package/studio/api/routes/media.ts +30 -0
- package/studio/api/routes/omnichat.ts +113 -0
- package/studio/api/routes/onboarding.ts +14 -0
- package/studio/api/routes/publish.ts +40 -0
- package/studio/api/routes/queue.ts +14 -0
- package/studio/api/routes/references.ts +40 -0
- package/studio/api/routes/runner.ts +17 -0
- package/studio/api/routes/schedule.ts +47 -0
- package/studio/api/routes/services.ts +11 -0
- package/studio/api/routes/sessions.ts +27 -0
- package/studio/api/routes/settings.ts +102 -0
- package/studio/api/routes/sound.ts +45 -0
- package/studio/api/routes/thumbnail.ts +18 -0
- package/studio/api/routes/usage.ts +13 -0
- package/studio/api/routes/videos.ts +41 -0
- package/studio/api/routes/voices.ts +71 -0
- package/studio/api/services/admin.ts +113 -0
- package/studio/api/services/agent-cascade.ts +975 -0
- package/studio/api/services/agent-claude.ts +47 -0
- package/studio/api/services/agent-history.ts +103 -0
- package/studio/api/services/agent-persona.ts +77 -0
- package/studio/api/services/agent-tools.ts +2237 -0
- package/studio/api/services/agent-ui-tools.ts +259 -0
- package/studio/api/services/agent-wait.ts +32 -0
- package/studio/api/services/agent.ts +553 -0
- package/studio/api/services/analytics.ts +92 -0
- package/studio/api/services/approval.ts +134 -0
- package/studio/api/services/archive.ts +38 -0
- package/studio/api/services/captions.ts +268 -0
- package/studio/api/services/carousel.ts +206 -0
- package/studio/api/services/classify.ts +196 -0
- package/studio/api/services/clone-phrases.ts +75 -0
- package/studio/api/services/clone.ts +722 -0
- package/studio/api/services/create.ts +421 -0
- package/studio/api/services/events.ts +215 -0
- package/studio/api/services/media.ts +32 -0
- package/studio/api/services/omnichat.ts +624 -0
- package/studio/api/services/onboarding.ts +77 -0
- package/studio/api/services/publish.ts +287 -0
- package/studio/api/services/queue.ts +150 -0
- package/studio/api/services/references.ts +269 -0
- package/studio/api/services/root.ts +60 -0
- package/studio/api/services/services.ts +114 -0
- package/studio/api/services/sessions.ts +1007 -0
- package/studio/api/services/settings.ts +983 -0
- package/studio/api/services/sound.ts +311 -0
- package/studio/api/services/thumbnail.ts +133 -0
- package/studio/api/services/usage.ts +27 -0
- package/studio/api/services/videos.ts +418 -0
- package/studio/api/services/voice-pause.ts +98 -0
- package/studio/api/services/voices.ts +324 -0
- package/studio/runner/runner.ts +244 -0
- package/studio/shared/omni-actions.ts +68 -0
- package/studio/shared/omni-admin.ts +52 -0
- package/studio/shared/omni-farewell.ts +48 -0
- package/studio/shared/omni-hotword.ts +20 -0
- package/studio/shared/omni-screens.ts +228 -0
- package/studio/shared/schemas/admin.ts +15 -0
- package/studio/shared/schemas/agent-cascade.ts +58 -0
- package/studio/shared/schemas/agent-history.ts +73 -0
- package/studio/shared/schemas/agent.ts +50 -0
- package/studio/shared/schemas/analytics.ts +6 -0
- package/studio/shared/schemas/approval.ts +22 -0
- package/studio/shared/schemas/captions.ts +19 -0
- package/studio/shared/schemas/carousel.ts +26 -0
- package/studio/shared/schemas/clone.ts +40 -0
- package/studio/shared/schemas/common.ts +16 -0
- package/studio/shared/schemas/omnichat.ts +54 -0
- package/studio/shared/schemas/onboarding.ts +5 -0
- package/studio/shared/schemas/publish.ts +45 -0
- package/studio/shared/schemas/references.ts +20 -0
- package/studio/shared/schemas/settings.ts +82 -0
- package/studio/shared/schemas/sound.ts +22 -0
- package/studio/shared/schemas/videos.ts +38 -0
- package/studio/shared/schemas/voices.ts +23 -0
- package/studio/shared/types/api.ts +1290 -0
- package/studio/studio.ts +148 -0
- package/studio/tsconfig.json +15 -0
- package/studio/web/assets/logos/cartesia.svg +4 -0
- package/studio/web/assets/logos/elevenlabs.svg +12 -0
- package/studio/web/assets/logos/fish.svg +24 -0
- package/studio/web/assets/logos/omni-black.png +0 -0
- package/studio/web/assets/logos/omni-white.png +0 -0
- package/studio/web/assets/logos/voicestudio.svg +21 -0
- package/studio/web/components/AgentMark.tsx +7 -0
- package/studio/web/components/AgentWalking.tsx +11 -0
- package/studio/web/components/ApiKeyField.tsx +104 -0
- package/studio/web/components/AppShell.tsx +64 -0
- package/studio/web/components/ApprovalNotice.tsx +65 -0
- package/studio/web/components/AvatarGroupIcon.tsx +22 -0
- package/studio/web/components/AvatarNameField.tsx +86 -0
- package/studio/web/components/AvatarPicker.tsx +84 -0
- package/studio/web/components/BrandLogo.tsx +16 -0
- package/studio/web/components/CartesiaPlanSetting.tsx +90 -0
- package/studio/web/components/ClaudeWalking.tsx +32 -0
- package/studio/web/components/CloneVoiceDialog/GuidedScript.tsx +39 -0
- package/studio/web/components/CloneVoiceDialog/LanguageBar.tsx +37 -0
- package/studio/web/components/CloneVoiceDialog/LevelMeter.tsx +31 -0
- package/studio/web/components/CloneVoiceDialog/ProviderChoice.tsx +81 -0
- package/studio/web/components/CloneVoiceDialog/QualityPanel.tsx +62 -0
- package/studio/web/components/CloneVoiceDialog/RecordStep.tsx +50 -0
- package/studio/web/components/CloneVoiceDialog/RecorderBar.tsx +79 -0
- package/studio/web/components/CloneVoiceDialog/RedoSummary.tsx +54 -0
- package/studio/web/components/CloneVoiceDialog/SaveStep.tsx +91 -0
- package/studio/web/components/CloneVoiceDialog/SourceBar.tsx +30 -0
- package/studio/web/components/CloneVoiceDialog/index.tsx +141 -0
- package/studio/web/components/CloneVoiceDialog/types.ts +28 -0
- package/studio/web/components/CloneVoiceDialog/useCloneVoice.ts +528 -0
- package/studio/web/components/ConnectionSignals.tsx +51 -0
- package/studio/web/components/EditVoiceDialog/EditVoiceFooter.tsx +72 -0
- package/studio/web/components/EditVoiceDialog/ProviderCards.tsx +81 -0
- package/studio/web/components/EditVoiceDialog/index.tsx +256 -0
- package/studio/web/components/ErrorBanner.tsx +115 -0
- package/studio/web/components/FinishedTask.tsx +41 -0
- package/studio/web/components/FishModelSetting.tsx +69 -0
- package/studio/web/components/FishPriceSetting.tsx +44 -0
- package/studio/web/components/HumanBanner.tsx +64 -0
- package/studio/web/components/Lightbox.tsx +41 -0
- package/studio/web/components/LogStream.tsx +42 -0
- package/studio/web/components/Markdown.tsx +21 -0
- package/studio/web/components/MissingDmsPanel/BatchSend.tsx +137 -0
- package/studio/web/components/MissingDmsPanel/CommentCard.tsx +168 -0
- package/studio/web/components/MissingDmsPanel/CommentFeed.tsx +45 -0
- package/studio/web/components/MissingDmsPanel/DmBubble.tsx +38 -0
- package/studio/web/components/MissingDmsPanel/ReplyComposer.tsx +63 -0
- package/studio/web/components/MissingDmsPanel/index.tsx +98 -0
- package/studio/web/components/NotFound.tsx +48 -0
- package/studio/web/components/Omni/OmniAvatarPicker.tsx +92 -0
- package/studio/web/components/Omni/OmniCards.tsx +202 -0
- package/studio/web/components/Omni/OmniGlow.tsx +183 -0
- package/studio/web/components/Omni/OmniHistory.tsx +119 -0
- package/studio/web/components/Omni/OmniHotword.tsx +40 -0
- package/studio/web/components/Omni/OmniMicSelect.tsx +92 -0
- package/studio/web/components/Omni/OmniVoiceSample.tsx +81 -0
- package/studio/web/components/Omni/OmniWidget.tsx +743 -0
- package/studio/web/components/Omni/PendingActions.tsx +200 -0
- package/studio/web/components/Omni/Transcript.tsx +127 -0
- package/studio/web/components/OmnichatAccountStatus.tsx +87 -0
- package/studio/web/components/OmnichatRulePanel/RuleConfig.tsx +150 -0
- package/studio/web/components/OmnichatRulePanel/RuleDryRun.tsx +15 -0
- package/studio/web/components/OmnichatRulePanel/RuleEnableConfirm.tsx +42 -0
- package/studio/web/components/OmnichatRulePanel/RuleSkeleton.tsx +18 -0
- package/studio/web/components/OmnichatRulePanel/RuleStatus.tsx +55 -0
- package/studio/web/components/OmnichatRulePanel/index.tsx +115 -0
- package/studio/web/components/OmnichatRulePanel/rule-steps.ts +67 -0
- package/studio/web/components/OmnichatRulePanel/steps/MessageStep.tsx +91 -0
- package/studio/web/components/OmnichatRulePanel/steps/RepliesStep.tsx +201 -0
- package/studio/web/components/OmnichatRulePanel/steps/TriggerStep.tsx +76 -0
- package/studio/web/components/OmnichatRulePanel/steps/types.ts +11 -0
- package/studio/web/components/Palette.tsx +17 -0
- package/studio/web/components/PlatformCard.tsx +109 -0
- package/studio/web/components/PlatformIcon.tsx +19 -0
- package/studio/web/components/ProviderCard.tsx +80 -0
- package/studio/web/components/ProviderDetail.tsx +367 -0
- package/studio/web/components/ProviderLogo.tsx +20 -0
- package/studio/web/components/QueuePanel.tsx +77 -0
- package/studio/web/components/ReferenceActions.tsx +89 -0
- package/studio/web/components/ReferencePicker.tsx +136 -0
- package/studio/web/components/ResultMessage.tsx +7 -0
- package/studio/web/components/RuleForm.tsx +138 -0
- package/studio/web/components/RuleLog.tsx +151 -0
- package/studio/web/components/RunningTask.tsx +23 -0
- package/studio/web/components/SampleList.tsx +55 -0
- package/studio/web/components/SessionPanel.tsx +352 -0
- package/studio/web/components/SettingRow.tsx +14 -0
- package/studio/web/components/SettingsCategorySkeleton.tsx +25 -0
- package/studio/web/components/SidePanel.tsx +77 -0
- package/studio/web/components/Sidebar.tsx +289 -0
- package/studio/web/components/StageStepper.tsx +87 -0
- package/studio/web/components/StudioOffline.tsx +80 -0
- package/studio/web/components/TaskName.tsx +17 -0
- package/studio/web/components/TopBanners.tsx +30 -0
- package/studio/web/components/VideoOmnichatPanel.tsx +287 -0
- package/studio/web/components/VoiceAvatar.tsx +33 -0
- package/studio/web/components/VoiceCarousel.tsx +196 -0
- package/studio/web/components/VoiceCategory.tsx +9 -0
- package/studio/web/components/VoiceModal.tsx +39 -0
- package/studio/web/components/VoiceProfileCard.tsx +75 -0
- package/studio/web/components/VoiceProfilePicker.tsx +107 -0
- package/studio/web/components/VoiceProfilesSettings.tsx +150 -0
- package/studio/web/components/VoiceProviderCard.tsx +118 -0
- package/studio/web/components/VoiceProvidersCard.tsx +26 -0
- package/studio/web/components/WaitList.tsx +21 -0
- package/studio/web/components/icons.tsx +247 -0
- package/studio/web/components/ui/accordion.tsx +47 -0
- package/studio/web/components/ui/badge.tsx +18 -0
- package/studio/web/components/ui/calendar.tsx +43 -0
- package/studio/web/components/ui/chart.tsx +229 -0
- package/studio/web/components/ui/checkbox.tsx +26 -0
- package/studio/web/components/ui/cx.ts +2 -0
- package/studio/web/components/ui/date-time-picker.tsx +84 -0
- package/studio/web/components/ui/panel.tsx +23 -0
- package/studio/web/components/ui/picker.tsx +58 -0
- package/studio/web/components/ui/popover.tsx +24 -0
- package/studio/web/components/ui/select.tsx +89 -0
- package/studio/web/components/ui/skeleton.tsx +10 -0
- package/studio/web/components/ui/slider.tsx +68 -0
- package/studio/web/components/ui/switch.tsx +13 -0
- package/studio/web/components/ui/tooltip.tsx +59 -0
- package/studio/web/hooks/useAccounts.ts +27 -0
- package/studio/web/hooks/useAdmin.ts +12 -0
- package/studio/web/hooks/useAnalytics.ts +21 -0
- package/studio/web/hooks/useAvatarAudioReactive.ts +87 -0
- package/studio/web/hooks/useBrowserConnect.ts +48 -0
- package/studio/web/hooks/useClonePlan.ts +14 -0
- package/studio/web/hooks/useConnected.ts +7 -0
- package/studio/web/hooks/useLiveQuery.ts +29 -0
- package/studio/web/hooks/useMenuCollapsed.ts +32 -0
- package/studio/web/hooks/useMicDevices.ts +53 -0
- package/studio/web/hooks/useMissingDms.ts +211 -0
- package/studio/web/hooks/useMissingSetupSteps.ts +26 -0
- package/studio/web/hooks/useNow.ts +11 -0
- package/studio/web/hooks/useOmniAgent.ts +278 -0
- package/studio/web/hooks/useOmniClaude.ts +124 -0
- package/studio/web/hooks/useOmniDock.ts +142 -0
- package/studio/web/hooks/useOmniGreeting.ts +60 -0
- package/studio/web/hooks/useOmniHotword.ts +128 -0
- package/studio/web/hooks/useOmnichat.ts +26 -0
- package/studio/web/hooks/useOnboarding.ts +27 -0
- package/studio/web/hooks/usePost.ts +23 -0
- package/studio/web/hooks/useQueue.ts +10 -0
- package/studio/web/hooks/useReferences.ts +20 -0
- package/studio/web/hooks/useRuleEditor.ts +101 -0
- package/studio/web/hooks/useRunner.ts +24 -0
- package/studio/web/hooks/useSaveAction.ts +23 -0
- package/studio/web/hooks/useSchedule.ts +11 -0
- package/studio/web/hooks/useServices.ts +10 -0
- package/studio/web/hooks/useSessions.ts +15 -0
- package/studio/web/hooks/useSettings.ts +11 -0
- package/studio/web/hooks/useSettingsSection.ts +30 -0
- package/studio/web/hooks/useSidePanel.ts +23 -0
- package/studio/web/hooks/useSound.ts +30 -0
- package/studio/web/hooks/useUsage.ts +11 -0
- package/studio/web/hooks/useVideoVoice.ts +36 -0
- package/studio/web/hooks/useVideos.ts +21 -0
- package/studio/web/hooks/useVoiceProfilePreview.ts +52 -0
- package/studio/web/hooks/useVoiceProfiles.ts +7 -0
- package/studio/web/hooks/useVoiceRunning.ts +10 -0
- package/studio/web/hooks/useVoiceStudioClosed.ts +8 -0
- package/studio/web/index.html +19 -0
- package/studio/web/lib/agent.ts +7 -0
- package/studio/web/lib/alerts.ts +210 -0
- package/studio/web/lib/analytics-metrics.ts +351 -0
- package/studio/web/lib/api.ts +70 -0
- package/studio/web/lib/audio.ts +39 -0
- package/studio/web/lib/avatars.ts +41 -0
- package/studio/web/lib/calendar.ts +218 -0
- package/studio/web/lib/caption-position.ts +249 -0
- package/studio/web/lib/carousel.ts +24 -0
- package/studio/web/lib/chime.ts +42 -0
- package/studio/web/lib/clone-voice.ts +55 -0
- package/studio/web/lib/export.ts +11 -0
- package/studio/web/lib/files.ts +8 -0
- package/studio/web/lib/format.ts +93 -0
- package/studio/web/lib/media.ts +29 -0
- package/studio/web/lib/mic-device.ts +72 -0
- package/studio/web/lib/missing-dms.ts +70 -0
- package/studio/web/lib/omni-cards.ts +42 -0
- package/studio/web/lib/omni-cascade.ts +1067 -0
- package/studio/web/lib/omni-greeting-audio.ts +24 -0
- package/studio/web/lib/omni-hotword.ts +231 -0
- package/studio/web/lib/omni-panel.ts +67 -0
- package/studio/web/lib/omni-realtime.ts +811 -0
- package/studio/web/lib/omni-ui.ts +402 -0
- package/studio/web/lib/omni-wait.ts +174 -0
- package/studio/web/lib/omnichat-api.ts +44 -0
- package/studio/web/lib/orb.ts +270 -0
- package/studio/web/lib/pcm-recorder.ts +115 -0
- package/studio/web/lib/platforms.ts +17 -0
- package/studio/web/lib/providers.ts +27 -0
- package/studio/web/lib/publish-draft.ts +52 -0
- package/studio/web/lib/publish-settings.ts +81 -0
- package/studio/web/lib/query-client.ts +122 -0
- package/studio/web/lib/references.ts +13 -0
- package/studio/web/lib/services.ts +40 -0
- package/studio/web/lib/sessions.ts +103 -0
- package/studio/web/lib/settings-categories.ts +58 -0
- package/studio/web/lib/sound-audio.ts +33 -0
- package/studio/web/lib/sound-timeline.ts +291 -0
- package/studio/web/lib/sse.ts +86 -0
- package/studio/web/lib/stage-history.ts +141 -0
- package/studio/web/lib/stages.ts +344 -0
- package/studio/web/lib/studio-offline.ts +60 -0
- package/studio/web/lib/upload.ts +24 -0
- package/studio/web/lib/video-tabs.ts +118 -0
- package/studio/web/lib/voice-profile-draft.ts +34 -0
- package/studio/web/lib/voice-profiles.ts +3 -0
- package/studio/web/main.tsx +14 -0
- package/studio/web/pages/AdminPage/index.tsx +123 -0
- package/studio/web/pages/AgentPage/components/Measurements.tsx +102 -0
- package/studio/web/pages/AgentPage/index.tsx +28 -0
- package/studio/web/pages/AnalyticsPage/components/About.tsx +52 -0
- package/studio/web/pages/AnalyticsPage/components/ChannelCards.tsx +106 -0
- package/studio/web/pages/AnalyticsPage/components/ChannelView.tsx +137 -0
- package/studio/web/pages/AnalyticsPage/components/CollectionStatus.tsx +46 -0
- package/studio/web/pages/AnalyticsPage/components/Comparison.tsx +68 -0
- package/studio/web/pages/AnalyticsPage/components/Diagnosis.tsx +50 -0
- package/studio/web/pages/AnalyticsPage/components/Highlights.tsx +49 -0
- package/studio/web/pages/AnalyticsPage/components/Hint.tsx +11 -0
- package/studio/web/pages/AnalyticsPage/components/HookVsBody.tsx +100 -0
- package/studio/web/pages/AnalyticsPage/components/HourlyWave.tsx +133 -0
- package/studio/web/pages/AnalyticsPage/components/Insights.tsx +70 -0
- package/studio/web/pages/AnalyticsPage/components/MetricCard.tsx +46 -0
- package/studio/web/pages/AnalyticsPage/components/PlanSection.tsx +40 -0
- package/studio/web/pages/AnalyticsPage/components/ProgressionChart.tsx +155 -0
- package/studio/web/pages/AnalyticsPage/components/ReelBarsChart.tsx +154 -0
- package/studio/web/pages/AnalyticsPage/components/ReelThumb.tsx +19 -0
- package/studio/web/pages/AnalyticsPage/components/ReelView.tsx +290 -0
- package/studio/web/pages/AnalyticsPage/components/ReelsTable.tsx +269 -0
- package/studio/web/pages/AnalyticsPage/components/RequestWithFocus.tsx +38 -0
- package/studio/web/pages/AnalyticsPage/components/SegmentedControl.tsx +35 -0
- package/studio/web/pages/AnalyticsPage/components/VsMedian.tsx +31 -0
- package/studio/web/pages/AnalyticsPage/index.tsx +17 -0
- package/studio/web/pages/GettingStartedPage/index.tsx +174 -0
- package/studio/web/pages/NewVideoPage/components/DeliverablesPicker.tsx +62 -0
- package/studio/web/pages/NewVideoPage/components/FormatPicker.tsx +33 -0
- package/studio/web/pages/NewVideoPage/index.tsx +133 -0
- package/studio/web/pages/NotFoundPage/index.tsx +9 -0
- package/studio/web/pages/OmnichatPage/components/NewFromLink.tsx +59 -0
- package/studio/web/pages/OmnichatPage/components/RuleListItem.tsx +64 -0
- package/studio/web/pages/OmnichatPage/components/RulePreview.tsx +14 -0
- package/studio/web/pages/OmnichatPage/components/RuleView.tsx +88 -0
- package/studio/web/pages/OmnichatPage/index.tsx +153 -0
- package/studio/web/pages/QueuePage/index.tsx +22 -0
- package/studio/web/pages/ReferencePage/components/ReferenceTexts.tsx +131 -0
- package/studio/web/pages/ReferencePage/index.tsx +216 -0
- package/studio/web/pages/ReferencesPage/components/NewReferenceForm.tsx +150 -0
- package/studio/web/pages/ReferencesPage/components/ReferenceCard.tsx +42 -0
- package/studio/web/pages/ReferencesPage/components/ReferenceGridSkeleton.tsx +31 -0
- package/studio/web/pages/ReferencesPage/index.tsx +67 -0
- package/studio/web/pages/SchedulePage/components/CalendarSkeleton.tsx +18 -0
- package/studio/web/pages/SchedulePage/components/DayView.tsx +177 -0
- package/studio/web/pages/SchedulePage/components/HourPicker.tsx +103 -0
- package/studio/web/pages/SchedulePage/components/MonthDayCell.tsx +111 -0
- package/studio/web/pages/SchedulePage/components/MonthView.tsx +47 -0
- package/studio/web/pages/SchedulePage/components/PlatformIcons.tsx +12 -0
- package/studio/web/pages/SchedulePage/components/PostThumb.tsx +15 -0
- package/studio/web/pages/SchedulePage/components/WeekColumn.tsx +75 -0
- package/studio/web/pages/SchedulePage/components/WeekView.tsx +35 -0
- package/studio/web/pages/SchedulePage/index.tsx +285 -0
- package/studio/web/pages/SettingsPage/components/AgentAccounts.tsx +263 -0
- package/studio/web/pages/SettingsPage/components/AgentCategory.tsx +20 -0
- package/studio/web/pages/SettingsPage/components/ModelPicker.tsx +49 -0
- package/studio/web/pages/SettingsPage/components/ModelsSettings.tsx +138 -0
- package/studio/web/pages/SettingsPage/components/PlatformsCategory.tsx +23 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/AccountStatus.tsx +29 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/AutoPublishPanel.tsx +90 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/BrowserConnect.tsx +62 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/CheckField.tsx +19 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/InstagramPanel.tsx +113 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/OmnichatSettingsPanel.tsx +146 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SaveBar.tsx +33 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SchedulePanel.tsx +132 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SettingsCard.tsx +47 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SettingsCardGroup.tsx +19 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/TextPanel.tsx +55 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/TiktokPanel.tsx +123 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/YoutubePanel.tsx +100 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/badges.tsx +15 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/index.tsx +40 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/types.ts +10 -0
- package/studio/web/pages/SettingsPage/components/UsageCategory.tsx +389 -0
- package/studio/web/pages/SettingsPage/components/VoiceProvidersCategory.tsx +97 -0
- package/studio/web/pages/SettingsPage/index.tsx +85 -0
- package/studio/web/pages/VideoPage/components/AudioPlayer.tsx +113 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/AxisField.tsx +50 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionList.tsx +56 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionListItem.tsx +92 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionMargins.tsx +57 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionStyleFields.tsx +70 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionTextForm.tsx +87 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/ColorField.tsx +37 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/MarginField.tsx +59 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/NumberField.tsx +57 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/PositionControls.tsx +140 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/captionEditor.ts +215 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/useCaptionPosition.ts +154 -0
- package/studio/web/pages/VideoPage/components/CarouselChangeRequest.tsx +72 -0
- package/studio/web/pages/VideoPage/components/CarouselCompositionStage.tsx +80 -0
- package/studio/web/pages/VideoPage/components/CarouselCreate.tsx +63 -0
- package/studio/web/pages/VideoPage/components/CarouselMissing.tsx +19 -0
- package/studio/web/pages/VideoPage/components/CarouselPublishStage.tsx +173 -0
- package/studio/web/pages/VideoPage/components/CarouselScriptStage.tsx +82 -0
- package/studio/web/pages/VideoPage/components/CarouselSlideCard.tsx +49 -0
- package/studio/web/pages/VideoPage/components/CarouselViewer.tsx +55 -0
- package/studio/web/pages/VideoPage/components/ChangedVoices.tsx +53 -0
- package/studio/web/pages/VideoPage/components/CompositionStage.tsx +78 -0
- package/studio/web/pages/VideoPage/components/CoverPicker.tsx +32 -0
- package/studio/web/pages/VideoPage/components/EditorStage.tsx +53 -0
- package/studio/web/pages/VideoPage/components/LineTakes.tsx +160 -0
- package/studio/web/pages/VideoPage/components/LineTextEditor.tsx +124 -0
- package/studio/web/pages/VideoPage/components/LineVoicePicker.tsx +37 -0
- package/studio/web/pages/VideoPage/components/MediaImage.tsx +25 -0
- package/studio/web/pages/VideoPage/components/MotionScriptStage.tsx +39 -0
- package/studio/web/pages/VideoPage/components/NarrationStage.tsx +70 -0
- package/studio/web/pages/VideoPage/components/PublishForm.tsx +387 -0
- package/studio/web/pages/VideoPage/components/PublishStage.tsx +76 -0
- package/studio/web/pages/VideoPage/components/PublishText.tsx +149 -0
- package/studio/web/pages/VideoPage/components/ScenesApprovalPanel.tsx +278 -0
- package/studio/web/pages/VideoPage/components/ScheduledInfo.tsx +72 -0
- package/studio/web/pages/VideoPage/components/ScriptApprovalPanel.tsx +189 -0
- package/studio/web/pages/VideoPage/components/ScriptStage.tsx +17 -0
- package/studio/web/pages/VideoPage/components/SequencePlayer.tsx +146 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/AddSound.tsx +117 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/AreaSelection.tsx +74 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/BedPanel.tsx +94 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/BedRow.tsx +45 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionOverlay.tsx +44 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionSaveBar.tsx +32 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionsPanel.tsx +22 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/ClipBlock.tsx +111 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/ClipPanel.tsx +76 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CutsPanel.tsx +44 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EditorTabBar.tsx +73 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectChoice.tsx +46 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectItem.tsx +89 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectPanel.tsx +232 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectsRow.tsx +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/Lane.tsx +39 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/MarkerRow.tsx +40 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/MuteButton.tsx +36 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/NumberInput.tsx +37 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PlanWarnings.tsx +19 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PlayerResizeHandle.tsx +50 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PreviewControls.tsx +51 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SceneRow.tsx +54 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SettingsPanel.tsx +65 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SoundLibrary.tsx +99 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SoundPreview.tsx +82 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SpeedPanel.tsx +128 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineDock.tsx +56 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineFooter.tsx +26 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineSkeleton.tsx +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineToolbar.tsx +160 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineTracks.tsx +121 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TrackSidebar.tsx +30 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/VoiceRow.tsx +53 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/Waveform.tsx +97 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/clipActions.ts +50 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/effectActions.ts +161 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/index.tsx +161 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/timelineGeometry.ts +45 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/types.ts +43 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useAutosave.ts +107 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useEditorShortcuts.ts +168 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useFitHeight.ts +40 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useFollowPlayhead.ts +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useListenMix.ts +43 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/usePlayback.ts +231 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/usePlayerWidth.ts +27 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useSoundData.ts +124 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useSoundTimeline.ts +511 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/CompareVersions.tsx +111 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionCard.tsx +81 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionMedia.tsx +24 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionText.tsx +15 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/index.tsx +109 -0
- package/studio/web/pages/VideoPage/components/StageProcess.tsx +126 -0
- package/studio/web/pages/VideoPage/components/StageResult.tsx +69 -0
- package/studio/web/pages/VideoPage/components/SwapReference.tsx +92 -0
- package/studio/web/pages/VideoPage/components/ThumbnailPanel.tsx +252 -0
- package/studio/web/pages/VideoPage/components/TimingPanel.tsx +89 -0
- package/studio/web/pages/VideoPage/components/VideoPlayer.tsx +18 -0
- package/studio/web/pages/VideoPage/components/VideoSkeleton.tsx +50 -0
- package/studio/web/pages/VideoPage/components/VideoVoiceInfo.tsx +33 -0
- package/studio/web/pages/VideoPage/components/VideoVoicePicker.tsx +165 -0
- package/studio/web/pages/VideoPage/components/VoicePauseBanner.tsx +56 -0
- package/studio/web/pages/VideoPage/components/WithLogo.tsx +10 -0
- package/studio/web/pages/VideoPage/index.tsx +295 -0
- package/studio/web/pages/VideosPage/components/PublishedOn.tsx +85 -0
- package/studio/web/pages/VideosPage/components/ServicesPanel.tsx +81 -0
- package/studio/web/pages/VideosPage/components/SessionsPanel.tsx +62 -0
- package/studio/web/pages/VideosPage/components/VideoListSkeleton.tsx +25 -0
- package/studio/web/pages/VideosPage/components/VideoRow.tsx +122 -0
- package/studio/web/pages/VideosPage/index.tsx +134 -0
- package/studio/web/pages/VoicePage/index.tsx +28 -0
- package/studio/web/router.tsx +201 -0
- package/studio/web/styles/base/elements.css +55 -0
- package/studio/web/styles/base/utilities.css +25 -0
- package/studio/web/styles/components/badge.css +33 -0
- package/studio/web/styles/components/claude-running.css +27 -0
- package/studio/web/styles/components/claude-session.css +212 -0
- package/studio/web/styles/components/claude-walking.css +92 -0
- package/studio/web/styles/components/clone-voice-save.css +136 -0
- package/studio/web/styles/components/clone-voice.css +379 -0
- package/studio/web/styles/components/controls.css +70 -0
- package/studio/web/styles/components/data-and-image.css +54 -0
- package/studio/web/styles/components/forms.css +132 -0
- package/studio/web/styles/components/human-banner.css +99 -0
- package/studio/web/styles/components/lightbox.css +50 -0
- package/studio/web/styles/components/markdown.css +68 -0
- package/studio/web/styles/components/modal.css +70 -0
- package/studio/web/styles/components/omni-cards.css +105 -0
- package/studio/web/styles/components/omni.css +859 -0
- package/studio/web/styles/components/omnichat.css +538 -0
- package/studio/web/styles/components/panel.css +115 -0
- package/studio/web/styles/components/platform-card.css +140 -0
- package/studio/web/styles/components/provider-card.css +132 -0
- package/studio/web/styles/components/queue.css +185 -0
- package/studio/web/styles/components/reference-actions.css +133 -0
- package/studio/web/styles/components/reference-picker.css +146 -0
- package/studio/web/styles/components/results-drawer.css +224 -0
- package/studio/web/styles/components/segmented.css +115 -0
- package/studio/web/styles/components/side-panel-tab.css +23 -0
- package/studio/web/styles/components/status-signals.css +66 -0
- package/studio/web/styles/components/stepper.css +208 -0
- package/studio/web/styles/components/table.css +19 -0
- package/studio/web/styles/components/tabs.css +24 -0
- package/studio/web/styles/components/ui/accordion.css +71 -0
- package/studio/web/styles/components/ui/chart.css +162 -0
- package/studio/web/styles/components/ui/checkbox.css +37 -0
- package/studio/web/styles/components/ui/date-picker.css +153 -0
- package/studio/web/styles/components/ui/select.css +110 -0
- package/studio/web/styles/components/ui/skeleton.css +25 -0
- package/studio/web/styles/components/ui/slider.css +81 -0
- package/studio/web/styles/components/ui/switch.css +41 -0
- package/studio/web/styles/components/ui/tooltip.css +24 -0
- package/studio/web/styles/components/voice-carousel.css +255 -0
- package/studio/web/styles/components/voice-editor.css +179 -0
- package/studio/web/styles/components/voice-grid.css +56 -0
- package/studio/web/styles/components/voice-profiles.css +192 -0
- package/studio/web/styles/design-system.md +136 -0
- package/studio/web/styles/index.css +116 -0
- package/studio/web/styles/layout/page.css +41 -0
- package/studio/web/styles/layout/sidebar-groups.css +39 -0
- package/studio/web/styles/layout/sidebar.css +111 -0
- package/studio/web/styles/pages/agent.css +26 -0
- package/studio/web/styles/pages/analytics/dashboard.css +614 -0
- package/studio/web/styles/pages/analytics/insights.css +48 -0
- package/studio/web/styles/pages/getting-started.css +166 -0
- package/studio/web/styles/pages/new-video/form.css +32 -0
- package/studio/web/styles/pages/not-found.css +59 -0
- package/studio/web/styles/pages/references.css +204 -0
- package/studio/web/styles/pages/schedule/calendar.css +541 -0
- package/studio/web/styles/pages/schedule/chip-states.css +60 -0
- package/studio/web/styles/pages/settings/models.css +72 -0
- package/studio/web/styles/pages/settings/shell.css +361 -0
- package/studio/web/styles/pages/settings/usage.css +63 -0
- package/studio/web/styles/pages/studio-offline.css +105 -0
- package/studio/web/styles/pages/video/caption-controls.css +194 -0
- package/studio/web/styles/pages/video/captions-grid.css +70 -0
- package/studio/web/styles/pages/video/captions.css +79 -0
- package/studio/web/styles/pages/video/editor-chat.css +103 -0
- package/studio/web/styles/pages/video/export.css +50 -0
- package/studio/web/styles/pages/video/frames.css +29 -0
- package/studio/web/styles/pages/video/fullscreen-stage.css +400 -0
- package/studio/web/styles/pages/video/instagram-carousel.css +309 -0
- package/studio/web/styles/pages/video/layout.css +285 -0
- package/studio/web/styles/pages/video/narration.css +138 -0
- package/studio/web/styles/pages/video/preview-overview.css +11 -0
- package/studio/web/styles/pages/video/processing-notice.css +34 -0
- package/studio/web/styles/pages/video/publish-when.css +76 -0
- package/studio/web/styles/pages/video/publish.css +97 -0
- package/studio/web/styles/pages/video/result.css +96 -0
- package/studio/web/styles/pages/video/scenes.css +167 -0
- package/studio/web/styles/pages/video/sound-timeline.css +672 -0
- package/studio/web/styles/pages/video/sound-toolbar.css +149 -0
- package/studio/web/styles/pages/video/take-player.css +100 -0
- package/studio/web/styles/pages/video/thumbnail.css +157 -0
- package/studio/web/styles/pages/video/timeline.css +117 -0
- package/studio/web/styles/pages/video/voice-picker.css +14 -0
- package/studio/web/styles/pages/video-list/active-row.css +27 -0
- package/studio/web/styles/pages/video-list/card-link.css +49 -0
- package/studio/web/styles/pages/video-list/list.css +86 -0
- package/studio/web/styles/theme/identity/details.css +204 -0
- package/studio/web/styles/theme/identity/shell.css +249 -0
- package/studio/web/styles/theme/identity/surfaces.css +183 -0
- package/studio/web/styles/theme/identity/titles-and-buttons.css +120 -0
- package/studio/web/styles/theme/no-borders/blocks.css +208 -0
- package/studio/web/styles/theme/no-borders/controls.css +256 -0
- package/studio/web/styles/tokens.css +245 -0
- package/studio/web/types/api.ts +2 -0
- package/studio/web/types/assets.d.ts +9 -0
- package/templates/brief.md +27 -0
- package/templates/captions.html +204 -0
- package/templates/carousel-composition.md +47 -0
- package/templates/carousel-script.md +60 -0
- package/templates/components/voiceavatar/README.md +87 -0
- package/templates/components/voiceavatar/demo.html +50 -0
- package/templates/components/voiceavatar/voiceavatar.js +415 -0
- package/templates/motion.md +80 -0
- package/templates/playbook.md +43 -0
- package/templates/reference.md +123 -0
- package/templates/scene.html +112 -0
- package/templates/scenes.example.json +96 -0
- package/templates/script.md +63 -0
- package/templates/slide.html +71 -0
- package/templates/wireframe.html +91 -0
- package/tools/analysis.mjs +300 -0
- package/tools/approval.mjs +442 -0
- package/tools/assemble.mjs +942 -0
- package/tools/build-motion.mjs +437 -0
- package/tools/captions.mjs +246 -0
- package/tools/carousel.mjs +558 -0
- package/tools/compose.mjs +307 -0
- package/tools/cuts.mjs +74 -0
- package/tools/editor.mjs +419 -0
- package/tools/epidemic-capture.js +54 -0
- package/tools/fanout.mjs +69 -0
- package/tools/history.mjs +70 -0
- package/tools/history.py +61 -0
- package/tools/job-queue.mjs +180 -0
- package/tools/job_queue.py +430 -0
- package/tools/lib/agents.mjs +412 -0
- package/tools/lib/channel.mjs +399 -0
- package/tools/lib/claude-settings.mjs +67 -0
- package/tools/lib/cli.mjs +9 -0
- package/tools/lib/fanout.mjs +234 -0
- package/tools/lib/http.mjs +94 -0
- package/tools/lib/index.js +14 -0
- package/tools/lib/mcp-server.mjs +69 -0
- package/tools/lib/metrics/metrics.mjs +204 -0
- package/tools/lib/narration.mjs +15 -0
- package/tools/lib/oauth-client.mjs +295 -0
- package/tools/lib/omnichat/config.mjs +139 -0
- package/tools/lib/omnichat/errors.mjs +42 -0
- package/tools/lib/omnichat/extract.mjs +82 -0
- package/tools/lib/omnichat/gate.mjs +151 -0
- package/tools/lib/omnichat/manual.mjs +166 -0
- package/tools/lib/omnichat/match.mjs +78 -0
- package/tools/lib/omnichat/pass.mjs +393 -0
- package/tools/lib/omnichat/record.mjs +208 -0
- package/tools/lib/omnichat/text.mjs +315 -0
- package/tools/lib/omnichat/webhook.mjs +166 -0
- package/tools/lib/pairing.mjs +99 -0
- package/tools/lib/paths.mjs +41 -0
- package/tools/lib/platforms/instagram.mjs +469 -0
- package/tools/lib/platforms/tiktok.mjs +343 -0
- package/tools/lib/platforms/youtube.mjs +228 -0
- package/tools/lib/publish/publish.mjs +244 -0
- package/tools/lib/schedule/schedule.mjs +191 -0
- package/tools/lib/service.mjs +134 -0
- package/tools/lib/skill-client.mjs +126 -0
- package/tools/lib/skills-release.mjs +196 -0
- package/tools/lib/testing.mjs +52 -0
- package/tools/lib/up.mjs +187 -0
- package/tools/metrics.mjs +415 -0
- package/tools/models.mjs +134 -0
- package/tools/narrate.mjs +257 -0
- package/tools/omni.mjs +298 -0
- package/tools/omni_paths.py +12 -0
- package/tools/omnichat.mjs +1577 -0
- package/tools/omnivideo.py +1122 -0
- package/tools/package.mjs +130 -0
- package/tools/platforms.mjs +236 -0
- package/tools/premiere.mjs +533 -0
- package/tools/publish.mjs +1496 -0
- package/tools/reference.mjs +1408 -0
- package/tools/render.mjs +426 -0
- package/tools/runner.mjs +156 -0
- package/tools/setup.mjs +466 -0
- package/tools/skills-release.mjs +93 -0
- package/tools/sound.mjs +1323 -0
- package/tools/soundtrack.mjs +217 -0
- package/tools/thumbnail.mjs +271 -0
- package/tools/timing.mjs +108 -0
- package/tools/usage.py +628 -0
- package/tools/voice-envelope.mjs +185 -0
- package/tools/voice.py +448 -0
- package/tools/voice_sample.py +75 -0
- package/tools/wireframe.mjs +230 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/* The "Sem DM" panel's state (MissingDmsPanel): the list read from the post, the checked
|
|
2
|
+
comments, the send mode and text, the batch confirmation and the focused comment. */
|
|
3
|
+
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { send as request, type ActionResult } from "../lib/api";
|
|
6
|
+
import { ruleApi, type RuleTargetRef } from "../lib/omnichat-api";
|
|
7
|
+
import {
|
|
8
|
+
askingItems,
|
|
9
|
+
missingBeforeSend,
|
|
10
|
+
replyTarget,
|
|
11
|
+
replyText,
|
|
12
|
+
type SendMode,
|
|
13
|
+
sendActionLabel,
|
|
14
|
+
} from "../lib/missing-dms";
|
|
15
|
+
import type { ManualSend, MissingDmList } from "../types/api";
|
|
16
|
+
import { PAGE_SIZE } from "../components/RuleLog";
|
|
17
|
+
|
|
18
|
+
type SendResult = NonNullable<ActionResult> & { results?: ManualSend[] };
|
|
19
|
+
|
|
20
|
+
export function useMissingDms({
|
|
21
|
+
target,
|
|
22
|
+
noRule,
|
|
23
|
+
hasPublicReplies,
|
|
24
|
+
onSend,
|
|
25
|
+
}: {
|
|
26
|
+
target: RuleTargetRef;
|
|
27
|
+
noRule: boolean;
|
|
28
|
+
hasPublicReplies: boolean;
|
|
29
|
+
onSend: () => void;
|
|
30
|
+
}) {
|
|
31
|
+
const [list, setList] = useState<MissingDmList | null>(null);
|
|
32
|
+
const [checked, setChecked] = useState<Set<string>>(new Set());
|
|
33
|
+
const [mode, setMode] = useState<SendMode>(hasPublicReplies ? "both" : "dm");
|
|
34
|
+
const [text, setText] = useState("");
|
|
35
|
+
const [confirm, setConfirm] = useState(false);
|
|
36
|
+
const [busy, setBusy] = useState<"fetch" | "send" | "delete" | null>(null);
|
|
37
|
+
const [result, setResult] = useState<SendResult | null>(null);
|
|
38
|
+
const [showAll, setShowAll] = useState(false);
|
|
39
|
+
/* the focused comment (Responder on the row), its text and whether the rule's DM goes too */
|
|
40
|
+
const [focus, setFocus] = useState<string | null>(null);
|
|
41
|
+
const [focusText, setFocusText] = useState("");
|
|
42
|
+
const [focusDm, setFocusDm] = useState(false);
|
|
43
|
+
/* the feed: every comment or only the ones without the DM; the comment waiting for the second click on Apagar */
|
|
44
|
+
const [filter, setFilter] = useState<"all" | "nodm">("nodm");
|
|
45
|
+
const [askDelete, setAskDelete] = useState<string | null>(null);
|
|
46
|
+
|
|
47
|
+
const commentOnly = mode === "comment";
|
|
48
|
+
|
|
49
|
+
/* the list read, or why not (Omni reads what it returns: lib/omni-ui omnichat_comments) */
|
|
50
|
+
const fetchList = async (clear = true): Promise<{ list: MissingDmList } | { error: string }> => {
|
|
51
|
+
setBusy("fetch");
|
|
52
|
+
if (clear) setResult(null);
|
|
53
|
+
setConfirm(false);
|
|
54
|
+
const r = await request(ruleApi(target).comments());
|
|
55
|
+
setBusy(null);
|
|
56
|
+
if (!r.ok || !r.list) {
|
|
57
|
+
setResult(r);
|
|
58
|
+
return { error: (!r.ok && r.error) || "não deu para ler os comentários" };
|
|
59
|
+
}
|
|
60
|
+
const l = r.list;
|
|
61
|
+
setList(l);
|
|
62
|
+
setChecked(m => new Set([...m].filter(id => l.items.some(i => i.id === id && (commentOnly || i.within_deadline)))));
|
|
63
|
+
/* the comment being answered or deleted left the post */
|
|
64
|
+
setFocus(f => (f && replyTarget(l.thread, f) ? f : null));
|
|
65
|
+
setAskDelete(d => (d && replyTarget(l.thread, d) ? d : null));
|
|
66
|
+
return { list: l };
|
|
67
|
+
};
|
|
68
|
+
const openFocus = (id: string) => {
|
|
69
|
+
setFocus(id);
|
|
70
|
+
setAskDelete(null);
|
|
71
|
+
setFocusText("");
|
|
72
|
+
setFocusDm(false);
|
|
73
|
+
setConfirm(false);
|
|
74
|
+
setResult(null);
|
|
75
|
+
};
|
|
76
|
+
const replyFocus = async () => {
|
|
77
|
+
const to = replyTarget(list?.thread, focus);
|
|
78
|
+
if (!to) return;
|
|
79
|
+
setBusy("send");
|
|
80
|
+
setResult(null);
|
|
81
|
+
/* the DM is the comment's: a reply to a reply is only ever a comment */
|
|
82
|
+
const r = await request(
|
|
83
|
+
ruleApi(target).send({
|
|
84
|
+
ids: [to.parentId],
|
|
85
|
+
public_reply: true,
|
|
86
|
+
public_reply_only: to.nested || !focusDm,
|
|
87
|
+
text: replyText(to, focusText.trim()),
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
setBusy(null);
|
|
91
|
+
setResult(r);
|
|
92
|
+
/* what did not go stays focused, with its text, to try again */
|
|
93
|
+
if (r.ok && !r.results?.some(x => x.state !== "done")) {
|
|
94
|
+
setFocus(null);
|
|
95
|
+
setFocusText("");
|
|
96
|
+
}
|
|
97
|
+
if (r.ok) {
|
|
98
|
+
onSend();
|
|
99
|
+
await fetchList(false);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
/* Apagar: the first click only asks (askDelete); the second deletes on Instagram, with no way back */
|
|
103
|
+
const remove = async (id: string) => {
|
|
104
|
+
setBusy("delete");
|
|
105
|
+
setResult(null);
|
|
106
|
+
const r = await request(ruleApi(target).remove([id]));
|
|
107
|
+
setBusy(null);
|
|
108
|
+
setAskDelete(null);
|
|
109
|
+
setResult(r);
|
|
110
|
+
if (r.ok) {
|
|
111
|
+
setChecked(m => new Set([...m].filter(x => x !== id)));
|
|
112
|
+
setFocus(f => (f === id ? null : f));
|
|
113
|
+
onSend();
|
|
114
|
+
await fetchList(false);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const send = async () => {
|
|
118
|
+
setBusy("send");
|
|
119
|
+
setResult(null);
|
|
120
|
+
const r = await request(
|
|
121
|
+
ruleApi(target).send({
|
|
122
|
+
ids: [...checked],
|
|
123
|
+
public_reply: mode !== "dm",
|
|
124
|
+
public_reply_only: commentOnly,
|
|
125
|
+
text: mode === "dm" ? "" : text.trim(),
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
128
|
+
setBusy(null);
|
|
129
|
+
setConfirm(false);
|
|
130
|
+
setResult(r);
|
|
131
|
+
if (r.ok) {
|
|
132
|
+
setChecked(new Set());
|
|
133
|
+
setText("");
|
|
134
|
+
onSend();
|
|
135
|
+
await fetchList(false);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const check = (id: string, yes: boolean) => {
|
|
139
|
+
setChecked(m => {
|
|
140
|
+
const n = new Set(m);
|
|
141
|
+
yes ? n.add(id) : n.delete(id);
|
|
142
|
+
return n;
|
|
143
|
+
});
|
|
144
|
+
setConfirm(false);
|
|
145
|
+
};
|
|
146
|
+
/* without DM there is no deadline; back to the DM, who passed 7 days leaves the selection */
|
|
147
|
+
const changeMode = (m: SendMode) => {
|
|
148
|
+
setMode(m);
|
|
149
|
+
setConfirm(false);
|
|
150
|
+
if (m !== "comment")
|
|
151
|
+
setChecked(s => new Set([...s].filter(id => list?.items.some(i => i.id === id && i.within_deadline))));
|
|
152
|
+
};
|
|
153
|
+
const written = text.trim();
|
|
154
|
+
const asking = askingItems(list?.items, commentOnly);
|
|
155
|
+
const replying = replyTarget(list?.thread, focus);
|
|
156
|
+
/* what the feed lists: the whole post, or the comments without the DM (the ones the batch can pick) */
|
|
157
|
+
const without = new Set(list?.items.map(i => i.id));
|
|
158
|
+
const feedAll = (list?.thread ?? []).filter(c => filter === "all" || without.has(c.id));
|
|
159
|
+
const feed = showAll ? feedAll : feedAll.slice(0, PAGE_SIZE);
|
|
160
|
+
const focusWritten = focusText.trim();
|
|
161
|
+
const n = checked.size;
|
|
162
|
+
const missing = missingBeforeSend({ n, commentOnly, written, noRule });
|
|
163
|
+
const action = sendActionLabel(commentOnly, n);
|
|
164
|
+
const problems = result?.results?.filter(x => x.state !== "done") ?? [];
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
list,
|
|
168
|
+
checked,
|
|
169
|
+
setChecked,
|
|
170
|
+
mode,
|
|
171
|
+
text,
|
|
172
|
+
setText,
|
|
173
|
+
confirm,
|
|
174
|
+
setConfirm,
|
|
175
|
+
busy,
|
|
176
|
+
result,
|
|
177
|
+
showAll,
|
|
178
|
+
setShowAll,
|
|
179
|
+
focus,
|
|
180
|
+
setFocus,
|
|
181
|
+
focusText,
|
|
182
|
+
setFocusText,
|
|
183
|
+
focusDm,
|
|
184
|
+
setFocusDm,
|
|
185
|
+
commentOnly,
|
|
186
|
+
fetchList,
|
|
187
|
+
openFocus,
|
|
188
|
+
replyFocus,
|
|
189
|
+
send,
|
|
190
|
+
check,
|
|
191
|
+
changeMode,
|
|
192
|
+
written,
|
|
193
|
+
asking,
|
|
194
|
+
replying,
|
|
195
|
+
filter,
|
|
196
|
+
setFilter,
|
|
197
|
+
askDelete,
|
|
198
|
+
setAskDelete,
|
|
199
|
+
remove,
|
|
200
|
+
without,
|
|
201
|
+
feedAll,
|
|
202
|
+
feed,
|
|
203
|
+
focusWritten,
|
|
204
|
+
n,
|
|
205
|
+
missing,
|
|
206
|
+
action,
|
|
207
|
+
problems,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export type MissingDms = ReturnType<typeof useMissingDms>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* The required getting-started steps still missing (null while checking); a new `key` checks
|
|
2
|
+
again. The menu hides "Primeiros passos" when none is missing, and the overview says what is. */
|
|
3
|
+
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { api } from "../lib/api";
|
|
6
|
+
import { invalidate, queryKeys } from "../lib/query-client";
|
|
7
|
+
import type { Onboarding } from "../types/api";
|
|
8
|
+
import { useLiveQuery } from "./useLiveQuery";
|
|
9
|
+
|
|
10
|
+
export function useMissingSetupSteps(key?: string): string[] | null {
|
|
11
|
+
const { data: onboarding, error } = useLiveQuery(queryKeys.onboarding, () => api.onboarding.$get({ query: {} }));
|
|
12
|
+
const data: Onboarding | null = onboarding;
|
|
13
|
+
const first = useRef(true);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (first.current) {
|
|
16
|
+
first.current = false;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
void invalidate(queryKeys.onboarding);
|
|
20
|
+
}, [key]);
|
|
21
|
+
if (error) return [];
|
|
22
|
+
if (!data) return null;
|
|
23
|
+
return data.checked
|
|
24
|
+
? data.steps.filter(s => !s.optional && s.state === "missing").map(s => s.title.replace(/^\d+\.\s*/, ""))
|
|
25
|
+
: [];
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
/* a clock for elapsed times that tick on screen */
|
|
4
|
+
export function useNow(ms = 1000) {
|
|
5
|
+
const [now, setNow] = useState(Date.now());
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const t = setInterval(() => setNow(Date.now()), ms);
|
|
8
|
+
return () => clearInterval(t);
|
|
9
|
+
}, [ms]);
|
|
10
|
+
return now;
|
|
11
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/* Omni's page state: the config, voices and measurements (GET /api/agent) and the live conversation:
|
|
2
|
+
Grok Voice (lib/omni-realtime) or the cascade, STT → LLM → Fish (lib/omni-cascade), picked per
|
|
3
|
+
conversation. One conversation at a time; leaving the page hangs up.
|
|
4
|
+
|
|
5
|
+
The conversation is saved as it goes (api/services/agent-history.ts keeps it only once it had a
|
|
6
|
+
genuine request) under its own id, which a continued conversation keeps: the Omni panel's
|
|
7
|
+
Conversas reopens it and `start(mode, earlier)` goes on from where it stopped. */
|
|
8
|
+
|
|
9
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
10
|
+
import { api, enc, send } from "../lib/api";
|
|
11
|
+
import { invalidate, queryKeys } from "../lib/query-client";
|
|
12
|
+
import { OmniConversation, type OmniEntry, type OmniStatus } from "../lib/omni-realtime";
|
|
13
|
+
import { type CascadeMode, OmniCascade } from "../lib/omni-cascade";
|
|
14
|
+
import { openScreen, refreshMissingDms } from "../lib/omni-ui";
|
|
15
|
+
import type { AgentInfo, AgentPendingAction, AgentResolvedAction } from "../types/api";
|
|
16
|
+
import type { NavigateArgs } from "../../shared/omni-screens";
|
|
17
|
+
import type { Conversation, ConversationAction } from "../../shared/schemas/agent-history";
|
|
18
|
+
import { useLiveQuery } from "./useLiveQuery";
|
|
19
|
+
|
|
20
|
+
export function useAgentInfo() {
|
|
21
|
+
const { data, error, reload } = useLiveQuery(queryKeys.agent, () => api.agent.$get());
|
|
22
|
+
const info: AgentInfo | null = data;
|
|
23
|
+
return { info, error, reload };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* grok: Grok Voice, billed per open minute; stream / chunks: the cascade, billed per speech */
|
|
27
|
+
export type OmniMode = "grok" | CascadeMode;
|
|
28
|
+
|
|
29
|
+
/* a saved conversation, as the Conversas list opens it */
|
|
30
|
+
export type OmniConversationRecord = Conversation;
|
|
31
|
+
|
|
32
|
+
const newConversationId = () =>
|
|
33
|
+
`${new Date().toISOString().slice(0, 19).replace(/[-:T]/g, "")}-${crypto.randomUUID().slice(0, 6)}`;
|
|
34
|
+
|
|
35
|
+
/* opens the screen of an action (best effort: the card and the voice already said what happens) */
|
|
36
|
+
const show = (open: NavigateArgs | null | undefined) => {
|
|
37
|
+
if (open) void openScreen(open);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/* what the screen does once a card went: the "Sem DM" list drops the ones that got the send */
|
|
41
|
+
const afterConfirm = (a: { kind: string; slug?: string | null; payload?: Record<string, unknown> }) => {
|
|
42
|
+
if (a.kind === "omnichat_send" && a.slug)
|
|
43
|
+
void refreshMissingDms(a.slug, a.payload?.content === "carousel" ? "carousel" : "video");
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/* while a call is live, its record is saved this long after the last change */
|
|
47
|
+
const SAVE_DEBOUNCE_MS = 3000;
|
|
48
|
+
|
|
49
|
+
export function useOmniConversation(opts: { onQuota?: () => void } = {}) {
|
|
50
|
+
const onQuota = useRef(opts.onQuota);
|
|
51
|
+
onQuota.current = opts.onQuota;
|
|
52
|
+
const [status, setStatus] = useState<OmniStatus>("idle");
|
|
53
|
+
const [entries, setEntries] = useState<OmniEntry[]>([]);
|
|
54
|
+
const [pending, setPending] = useState<AgentPendingAction[]>([]);
|
|
55
|
+
/* read when the call ends, from a callback made before the cards arrived */
|
|
56
|
+
const pendingNow = useRef<AgentPendingAction[]>([]);
|
|
57
|
+
pendingNow.current = pending;
|
|
58
|
+
const [error, setError] = useState<string | null>(null);
|
|
59
|
+
const [muted, setMutedState] = useState(false);
|
|
60
|
+
const [startedAt, setStartedAt] = useState<number | null>(null);
|
|
61
|
+
const [mode, setMode] = useState<OmniMode>("grok");
|
|
62
|
+
const conv = useRef<OmniConversation | OmniCascade | null>(null);
|
|
63
|
+
/* the analyser of the reply audio, for the avatar (useAvatarAudioReactive reads .current) */
|
|
64
|
+
const analyser = useRef<AnalyserNode | null>(null);
|
|
65
|
+
/* the user's microphone, for the avatar while Omni listens */
|
|
66
|
+
const micAnalyser = useRef<AnalyserNode | null>(null);
|
|
67
|
+
/* the record being saved: its id, when it began, the voice sessions it used and each card's fate */
|
|
68
|
+
const record = useRef<{
|
|
69
|
+
id: string;
|
|
70
|
+
mode: OmniMode;
|
|
71
|
+
started_at: string;
|
|
72
|
+
sessions: Set<string>;
|
|
73
|
+
actions: Map<string, ConversationAction>;
|
|
74
|
+
} | null>(null);
|
|
75
|
+
/* the transcript as the class last reported it (the state lags a render behind) */
|
|
76
|
+
const entriesNow = useRef<OmniEntry[]>([]);
|
|
77
|
+
const saveTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
78
|
+
|
|
79
|
+
const save = useCallback(() => {
|
|
80
|
+
if (saveTimer.current) clearTimeout(saveTimer.current);
|
|
81
|
+
saveTimer.current = null;
|
|
82
|
+
const r = record.current;
|
|
83
|
+
if (!r) return;
|
|
84
|
+
const sid = conv.current?.sessionId;
|
|
85
|
+
if (sid) r.sessions.add(sid);
|
|
86
|
+
void send(
|
|
87
|
+
api.agent.conversations[":id"].$post({
|
|
88
|
+
param: { id: enc(r.id) },
|
|
89
|
+
json: {
|
|
90
|
+
mode: r.mode,
|
|
91
|
+
sessions: [...r.sessions],
|
|
92
|
+
entries: entriesNow.current,
|
|
93
|
+
actions: [...r.actions.values()],
|
|
94
|
+
started_at: r.started_at,
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
);
|
|
98
|
+
}, []);
|
|
99
|
+
const saveSoon = useCallback(() => {
|
|
100
|
+
if (saveTimer.current) clearTimeout(saveTimer.current);
|
|
101
|
+
saveTimer.current = setTimeout(save, SAVE_DEBOUNCE_MS);
|
|
102
|
+
}, [save]);
|
|
103
|
+
const track = (
|
|
104
|
+
a: { id: string; kind: string; slug?: string | null; summary: string },
|
|
105
|
+
state: ConversationAction["state"],
|
|
106
|
+
) => {
|
|
107
|
+
record.current?.actions.set(a.id, {
|
|
108
|
+
id: a.id,
|
|
109
|
+
kind: a.kind,
|
|
110
|
+
slug: a.slug ?? null,
|
|
111
|
+
summary: a.summary,
|
|
112
|
+
state,
|
|
113
|
+
at: new Date().toISOString(),
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/* `earlier`: a saved conversation to continue (its transcript and cards come back, same record).
|
|
118
|
+
`opts`: a call the panel opened by itself (OmniWidget) says the recorded greeting through the call
|
|
119
|
+
(greet: the voice's gender), and goes without the engine's own silence handling until the user
|
|
120
|
+
speaks (holdIdle) */
|
|
121
|
+
const start = useCallback(
|
|
122
|
+
async (
|
|
123
|
+
mode: OmniMode = "grok",
|
|
124
|
+
earlier?: OmniConversationRecord,
|
|
125
|
+
opts: { greet?: string; holdIdle?: boolean } = {},
|
|
126
|
+
) => {
|
|
127
|
+
conv.current?.stop();
|
|
128
|
+
setError(null);
|
|
129
|
+
const history: OmniEntry[] = earlier
|
|
130
|
+
? [
|
|
131
|
+
...(earlier.entries as OmniEntry[]),
|
|
132
|
+
{
|
|
133
|
+
kind: "note",
|
|
134
|
+
id: `continue-${Date.now()}`,
|
|
135
|
+
text: `Continuando a conversa de ${new Date(earlier.updated_at).toLocaleString("pt-BR", { dateStyle: "short", timeStyle: "short" })}.`,
|
|
136
|
+
},
|
|
137
|
+
]
|
|
138
|
+
: [];
|
|
139
|
+
record.current = {
|
|
140
|
+
id: earlier?.id ?? newConversationId(),
|
|
141
|
+
mode,
|
|
142
|
+
started_at: earlier?.started_at ?? new Date().toISOString(),
|
|
143
|
+
sessions: new Set(earlier?.sessions ?? []),
|
|
144
|
+
actions: new Map((earlier?.actions ?? []).map(a => [a.id, a])),
|
|
145
|
+
};
|
|
146
|
+
entriesNow.current = history;
|
|
147
|
+
setEntries(history);
|
|
148
|
+
setPending([]);
|
|
149
|
+
setMutedState(false);
|
|
150
|
+
const callbacks = {
|
|
151
|
+
onStatus: (s: OmniStatus) => {
|
|
152
|
+
setStatus(s);
|
|
153
|
+
if (s === "idle" || s === "error") {
|
|
154
|
+
setStartedAt(null);
|
|
155
|
+
/* hanging up cancels what still waits for Confirmar, and the cards leave the screen (the
|
|
156
|
+
server does the same when the call's end arrives, also if this tab closes) */
|
|
157
|
+
for (const a of pendingNow.current) {
|
|
158
|
+
void send(api.agent.actions[":id"].cancel.$post({ param: { id: enc(a.id) }, json: {} }));
|
|
159
|
+
track(a, "canceled");
|
|
160
|
+
}
|
|
161
|
+
setPending([]);
|
|
162
|
+
save();
|
|
163
|
+
/* the measurements include the conversation that just ended (also the idle hang-up) */
|
|
164
|
+
void invalidate(queryKeys.agent);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
onEntries: (e: OmniEntry[]) => {
|
|
168
|
+
entriesNow.current = e;
|
|
169
|
+
setEntries(e);
|
|
170
|
+
saveSoon();
|
|
171
|
+
},
|
|
172
|
+
/* a corrected request comes with the cards it replaced: they leave the screen */
|
|
173
|
+
onPending: (a: AgentPendingAction) => {
|
|
174
|
+
for (const id of a.replaces ?? []) {
|
|
175
|
+
const old = record.current?.actions.get(id);
|
|
176
|
+
if (old) track(old, "canceled");
|
|
177
|
+
}
|
|
178
|
+
track(a, "staged");
|
|
179
|
+
saveSoon();
|
|
180
|
+
setPending(p => [...p.filter(x => x.id !== a.id && !a.replaces?.includes(x.id)), a]);
|
|
181
|
+
/* the screen follows the request: the thumbnails, the publication, the content's Omnichat screen… */
|
|
182
|
+
show(a.open);
|
|
183
|
+
},
|
|
184
|
+
/* the user said yes or no out loud and Omni pressed the card's button (confirm_action) */
|
|
185
|
+
onResolved: (r: AgentResolvedAction) => {
|
|
186
|
+
const a = pendingNow.current.find(x => x.id === r.id) ?? r;
|
|
187
|
+
track(a, r.state);
|
|
188
|
+
saveSoon();
|
|
189
|
+
/* a failed publish stays, to be retried, like after the screen's Confirmar */
|
|
190
|
+
if (r.state !== "failed") setPending(p => p.filter(x => x.id !== r.id));
|
|
191
|
+
show(r.open);
|
|
192
|
+
if (r.state === "confirmed") afterConfirm(a);
|
|
193
|
+
},
|
|
194
|
+
onError: setError,
|
|
195
|
+
onQuota: () => {
|
|
196
|
+
void invalidate(queryKeys.agent);
|
|
197
|
+
onQuota.current?.();
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
setMode(mode);
|
|
201
|
+
const c = mode === "grok" ? new OmniConversation(callbacks, history) : new OmniCascade(callbacks, mode, history);
|
|
202
|
+
conv.current = c;
|
|
203
|
+
analyser.current = c.analyser;
|
|
204
|
+
micAnalyser.current = c.micAnalyser;
|
|
205
|
+
if (opts.holdIdle) c.holdIdle(true);
|
|
206
|
+
const started = c.start();
|
|
207
|
+
if (opts.greet) void c.greet(opts.greet);
|
|
208
|
+
await started;
|
|
209
|
+
if (conv.current === c && c.sessionId) setStartedAt(Date.now());
|
|
210
|
+
},
|
|
211
|
+
[],
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
const stop = useCallback(() => {
|
|
215
|
+
conv.current?.stop();
|
|
216
|
+
conv.current = null;
|
|
217
|
+
}, []);
|
|
218
|
+
|
|
219
|
+
/* the call the panel opened by itself, ended because nobody spoke: it leaves nothing on screen */
|
|
220
|
+
const discard = useCallback(() => {
|
|
221
|
+
conv.current?.stop("idle");
|
|
222
|
+
conv.current = null;
|
|
223
|
+
entriesNow.current = [];
|
|
224
|
+
setEntries([]);
|
|
225
|
+
setError(null);
|
|
226
|
+
}, []);
|
|
227
|
+
|
|
228
|
+
const holdIdle = useCallback((hold: boolean) => conv.current?.holdIdle(hold), []);
|
|
229
|
+
|
|
230
|
+
const setMuted = useCallback((m: boolean) => {
|
|
231
|
+
conv.current?.setMuted(m);
|
|
232
|
+
setMutedState(m);
|
|
233
|
+
}, []);
|
|
234
|
+
|
|
235
|
+
const resolve = useCallback(async (action: AgentPendingAction, confirm: boolean) => {
|
|
236
|
+
const c = conv.current;
|
|
237
|
+
/* the card belongs to a live conversation (hanging up cancels it); without one, straight to the API */
|
|
238
|
+
const r = c
|
|
239
|
+
? confirm
|
|
240
|
+
? await c.confirm(action)
|
|
241
|
+
: (await c.cancel(action), { ok: true })
|
|
242
|
+
: await send(
|
|
243
|
+
confirm
|
|
244
|
+
? api.agent.actions[":id"].confirm.$post({ param: { id: enc(action.id) }, json: {} })
|
|
245
|
+
: api.agent.actions[":id"].cancel.$post({ param: { id: enc(action.id) }, json: {} }),
|
|
246
|
+
);
|
|
247
|
+
track(action, !confirm ? "canceled" : r.ok ? "confirmed" : "failed");
|
|
248
|
+
saveSoon();
|
|
249
|
+
if (r.ok) setPending(p => p.filter(x => x.id !== action.id));
|
|
250
|
+
if (r.ok && confirm) {
|
|
251
|
+
show((r as { open?: NavigateArgs | null }).open);
|
|
252
|
+
afterConfirm(action);
|
|
253
|
+
}
|
|
254
|
+
return r;
|
|
255
|
+
}, []);
|
|
256
|
+
|
|
257
|
+
useEffect(() => () => conv.current?.stop("left"), []);
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
status,
|
|
261
|
+
entries,
|
|
262
|
+
pending,
|
|
263
|
+
error,
|
|
264
|
+
muted,
|
|
265
|
+
startedAt,
|
|
266
|
+
mode,
|
|
267
|
+
analyser,
|
|
268
|
+
micAnalyser,
|
|
269
|
+
start,
|
|
270
|
+
stop,
|
|
271
|
+
setMuted,
|
|
272
|
+
discard,
|
|
273
|
+
holdIdle,
|
|
274
|
+
sendText: (t: string) => conv.current?.sendText(t),
|
|
275
|
+
feedback: (item: string, v: "up" | "down" | null) => conv.current?.feedback(item, v),
|
|
276
|
+
resolve,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* Omni in Claude mode (after the day's voice quota): the user speaks (or types), the speech is
|
|
2
|
+
transcribed (/api/agent/stt) and goes to the user's own Claude (/api/agent/claude, a studio
|
|
3
|
+
session of type "omni"); the answer comes back as text in the widget. */
|
|
4
|
+
|
|
5
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
6
|
+
import { api, enc, read, send } from "../lib/api";
|
|
7
|
+
import type { OmniEntry } from "../lib/omni-realtime";
|
|
8
|
+
import { PcmRecorder, pcmToBase64 } from "../lib/pcm-recorder";
|
|
9
|
+
|
|
10
|
+
export type ClaudeStatus = "idle" | "recording" | "transcribing" | "thinking";
|
|
11
|
+
|
|
12
|
+
const POLL_MS = 1500;
|
|
13
|
+
|
|
14
|
+
/* the panel shows plain text: markdown marks Claude may still use are dropped */
|
|
15
|
+
const plain = (text: string | null) =>
|
|
16
|
+
(text ?? "")
|
|
17
|
+
.replace(/\*\*|__|`/g, "")
|
|
18
|
+
.replace(/^#+\s*/gm, "")
|
|
19
|
+
.trim();
|
|
20
|
+
const MAX_WAIT_MS = 5 * 60_000;
|
|
21
|
+
|
|
22
|
+
export function useOmniClaude() {
|
|
23
|
+
const [status, setStatus] = useState<ClaudeStatus>("idle");
|
|
24
|
+
const [entries, setEntries] = useState<OmniEntry[]>([]);
|
|
25
|
+
const [error, setError] = useState<string | null>(null);
|
|
26
|
+
const recorder = useRef<PcmRecorder | null>(null);
|
|
27
|
+
const session = useRef<string | null>(null);
|
|
28
|
+
const analyser = useRef<AnalyserNode | null>(null);
|
|
29
|
+
const alive = useRef(true);
|
|
30
|
+
useEffect(
|
|
31
|
+
() => () => {
|
|
32
|
+
alive.current = false;
|
|
33
|
+
recorder.current?.cancel();
|
|
34
|
+
},
|
|
35
|
+
[],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const push = useCallback((e: OmniEntry) => setEntries(list => [...list, e]), []);
|
|
39
|
+
|
|
40
|
+
const ask = useCallback(
|
|
41
|
+
async (text: string) => {
|
|
42
|
+
push({ kind: "user", id: `u-${Date.now()}`, text, pending: false });
|
|
43
|
+
setStatus("thinking");
|
|
44
|
+
const t0 = performance.now();
|
|
45
|
+
const r = await send(api.agent.claude.$post({ json: { message: text } }));
|
|
46
|
+
if (!r.ok || !r.session) {
|
|
47
|
+
setError(r.error ?? "não deu para falar com o Claude");
|
|
48
|
+
setStatus("idle");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
session.current = r.session;
|
|
52
|
+
const id = r.session;
|
|
53
|
+
while (alive.current && performance.now() - t0 < MAX_WAIT_MS) {
|
|
54
|
+
await new Promise(res => setTimeout(res, POLL_MS));
|
|
55
|
+
const s = await read(api.agent.claude[":id"].$get({ param: { id: enc(id) } })).catch(() => null);
|
|
56
|
+
if (!s || s.state === "running") continue;
|
|
57
|
+
push({
|
|
58
|
+
kind: "assistant",
|
|
59
|
+
id: `c-${id}-${Date.now()}`,
|
|
60
|
+
text: plain(s.text) || "(o Claude terminou sem resposta em texto)",
|
|
61
|
+
latency_ms: Math.round(performance.now() - t0),
|
|
62
|
+
feedback: null,
|
|
63
|
+
});
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
if (alive.current) setStatus("idle");
|
|
67
|
+
},
|
|
68
|
+
[push],
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
/* tap: start listening; tap again (or a pause) sends */
|
|
72
|
+
const toggleRecording = useCallback(async () => {
|
|
73
|
+
if (recorder.current) return recorder.current.stop();
|
|
74
|
+
setError(null);
|
|
75
|
+
const rec = new PcmRecorder();
|
|
76
|
+
recorder.current = rec;
|
|
77
|
+
analyser.current = rec.analyser;
|
|
78
|
+
setStatus("recording");
|
|
79
|
+
try {
|
|
80
|
+
const pcm = await rec.record();
|
|
81
|
+
recorder.current = null;
|
|
82
|
+
if (!pcm) {
|
|
83
|
+
setStatus("idle");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
setStatus("transcribing");
|
|
87
|
+
const r = await send(
|
|
88
|
+
api.agent.stt.$post({ json: { session: session.current ?? "claude", audio: pcmToBase64(pcm) } }),
|
|
89
|
+
);
|
|
90
|
+
if (!r.ok || !("text" in r) || !r.text) {
|
|
91
|
+
setError(r.error ?? "não entendi o áudio");
|
|
92
|
+
setStatus("idle");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
await ask(r.text);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
recorder.current = null;
|
|
98
|
+
setError(String((e as Error)?.message ?? e));
|
|
99
|
+
setStatus("idle");
|
|
100
|
+
}
|
|
101
|
+
}, [ask]);
|
|
102
|
+
|
|
103
|
+
const sendText = useCallback(
|
|
104
|
+
(text: string) => {
|
|
105
|
+
const t = text.trim();
|
|
106
|
+
if (t) void ask(t);
|
|
107
|
+
},
|
|
108
|
+
[ask],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const feedback = useCallback((item: string, value: "up" | "down" | null) => {
|
|
112
|
+
setEntries(list => list.map(e => (e.kind === "assistant" && e.id === item ? { ...e, feedback: value } : e)));
|
|
113
|
+
const id = session.current;
|
|
114
|
+
if (id)
|
|
115
|
+
void send(
|
|
116
|
+
api.agent.sessions[":id"].log.$post({
|
|
117
|
+
param: { id: enc(id) },
|
|
118
|
+
json: { type: "feedback", item, value: value ?? "none" },
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
}, []);
|
|
122
|
+
|
|
123
|
+
return { status, entries, error, analyser, toggleRecording, sendText, feedback };
|
|
124
|
+
}
|