creator

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package creator persists Content Creator projects and drives the video production workflow (references, keyframes, clips, assembly, publishing).

State lives in two places: authoritative JSON per project under the KV store (durable across process restarts) and generated media under an isolated root directory (config.Path("content-creator")/<projectID>/…). The service never stores plaintext credentials, never trusts caller-supplied filesystem paths beyond the registered artefact set, and refuses to re-run a paid media job that already has a pending provider id.

Index

Constants

This section is empty.

Variables

View Source
var ErrRevisionConflict = errors.New("project changed; reload before saving")
View Source
var ErrRunInProgress = errors.New("content project has an active run")

Functions

func RunFromContext

func RunFromContext(ctx context.Context) (runContext, bool)

RunFromContext returns the active run scope, or the zero value when there is none.

func WithRun

func WithRun(ctx context.Context, projectID, stage, publishMode, sessionID string) context.Context

WithRun attaches a run scope to ctx. Cron and the HTTP run handler wrap the per-turn context with this so every content_creator tool call — and every Service.Execute call the agent triggers — is bounded by the stage the operator authorised.

Callers preallocate the sessionID (so it lines up with BeginRun's owner tracking) and pass it in; a mismatched sessionID on Execute/Update is what stops a stray tab from mutating a project another run holds.

Passing an empty stage is treated as no active run (tool-driven, ad-hoc mutation): the strictest gates still apply (publish still needs publish_mode=auto or an explicit approved flag), but generation is allowed.

Types

type Idea

type Idea struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	Hook      string `json:"hook"`
	Rationale string `json:"rationale"`
	Selected  bool   `json:"selected"`
}

Idea is one candidate story arc the agent proposed. Exactly one is typically flagged Selected before Produce runs.

type Project

type Project struct {
	ID             string      `json:"id"`
	Title          string      `json:"title"`
	Brief          string      `json:"brief"`
	Platform       string      `json:"platform"`
	AccountID      string      `json:"account_id"`
	Style          string      `json:"style"`
	Size           string      `json:"size"`
	TargetSeconds  int         `json:"target_seconds"`
	Caption        string      `json:"caption"`
	Revision       int         `json:"revision"`
	PublishMode    string      `json:"publish_mode"` // draft|auto
	Status         string      `json:"status"`
	Error          string      `json:"error"`
	CreatedAt      string      `json:"created_at"`
	UpdatedAt      string      `json:"updated_at"`
	References     []Reference `json:"references"`
	Shots          []Shot      `json:"shots"`
	Research       []Trend     `json:"research"`
	Ideas          []Idea      `json:"ideas"`
	FinalPath      string      `json:"final_path"`
	FinalHash      string      `json:"final_hash,omitempty"`
	Publication    Publication `json:"publication"`
	RunSessionID   string      `json:"run_session_id,omitempty"`
	RunStage       string      `json:"run_stage,omitempty"`
	RunPublishMode string      `json:"run_publish_mode,omitempty"`
	RunStatus      string      `json:"run_status,omitempty"` // idle|running|error
	LastRunError   string      `json:"last_run_error,omitempty"`
	RunStartedAt   string      `json:"run_started_at,omitempty"`
	RunFinishedAt  string      `json:"run_finished_at,omitempty"`
}

Project is one video the agent is producing. Everything the UI, the agent and the cron scheduler need to know about the shoot lives here; the media service reads it through Get and writes it through Update/Execute.

type Publication

type Publication struct {
	Status       string `json:"status"` // not_started|uploading|published|blocked
	PostURL      string `json:"post_url"`
	Error        string `json:"error"`
	AccountID    string `json:"account_id"`
	ArtifactHash string `json:"artifact_hash"`
	// Proof is an observed browser evidence blurb the agent must supply on
	// confirm; empty means the publication is not verified even if a URL is
	// set. Never invent this — it is what stops the tool from lying about a
	// successful upload.
	Proof       string `json:"proof,omitempty"`
	PreparedAt  string `json:"prepared_at,omitempty"`
	PublishedAt string `json:"published_at,omitempty"`
}

Publication is the state of the current upload attempt to a social account. Status transitions: not_started -> uploading -> published | blocked.

type Reference

type Reference struct {
	ID     string `json:"id"`
	Kind   string `json:"kind"` // character|setting|style|prop
	Name   string `json:"name"`
	Prompt string `json:"prompt"`
	Path   string `json:"path"`
	Status string `json:"status"`
	Error  string `json:"error"`
}

Reference is a stable visual anchor (a character, setting, style or prop) the agent generates once and reuses across shots. Each reference lives in the project directory as a PNG the shots' keyframes may pass to the image endpoint as an inspiration image.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(db store.Store, root string) *Service

func (*Service) Artifact

func (s *Service) Artifact(ctx context.Context, id, path string) (string, error)

func (*Service) BeginRun

func (s *Service) BeginRun(ctx context.Context, id, stage, mode, sid string) (Project, error)

func (*Service) BlockPublish

func (s *Service) BlockPublish(ctx context.Context, id, reason string) (Project, error)

func (*Service) ConfirmPublish

func (s *Service) ConfirmPublish(ctx context.Context, id, postURL, proof, hash string) (Project, error)

func (*Service) Create

func (s *Service) Create(ctx context.Context, p Project) (Project, error)

func (*Service) EndRun

func (s *Service) EndRun(ctx context.Context, id, sid string, runErr error) (Project, error)

func (*Service) Execute

func (s *Service) Execute(ctx context.Context, cfg *config.Config, id, action, target string) (result Project, runErr error)

Execute performs one media action on a project: generate a reference PNG, generate a keyframe PNG for a shot, submit a paid video job, poll a video job to completion (downloading it and extracting the last frame), or assemble the ordered ready shots into the final MP4.

It is the only path that talks to the media provider. Guards:

  • stageAllows("media") — a research/plan run cannot spend money.
  • checkOwner — another run holding the project blocks writes.
  • a shot that already carries a video_job_id in a non-terminal state is never resubmitted; poll_video handles it instead.
  • keyframes for continue shots come from the previous shot's last_frame, not from References; a cut shot's keyframe is generated from References.
  • each shot's PromptHash records the exact inputs that produced its media so a matching precheck reuses artefacts and a mismatch refuses to serve stale ones (Update already invalidates paths — this defends inside).
  • assemble validates the total duration against target_seconds.

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (Project, error)

func (*Service) List

func (s *Service) List(ctx context.Context) ([]Project, error)

func (*Service) PreparePublish

func (s *Service) PreparePublish(ctx context.Context, id string, approved bool) (Publication, string, error)

func (*Service) ReconcileNotPublished

func (s *Service) ReconcileNotPublished(ctx context.Context, id, proof string) (Project, error)

func (*Service) Reset

func (s *Service) Reset(ctx context.Context, id, kind, target string) (Project, error)

Reset discards generated outputs only after an explicit operator decision. A pending provider job cannot be forgotten because that could bill twice.

func (*Service) Update

func (s *Service) Update(ctx context.Context, id string, next Project) (Project, error)

type Shot

type Shot struct {
	ID              string   `json:"id"`
	Prompt          string   `json:"prompt"`
	ReferenceIDs    []string `json:"reference_ids"`
	DurationSeconds int      `json:"duration_seconds"`
	Continuity      string   `json:"continuity"` // cut|continue
	Notes           string   `json:"notes"`
	KeyframePath    string   `json:"keyframe_path"`
	VideoJobID      string   `json:"video_job_id"`
	VideoPath       string   `json:"video_path"`
	LastFramePath   string   `json:"last_frame_path"`
	Status          string   `json:"status"`
	Error           string   `json:"error"`
	Progress        int      `json:"progress"`
	// PromptHash captures the (prompt, references, continuity) inputs that
	// produced the generated media. A caller-facing Update that changes any
	// input clears the derived artefacts so a stale clip cannot masquerade as
	// belonging to the new prompt.
	PromptHash string `json:"prompt_hash,omitempty"`
	// ProviderSnapshot pins the provider identity that owns this shot's
	// current VideoJobID. Poll/refetch MUST reject a mismatched config so a
	// swapped video provider cannot poll a foreign job or expose a different
	// bearer against the previous provider's host.
	ProviderSnapshot string `json:"provider_snapshot,omitempty"`
}

Shot is one clip in the ordered timeline. Continuity is either "cut" (the keyframe is generated fresh from References) or "continue" (the keyframe is the previous shot's last frame).

type Trend

type Trend struct {
	URL        string             `json:"url"`
	Title      string             `json:"title"`
	Platform   string             `json:"platform"`
	ObservedAt string             `json:"observed_at"`
	Notes      string             `json:"notes"`
	Metrics    map[string]float64 `json:"metrics,omitempty"`
}

Trend is one observed source of what is trending on the platform. The agent MUST NOT invent metrics; only URL, title and observed_at are required.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL