@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,77 @@
|
|
|
1
|
+
/* Getting started (/getting-started): the guide in docs/onboarding.md, one step per section
|
|
2
|
+
(`<!-- step: id -->`), with each step's state measured by `tools/setup.mjs
|
|
3
|
+
check --json`. The guide owns the text: the UI repeats none of it. */
|
|
4
|
+
|
|
5
|
+
import { join, resolve, sep } from "node:path";
|
|
6
|
+
import { CODE_ROOT, NODE, TOOLS_DIR, run, readText } from "./root";
|
|
7
|
+
|
|
8
|
+
export const DOCS_DIR = join(CODE_ROOT, "docs");
|
|
9
|
+
const GUIDE = join(DOCS_DIR, "onboarding.md");
|
|
10
|
+
|
|
11
|
+
type Check = { id: string; title: string; state: "ok" | "missing" | "warning"; detail: string };
|
|
12
|
+
type CheckResult = {
|
|
13
|
+
ready: boolean;
|
|
14
|
+
steps: { id: string; state: Check["state"]; optional?: boolean; items: Check[] }[];
|
|
15
|
+
};
|
|
16
|
+
export type OnboardingStep = {
|
|
17
|
+
id: string;
|
|
18
|
+
title: string;
|
|
19
|
+
markdown: string;
|
|
20
|
+
state: Check["state"] | null;
|
|
21
|
+
optional: boolean;
|
|
22
|
+
items: Check[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/* the check runs programs (bun, ffmpeg, python…): cache it briefly so the overview doesn't pay on every visit */
|
|
26
|
+
let cached: { at: number; r: CheckResult } | null = null;
|
|
27
|
+
async function runChecks(fresh: boolean): Promise<CheckResult | null> {
|
|
28
|
+
if (!fresh && cached && Date.now() - cached.at < 60_000) return cached.r;
|
|
29
|
+
const r = await run([NODE, join(TOOLS_DIR, "setup.mjs"), "check", "--json"]);
|
|
30
|
+
try {
|
|
31
|
+
cached = { at: Date.now(), r: JSON.parse(r.stdout) };
|
|
32
|
+
return cached.r;
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* an image relative to the guide (onboarding/x.png) becomes the studio's /docs/… route; a link to another
|
|
39
|
+
repo file becomes the path in code (in the studio it has nowhere to go) */
|
|
40
|
+
const withImages = (md: string) =>
|
|
41
|
+
md
|
|
42
|
+
.replace(/!\[([^\]]*)\]\((?!https?:|\/)([^)\s]+)\)/g, "")
|
|
43
|
+
.replace(/(?<!!)\[([^\]]+)\]\((?!https?:|\/|#)(?:\.\.\/)?([^)\s]+)\)/g, (_, text: string, target: string) =>
|
|
44
|
+
text.includes("`") ? text : `${text} (\`${target}\`)`,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export async function getOnboarding(fresh = false) {
|
|
48
|
+
const text = readText(GUIDE);
|
|
49
|
+
if (!text) return { error: "docs/onboarding.md não existe" };
|
|
50
|
+
const checks = await runChecks(fresh);
|
|
51
|
+
const [head, ...sections] = text.split(/<!--\s*step:\s*([\w-]+)\s*-->/);
|
|
52
|
+
/* split interleaves: id, body, id, body… */
|
|
53
|
+
const steps: OnboardingStep[] = [];
|
|
54
|
+
for (let i = 0; i < sections.length; i += 2) {
|
|
55
|
+
const id = sections[i];
|
|
56
|
+
const body = sections[i + 1].trim();
|
|
57
|
+
const m = body.match(/^##\s+(.+)\n/);
|
|
58
|
+
const c = checks?.steps.find(p => p.id === id);
|
|
59
|
+
steps.push({
|
|
60
|
+
id,
|
|
61
|
+
title: m ? m[1].trim() : id,
|
|
62
|
+
markdown: withImages(m ? body.slice(m[0].length) : body).trim(),
|
|
63
|
+
state: c?.state ?? null,
|
|
64
|
+
optional: !!c?.optional,
|
|
65
|
+
items: c?.items ?? [],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const intro = withImages(head.replace(/^#\s+.+\n/, "")).trim();
|
|
69
|
+
return { ready: checks?.ready ?? false, checked: !!checks, intro, steps };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* /docs/<path>: the guide's images */
|
|
73
|
+
export function docFile(rel: string): string | null {
|
|
74
|
+
if (!/\.(png|jpe?g|webp|gif)$/i.test(rel)) return null;
|
|
75
|
+
const abs = resolve(DOCS_DIR, rel);
|
|
76
|
+
return abs.startsWith(DOCS_DIR + sep) ? abs : null;
|
|
77
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/* Publishing from the UI: the export stage button. Writes the text to
|
|
2
|
+
publication.json and calls `publish.mjs --confirm`, the same the terminal
|
|
3
|
+
would call: it uploads, checks the limits and records the result. The accounts
|
|
4
|
+
(`status --json`) are cached for a few minutes: each read refreshes
|
|
5
|
+
tokens and asks the three platforms. */
|
|
6
|
+
|
|
7
|
+
import { writeFileSync, renameSync, statSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import type { Subprocess } from "bun";
|
|
10
|
+
import { NODE, ROOT, TOOLS_DIR, run, readJson } from "./root";
|
|
11
|
+
|
|
12
|
+
type Result = { ok: true; output: string } | { ok: false; error: string };
|
|
13
|
+
|
|
14
|
+
const PUBLISH = join(TOOLS_DIR, "publish.mjs");
|
|
15
|
+
const PLATFORMS = ["youtube", "instagram", "tiktok"];
|
|
16
|
+
const PRIVACIES = ["private", "unlisted", "public"];
|
|
17
|
+
const TIKTOK_PRIVACIES = ["SELF_ONLY", "MUTUAL_FOLLOW_FRIENDS", "FOLLOWER_OF_CREATOR", "PUBLIC_TO_EVERYONE"];
|
|
18
|
+
|
|
19
|
+
/* a login done from the terminal (`publish.mjs auth`) changes .env without going through here:
|
|
20
|
+
a .env newer than the cached read counts as a refresh */
|
|
21
|
+
const ENV_FILE = join(ROOT, ".env");
|
|
22
|
+
const envChanged = (since: number) => {
|
|
23
|
+
try {
|
|
24
|
+
return statSync(ENV_FILE).mtimeMs > since;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
let cachedAccounts: { at: number; data: unknown } | null = null;
|
|
31
|
+
export async function getAccounts(refresh = false) {
|
|
32
|
+
if (!refresh && cachedAccounts && Date.now() - cachedAccounts.at < 5 * 60_000 && !envChanged(cachedAccounts.at))
|
|
33
|
+
return cachedAccounts.data;
|
|
34
|
+
const r = await run([NODE, PUBLISH, "status", "--json"]);
|
|
35
|
+
let data: unknown;
|
|
36
|
+
try {
|
|
37
|
+
data = JSON.parse(r.stdout);
|
|
38
|
+
} catch {
|
|
39
|
+
data = { error: (r.stderr || r.stdout).trim() || `publish.mjs saiu com ${r.code}` };
|
|
40
|
+
}
|
|
41
|
+
cachedAccounts = { at: Date.now(), data };
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const forgetAccounts = () => {
|
|
46
|
+
cachedAccounts = null;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/* Connecting an account from the UI: the same `publish.mjs auth` as the terminal. Instagram's
|
|
50
|
+
gets the token generated in the Meta dashboard, through the environment (it doesn't go
|
|
51
|
+
to argv, which shows in the process list).
|
|
52
|
+
|
|
53
|
+
YouTube's and TikTok's answer as soon as the link exists (the `url:` line
|
|
54
|
+
of publish.mjs) and keep waiting for the login to come back for up to 10 min: the UI
|
|
55
|
+
shows the link to copy and asks for the end with GET
|
|
56
|
+
/api/settings/publish/connect?platform=…. `mode`: "dia" opens in Dia,
|
|
57
|
+
"link" only generates the link, any other value opens in the default browser. */
|
|
58
|
+
type Connection = {
|
|
59
|
+
state: "waiting" | "ok" | "error";
|
|
60
|
+
url: string | null;
|
|
61
|
+
output: string;
|
|
62
|
+
at: number;
|
|
63
|
+
proc: Subprocess;
|
|
64
|
+
};
|
|
65
|
+
const BROWSER_LOGIN_PLATFORMS = ["youtube", "tiktok"];
|
|
66
|
+
const connections: Record<string, Connection | null> = {};
|
|
67
|
+
|
|
68
|
+
export function connectionStatus(platform: unknown) {
|
|
69
|
+
const c = connections[BROWSER_LOGIN_PLATFORMS.includes(String(platform)) ? String(platform) : "youtube"];
|
|
70
|
+
return c ? { state: c.state, url: c.state === "waiting" ? c.url : null, output: c.output.trim(), at: c.at } : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function connectInBrowser(platform: string, mode: unknown): Promise<Result & { url?: string }> {
|
|
74
|
+
const flags = mode === "link" ? ["--no-open"] : mode === "dia" ? ["--browser", "Dia"] : [];
|
|
75
|
+
/* a new link replaces the one still waiting */
|
|
76
|
+
if (connections[platform]?.state === "waiting") connections[platform]!.proc.kill();
|
|
77
|
+
const p = Bun.spawn([NODE, PUBLISH, "auth", platform, ...flags], { cwd: ROOT, stdout: "pipe", stderr: "pipe" });
|
|
78
|
+
const c: Connection = { state: "waiting", url: null, output: "", at: Date.now(), proc: p };
|
|
79
|
+
connections[platform] = c;
|
|
80
|
+
const account = platform === "youtube" ? "a conta do canal" : "a conta do TikTok";
|
|
81
|
+
let found: (u: string | null) => void = () => {};
|
|
82
|
+
const link = new Promise<string | null>(r => {
|
|
83
|
+
found = r;
|
|
84
|
+
});
|
|
85
|
+
(async () => {
|
|
86
|
+
const dec = new TextDecoder();
|
|
87
|
+
for await (const chunk of p.stdout) {
|
|
88
|
+
c.output += dec.decode(chunk);
|
|
89
|
+
const m = /^url: (\S+)/m.exec(c.output);
|
|
90
|
+
if (m && !c.url) {
|
|
91
|
+
c.url = m[1];
|
|
92
|
+
found(m[1]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
})();
|
|
96
|
+
const stderr = new Response(p.stderr).text();
|
|
97
|
+
p.exited.then(async code => {
|
|
98
|
+
const e = (await stderr).trim();
|
|
99
|
+
if (e) c.output += `\n${e}`;
|
|
100
|
+
if (connections[platform] === c) c.state = code === 0 ? "ok" : "error";
|
|
101
|
+
cachedAccounts = null;
|
|
102
|
+
found(null);
|
|
103
|
+
});
|
|
104
|
+
const url = await Promise.race([link, Bun.sleep(8000).then(() => null)]);
|
|
105
|
+
if (!url) {
|
|
106
|
+
p.kill();
|
|
107
|
+
return { ok: false, error: c.output.replace(/^url: .*$/m, "").trim() || "o publish.mjs não gerou o link do login" };
|
|
108
|
+
}
|
|
109
|
+
const notOpened = /não abriu/.test(c.output);
|
|
110
|
+
const output =
|
|
111
|
+
mode === "link"
|
|
112
|
+
? `link gerado: abra num navegador desta máquina e escolha ${account}`
|
|
113
|
+
: notOpened
|
|
114
|
+
? `${mode === "dia" ? "o Dia" : "o navegador"} não abriu: copie o link abaixo`
|
|
115
|
+
: `login aberto ${mode === "dia" ? "no Dia" : "no navegador"}: escolha ${account}`;
|
|
116
|
+
return { ok: true, output, url };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let connecting: string | null = null;
|
|
120
|
+
export async function connectPlatform(
|
|
121
|
+
platform: unknown,
|
|
122
|
+
token: unknown,
|
|
123
|
+
mode?: unknown,
|
|
124
|
+
): Promise<Result & { url?: string }> {
|
|
125
|
+
if (BROWSER_LOGIN_PLATFORMS.includes(String(platform))) return connectInBrowser(String(platform), mode);
|
|
126
|
+
if (platform !== "instagram") return { ok: false, error: `plataforma desconhecida: ${platform}` };
|
|
127
|
+
if (connecting) return { ok: false, error: `já tem uma conexão em andamento (${connecting})` };
|
|
128
|
+
let env: Record<string, string> = {};
|
|
129
|
+
if (platform === "instagram") {
|
|
130
|
+
const t = typeof token === "string" ? token.trim() : "";
|
|
131
|
+
if (!/^[\w.-]{20,}$/.test(t))
|
|
132
|
+
return { ok: false, error: "cole o token gerado em Instagram → API setup → Generate access tokens" };
|
|
133
|
+
env = { OMNIVIDEO_IG_TOKEN: t };
|
|
134
|
+
}
|
|
135
|
+
connecting = platform;
|
|
136
|
+
try {
|
|
137
|
+
const r = await run([NODE, PUBLISH, "auth", platform], env);
|
|
138
|
+
cachedAccounts = null;
|
|
139
|
+
const output = [r.stdout, r.stderr]
|
|
140
|
+
.map(s => s.trim())
|
|
141
|
+
.filter(Boolean)
|
|
142
|
+
.join("\n");
|
|
143
|
+
return r.code === 0
|
|
144
|
+
? { ok: true, output: output.split("\n").pop() ?? "conectado" }
|
|
145
|
+
: { ok: false, error: output || `publish.mjs saiu com ${r.code}` };
|
|
146
|
+
} finally {
|
|
147
|
+
connecting = null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* one video publishing at a time: two clicks don't upload twice */
|
|
152
|
+
const publishing = new Set<string>();
|
|
153
|
+
|
|
154
|
+
/* Title, description, caption and tags from the script (`publish.mjs text`):
|
|
155
|
+
Claude writes them, and without it they come from the script itself. Without `redo`, only what
|
|
156
|
+
is empty in publication.json. */
|
|
157
|
+
const writing = new Set<string>();
|
|
158
|
+
|
|
159
|
+
export async function generatePublishText(dir: string, redo: boolean): Promise<Result & { text?: unknown }> {
|
|
160
|
+
if (writing.has(dir)) return { ok: false, error: "o texto deste vídeo já está sendo escrito" };
|
|
161
|
+
writing.add(dir);
|
|
162
|
+
try {
|
|
163
|
+
const r = await run([NODE, PUBLISH, "text", dir, "--json", ...(redo ? ["--redo"] : [])]);
|
|
164
|
+
if (r.code !== 0) return { ok: false, error: (r.stderr || r.stdout).trim() || `publish.mjs saiu com ${r.code}` };
|
|
165
|
+
const t = JSON.parse(r.stdout.trim().split("\n").pop()!);
|
|
166
|
+
const output =
|
|
167
|
+
t.warning ??
|
|
168
|
+
(t.by === "claude"
|
|
169
|
+
? "texto escrito pelo Claude a partir do roteiro"
|
|
170
|
+
: t.by
|
|
171
|
+
? "texto tirado do roteiro"
|
|
172
|
+
: "o texto já estava escrito");
|
|
173
|
+
return { ok: true, output, text: t };
|
|
174
|
+
} catch (e: any) {
|
|
175
|
+
return { ok: false, error: `não deu para ler o texto: ${e.message}` };
|
|
176
|
+
} finally {
|
|
177
|
+
writing.delete(dir);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* the UI request (where, privacy, again) as publish.mjs flags; writes the text
|
|
182
|
+
to publication.json, which stays even if publishing fails (the caption counts for Instagram and TikTok) */
|
|
183
|
+
function publishFlags(dir: string, body: any): { flags: string[] } | { error: string } {
|
|
184
|
+
const platforms = PLATFORMS.filter(p => body?.[p] === true);
|
|
185
|
+
if (!platforms.length) return { error: "escolha ao menos uma plataforma" };
|
|
186
|
+
const privacy = String(body?.privacy ?? "public");
|
|
187
|
+
if (!PRIVACIES.includes(privacy)) return { error: `privacidade desconhecida: ${privacy}` };
|
|
188
|
+
const tiktokPrivacy = String(body?.tiktok_privacy ?? "PUBLIC_TO_EVERYONE");
|
|
189
|
+
if (!TIKTOK_PRIVACIES.includes(tiktokPrivacy))
|
|
190
|
+
return { error: `privacidade do TikTok desconhecida: ${tiktokPrivacy}` };
|
|
191
|
+
|
|
192
|
+
const file = join(dir, "publication.json");
|
|
193
|
+
const pub = readJson<Record<string, unknown>>(file) ?? {};
|
|
194
|
+
for (const k of ["title", "description", "caption"]) {
|
|
195
|
+
if (typeof body?.[k] === "string") pub[k] = body[k].trim();
|
|
196
|
+
}
|
|
197
|
+
if (typeof body?.caption === "string") delete pub.caption_instagram;
|
|
198
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
199
|
+
writeFileSync(tmp, JSON.stringify(pub, null, 2) + "\n");
|
|
200
|
+
renameSync(tmp, file);
|
|
201
|
+
return {
|
|
202
|
+
flags: [
|
|
203
|
+
...platforms.map(p => `--${p}`),
|
|
204
|
+
"--privacy",
|
|
205
|
+
privacy,
|
|
206
|
+
"--tiktok-privacy",
|
|
207
|
+
tiktokPrivacy,
|
|
208
|
+
"--confirm",
|
|
209
|
+
...(body?.republish === true ? ["--again"] : []),
|
|
210
|
+
],
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const joinOutput = (r: { stdout: string; stderr: string }) =>
|
|
215
|
+
[r.stdout, r.stderr]
|
|
216
|
+
.map(s => s.trim())
|
|
217
|
+
.filter(Boolean)
|
|
218
|
+
.join("\n");
|
|
219
|
+
|
|
220
|
+
export async function publishVideo(dir: string, body: any): Promise<Result> {
|
|
221
|
+
if (publishing.has(dir)) return { ok: false, error: "este vídeo já está sendo publicado" };
|
|
222
|
+
const p = publishFlags(dir, body);
|
|
223
|
+
if ("error" in p) return { ok: false, error: p.error };
|
|
224
|
+
publishing.add(dir);
|
|
225
|
+
try {
|
|
226
|
+
const r = await run([NODE, PUBLISH, dir, ...p.flags], { OMNIVIDEO_ORIGIN: "studio" });
|
|
227
|
+
cachedAccounts = null;
|
|
228
|
+
const output = joinOutput(r);
|
|
229
|
+
return r.code === 0 ? { ok: true, output } : { ok: false, error: output || `publish.mjs saiu com ${r.code}` };
|
|
230
|
+
} finally {
|
|
231
|
+
publishing.delete(dir);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* Scheduling from the UI: the same request as the Publish button, for the day and time in `when`
|
|
236
|
+
(ISO, converted from local time by the UI). The scheduler agent uploads on time
|
|
237
|
+
(`publish.mjs scheduler install`), with the studio open or not. */
|
|
238
|
+
export async function schedulePublish(dir: string, body: any): Promise<Result> {
|
|
239
|
+
if (publishing.has(dir)) return { ok: false, error: "este vídeo está sendo publicado agora" };
|
|
240
|
+
const when = String(body?.when ?? "");
|
|
241
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(when) || Number.isNaN(Date.parse(when)))
|
|
242
|
+
return { ok: false, error: "escolha o dia e a hora" };
|
|
243
|
+
const p = publishFlags(dir, body);
|
|
244
|
+
if ("error" in p) return { ok: false, error: p.error };
|
|
245
|
+
const r = await run([NODE, PUBLISH, "schedule", dir, "--when", when, ...p.flags], { OMNIVIDEO_ORIGIN: "studio" });
|
|
246
|
+
const output = joinOutput(r);
|
|
247
|
+
return r.code === 0 ? { ok: true, output } : { ok: false, error: output || `publish.mjs saiu com ${r.code}` };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* Rescheduling from the schedule (dragging the post): the same schedule, another time. `when`
|
|
251
|
+
in ISO; publish.mjs refuses a time already past */
|
|
252
|
+
export async function reschedulePublish(dir: string, body: any): Promise<Result> {
|
|
253
|
+
if (publishing.has(dir)) return { ok: false, error: "este vídeo está sendo publicado agora" };
|
|
254
|
+
const when = String(body?.when ?? "");
|
|
255
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(when) || Number.isNaN(Date.parse(when)))
|
|
256
|
+
return { ok: false, error: "escolha o dia e a hora" };
|
|
257
|
+
const r = await run([NODE, PUBLISH, "schedule", dir, "--reschedule", "--when", when, "--confirm"], {
|
|
258
|
+
OMNIVIDEO_ORIGIN: "studio",
|
|
259
|
+
});
|
|
260
|
+
const output = joinOutput(r);
|
|
261
|
+
return r.code === 0 ? { ok: true, output } : { ok: false, error: output || `publish.mjs saiu com ${r.code}` };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export async function cancelScheduledPublish(dir: string): Promise<Result> {
|
|
265
|
+
const r = await run([NODE, PUBLISH, "schedule", dir, "--cancel"]);
|
|
266
|
+
const output = joinOutput(r);
|
|
267
|
+
return r.code === 0 ? { ok: true, output } : { ok: false, error: output || `publish.mjs saiu com ${r.code}` };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/* `scheduler --json`: the agent and everything scheduled, across all videos */
|
|
271
|
+
export async function getSchedule() {
|
|
272
|
+
const r = await run([NODE, PUBLISH, "scheduler", "--json"]);
|
|
273
|
+
try {
|
|
274
|
+
return JSON.parse(r.stdout);
|
|
275
|
+
} catch {
|
|
276
|
+
return { error: joinOutput(r) || `publish.mjs saiu com ${r.code}` };
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/* enables and disables the launchd agent: installs with the studio's node */
|
|
281
|
+
export async function setScheduleAgent(enable: unknown): Promise<Result> {
|
|
282
|
+
if (typeof enable !== "boolean") return { ok: false, error: "enable: true ou false" };
|
|
283
|
+
const r = await run([NODE, PUBLISH, "scheduler", enable ? "install" : "uninstall"]);
|
|
284
|
+
cachedAccounts = null;
|
|
285
|
+
const output = joinOutput(r);
|
|
286
|
+
return r.code === 0 ? { ok: true, output } : { ok: false, error: output || `publish.mjs saiu com ${r.code}` };
|
|
287
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/* Reads the machine queue. The writer is tools/job_queue.py (and its guardian
|
|
2
|
+
for the Node tools); the studio only reads .queue/ and applies the same
|
|
3
|
+
liveness rule: an active ticket whose process is dead, or with no heartbeat for
|
|
4
|
+
more than 15 s, is interrupted. */
|
|
5
|
+
|
|
6
|
+
import { readdirSync, statSync, existsSync, mkdirSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { QUEUE_DIR, ROOT, readJson } from "./root";
|
|
9
|
+
|
|
10
|
+
const STALE_MS = 15_000;
|
|
11
|
+
const ACTIVE_STATES = new Set(["waiting", "running"]);
|
|
12
|
+
|
|
13
|
+
export type Ticket = {
|
|
14
|
+
id: string;
|
|
15
|
+
tool: string;
|
|
16
|
+
video: string | null;
|
|
17
|
+
dir: string | null;
|
|
18
|
+
command: string;
|
|
19
|
+
pid: number;
|
|
20
|
+
guardian: number | null;
|
|
21
|
+
origin: string;
|
|
22
|
+
session: string | null;
|
|
23
|
+
state: string;
|
|
24
|
+
effective: string;
|
|
25
|
+
order: number;
|
|
26
|
+
arrived_at: string;
|
|
27
|
+
started_at: string | null;
|
|
28
|
+
ended_at: string | null;
|
|
29
|
+
exit_code: number | null;
|
|
30
|
+
log: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type Queue = { running: Ticket[]; waiting: Ticket[]; recent: Ticket[] };
|
|
34
|
+
|
|
35
|
+
/* a zombie counts as dead: kill(pid, 0) answers for it, and a studio child that
|
|
36
|
+
exits after a `bun --watch` reload stays a zombie forever (the new image
|
|
37
|
+
doesn't know it exists and never reaps its exit) */
|
|
38
|
+
export function isAlive(pid: number) {
|
|
39
|
+
if (!pid) return false;
|
|
40
|
+
try {
|
|
41
|
+
process.kill(pid, 0);
|
|
42
|
+
} catch (e: any) {
|
|
43
|
+
if (e.code !== "EPERM") return false;
|
|
44
|
+
}
|
|
45
|
+
const ps = Bun.spawnSync(["ps", "-o", "stat=", "-p", String(pid)]);
|
|
46
|
+
return !ps.stdout.toString().trim().startsWith("Z");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function listTickets(): Ticket[] {
|
|
50
|
+
if (!existsSync(QUEUE_DIR)) mkdirSync(QUEUE_DIR, { recursive: true });
|
|
51
|
+
const now = Date.now();
|
|
52
|
+
const all: Ticket[] = [];
|
|
53
|
+
for (const name of readdirSync(QUEUE_DIR)) {
|
|
54
|
+
if (!name.endsWith(".json")) continue;
|
|
55
|
+
const file = join(QUEUE_DIR, name);
|
|
56
|
+
const ticket = readJson<Ticket>(file);
|
|
57
|
+
if (!ticket) continue;
|
|
58
|
+
let mtime = 0;
|
|
59
|
+
try {
|
|
60
|
+
mtime = statSync(file).mtimeMs;
|
|
61
|
+
} catch {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
ticket.effective =
|
|
65
|
+
ACTIVE_STATES.has(ticket.state) && (!isAlive(ticket.pid) || now - mtime > STALE_MS)
|
|
66
|
+
? "interrupted"
|
|
67
|
+
: ticket.state;
|
|
68
|
+
all.push(ticket);
|
|
69
|
+
}
|
|
70
|
+
return all;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const byOrder = (a: Ticket, b: Ticket) => a.order - b.order || a.pid - b.pid;
|
|
74
|
+
|
|
75
|
+
export function getQueue(recent = 30): Queue {
|
|
76
|
+
const all = listTickets();
|
|
77
|
+
return {
|
|
78
|
+
running: all.filter(s => s.effective === "running").sort(byOrder),
|
|
79
|
+
waiting: all.filter(s => s.effective === "waiting").sort(byOrder),
|
|
80
|
+
recent: all
|
|
81
|
+
.filter(s => !ACTIVE_STATES.has(s.effective))
|
|
82
|
+
.sort((a, b) => (b.ended_at ?? b.arrived_at).localeCompare(a.ended_at ?? a.arrived_at))
|
|
83
|
+
.slice(0, recent),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function getTicket(id: string): Ticket | null {
|
|
88
|
+
if (!/^[\w.-]+$/.test(id)) return null;
|
|
89
|
+
return listTickets().find(s => s.id === id) ?? null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* The log grows while the task runs. Sends what already exists and then only
|
|
93
|
+
what arrives, decoding as a stream (an accented character may be split
|
|
94
|
+
between two reads); ends when the task ends and the file stops. */
|
|
95
|
+
export function streamTicketLog(id: string, req: Request): Response {
|
|
96
|
+
const s = getTicket(id);
|
|
97
|
+
if (!s) return new Response("tarefa não encontrada", { status: 404 });
|
|
98
|
+
const file = join(ROOT, s.log);
|
|
99
|
+
const encoder = new TextEncoder();
|
|
100
|
+
const decoder = new TextDecoder();
|
|
101
|
+
let pos = 0;
|
|
102
|
+
let busy = false;
|
|
103
|
+
let closed = false;
|
|
104
|
+
let timer: ReturnType<typeof setInterval>;
|
|
105
|
+
const stop = () => {
|
|
106
|
+
closed = true;
|
|
107
|
+
clearInterval(timer);
|
|
108
|
+
};
|
|
109
|
+
const body = new ReadableStream({
|
|
110
|
+
start(ctrl) {
|
|
111
|
+
const send = (event: string, data: unknown) =>
|
|
112
|
+
ctrl.enqueue(encoder.encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`));
|
|
113
|
+
const check = async () => {
|
|
114
|
+
if (busy || closed) return;
|
|
115
|
+
busy = true;
|
|
116
|
+
try {
|
|
117
|
+
/* state before size: the task writes the log before closing the
|
|
118
|
+
ticket, so if it has already finished here, everything it said is
|
|
119
|
+
in the file and goes out before the end */
|
|
120
|
+
const current = getTicket(id);
|
|
121
|
+
const f = Bun.file(file);
|
|
122
|
+
const size = (await f.exists()) ? f.size : 0;
|
|
123
|
+
if (size > pos) {
|
|
124
|
+
const bytes = new Uint8Array(await f.slice(pos, size).arrayBuffer());
|
|
125
|
+
pos = size;
|
|
126
|
+
const text = decoder.decode(bytes, { stream: true });
|
|
127
|
+
if (text) send("log", text);
|
|
128
|
+
}
|
|
129
|
+
if (!current || !ACTIVE_STATES.has(current.effective)) {
|
|
130
|
+
const rest = decoder.decode();
|
|
131
|
+
if (rest) send("log", rest);
|
|
132
|
+
send("end", { state: current?.effective ?? "gone", exit_code: current?.exit_code ?? null });
|
|
133
|
+
stop();
|
|
134
|
+
ctrl.close();
|
|
135
|
+
}
|
|
136
|
+
} catch {
|
|
137
|
+
/* client left in the middle of a read */
|
|
138
|
+
stop();
|
|
139
|
+
} finally {
|
|
140
|
+
busy = false;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
timer = setInterval(check, 400);
|
|
144
|
+
check();
|
|
145
|
+
req.signal.addEventListener("abort", stop);
|
|
146
|
+
},
|
|
147
|
+
cancel: stop,
|
|
148
|
+
});
|
|
149
|
+
return new Response(body, { headers: { "content-type": "text/event-stream", "cache-control": "no-cache" } });
|
|
150
|
+
}
|