53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
package app
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notify"
|
|
)
|
|
|
|
func composeInvocation(runtime *invocationRuntime) error {
|
|
env := runtime.env
|
|
stages := runtime.stages
|
|
dependencies := runtime.dependencies
|
|
|
|
if env.WhisperX == nil && stagesContainAny(stages, "transcribe") {
|
|
client, err := dependencies.newWhisperX(env.Config)
|
|
if err != nil {
|
|
return runtime.persistTerminalFailure(fmt.Errorf("initialize whisperx client: %w", err))
|
|
}
|
|
env.WhisperX = client
|
|
}
|
|
if env.Seriatim == nil && stagesContainAny(stages, "merge", "normalize", "trim", "render") {
|
|
runner, err := dependencies.newSeriatim(env.Config)
|
|
if err != nil {
|
|
return runtime.persistTerminalFailure(fmt.Errorf("initialize seriatim runner: %w", err))
|
|
}
|
|
env.Seriatim = runner
|
|
}
|
|
if env.Audita == nil && stagesContainAny(stages, "polish") {
|
|
runner, err := dependencies.newAudita(env.Config)
|
|
if err != nil {
|
|
return runtime.persistTerminalFailure(fmt.Errorf("initialize audita runner: %w", err))
|
|
}
|
|
env.Audita = runner
|
|
}
|
|
if env.Notarius == nil && needsNotariusForRun(env.Config, stages) {
|
|
env.Notarius = dependencies.newNotarius()
|
|
}
|
|
if env.Scriptorium == nil && stagesContainAny(stages, "trim", "analyze") {
|
|
env.Scriptorium = dependencies.newScriptorium()
|
|
}
|
|
if env.ObjectStore == nil && needsObjectStoreForRun(env.Config, stages, runtime.effectiveArtifacts) {
|
|
objectStore, err := dependencies.newObjectStore(runtime.ctx, env.Config)
|
|
if err != nil {
|
|
return runtime.persistTerminalFailure(err)
|
|
}
|
|
env.ObjectStore = objectStore
|
|
}
|
|
if env.Notifier == nil && stagesContainAny(stages, "notify") {
|
|
env.Notifier = ¬ify.NoopSender{}
|
|
}
|
|
return nil
|
|
}
|