Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

3.7 KB
Raw Blame
import type { GenerationIssue } from '@features/generation/contracts';
import type { InvocationTemplatesSnapshot, WorkflowReadinessReason } from '@features/workflow/contracts';
import type { CanvasInputIssue } from '@workbench/canvasGenerationInputs';

export type InvocationSourceId = 'generate' | 'workflow' | 'upscale' | 'video' | 'canvas';

export type InvocationMode = 'global' | 'dialog';

export type ResultDestination = 'canvas' | 'gallery';

/** The prompt and settings an expansion was computed from. The sample seed travels on its own: it may rotate. */
export interface DynamicPromptsExpansionSource {
  combinatorial: boolean;
  maxPrompts: number;
  /** The effective (template-merged) positive prompt. */
  positivePrompt: string;
}

/** A dynamic prompt expansion, with the sample seed it drew from (null for All combinations). */
export interface ExpandedPositivePrompts {
  /** A submission whose source no longer matches what it compiles is refused rather than queued. */
  expandedFrom: DynamicPromptsExpansionSource;
  positivePrompts: string[];
  /** Recall reproduces this draw, and a resampling submission rotates only while the project still holds it. */
  positivePromptsSampleSeed: number | null;
}

/** The metadata a Model only upscale copies, with the image it was read from, so a changed input is never mislabelled. */
export interface UpscaleSourceMetadata {
  imageName: string;
  /** Null when the image has none. */
  metadata: Record<string, unknown> | null;
}

export interface InvocationRoute {
  sourceId: InvocationSourceId;
  destination: ResultDestination;
  sourceLocked: boolean;
  destinationLocked: boolean;
}

export interface CanvasInputValidationReason {
  canvasInputIssue: CanvasInputIssue;
}

/**
 * A Generate settings issue, kept structured: the shell words it from the locale today, and its `target` (section and
 * field) and `fix` are there for a surface that jumps to the field or applies the fix.
 */
export interface GenerationValidationReason {
  generationIssue: GenerationIssue;
}

/** A problem with the route itself rather than its source's settings, kept structured so Invoke can offer the fix. */
export type RouteIssue =
  /** The source's widget is in no region or window of this project. */
  | { kind: 'sourceNotMounted'; sourceId: InvocationSourceId }
  /** Canvas staging takes images only. */
  | { kind: 'videoNeedsGallery' }
  | { kind: 'emptyCanvasFrame' };

export interface RouteValidationReason {
  routeIssue: RouteIssue;
}

export type InvocationValidationReason =
  | string
  | WorkflowReadinessReason
  | CanvasInputValidationReason
  | GenerationValidationReason
  | RouteValidationReason;

export interface ResolvedInvocationRoute extends InvocationRoute {
  mode: InvocationMode;
  sourceValid: boolean;
  destinationValid: boolean;
  /** The top validation issue, shown on the fixed Invoke control's secondary line. */
  validationMessage?: InvocationValidationReason;
  /** Every reason the route cannot run right now (legacy `reasonsWhyCannotEnqueue` equivalent). */
  validationReasons: InvocationValidationReason[];
  /** Present when the workflow has batch nodes; size is null until an async generator resolves on invoke. */
  workflowBatch?: { size: number | null };
}

export interface InvocationControllerState extends InvocationRoute {
  lastSubmittedRunId?: string;
}

/** Ephemeral values captured at dispatch, never persisted or treated as server authorization. */
export interface InvocationRuntimeInputs {
  /** GPU noise choice; the aggregate still applies the project's current CPU-noise preference. */
  readonly noiseDevice: string;
  readonly templates: Readonly<InvocationTemplatesSnapshot>;
  readonly boardDestinationIds: readonly string[];
}