Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

7.5 KB
Raw Blame
// screenpipe — AI that knows everything you've seen, said, or heard
// https://screenpipe.com

import type {
  SavedWorkflowSkill,
  WorkProfile,
  WorkflowAnalysis,
  WorkflowMap,
  WorkflowRuntime,
  WorkflowScope,
  WorkflowSkillDraft,
  WorkflowSkillProgress,
} from "./model";
import type { WorkflowGuide } from "./guide";
import type { WorkflowsAssistantPlatform } from "./assistant";

export type WorkflowAnalysisOptions = {
  signal?: AbortSignal;
  scope?: WorkflowScope;
  workProfile?: WorkProfile | null;
};

export type WorkflowRunActivity = {
  id: string;
  label: string;
  status: "running" | "complete" | "error";
};

export type WorkflowAnalysisJob = {
  id: string;
  /** Stable across agent executions belonging to one update. */
  cycleId?: string;
  status: "queued" | "processing" | "complete" | "incomplete" | "failed";
  progress?: number;
  startedAt?: string;
  message?: string;
  result?: WorkflowAnalysis;
};

export type WorkflowsPlatform = {
  /** Save reviewed answers through the existing revision-checked correction writer. */
  questionnaireVoice?: import("./questionnaire-voice").QuestionnaireVoice;
  saveWorkflowAnswers?: (workflow: WorkflowMap, correction: string) => Promise<WorkflowMap>;
  saveWorkflowEdits?: (draft: import("./workflow-edits").WorkflowEdit) => Promise<WorkflowMap>;
  modelPreference?: import("./model-choice").WorkflowModelPreference;
  /** The existing scheduled-task runtime owns reconciliation and persistence. */
  managesAnalysis?: boolean;
  ensureAnalysisTask?: () => Promise<void>;
  getLatestAnalysisJob?: () => Promise<WorkflowAnalysisJob | null>;
  cancelAnalysisJob?: () => Promise<void>;
  /** Observe the existing harness. Does not start or enable a task. */
  subscribeAnalysisActivity?: (
    jobId: string,
    onActivity: (items: WorkflowRunActivity[]) => void,
  ) => Promise<() => void>;
  /** Local, on-demand media only. Never persist the returned URL or upload it. */
  loadWorkflowRecording?: (
    timestamp: string,
    app: string,
  ) => Promise<WorkflowRecording | null>;
  releaseWorkflowRecording?: (url: string) => Promise<void>;
  /** Exact source preview, not verification of the step. Blob URLs are released
   * by the view; never persist this transient image in the workflow catalog. */
  loadWorkflowScreenshot?: (
    timestamp: string,
    app: string,
    signal: AbortSignal,
    frameId?: number,
  ) => Promise<import("./model").WorkflowScreenshot | null>;
  openCapturedMoment?: (frameId: number, timestamp: string) => Promise<void>;
  assistant?: WorkflowsAssistantPlatform;
  /** The host can discover context without uploaded sources. */
  contextDiscovery?: boolean;
  fillContext?: (
    request: import("./context-tool").ContextFillRequest,
  ) => Promise<void>;
  ensureRuntime: () => Promise<WorkflowRuntime>;
  analyzeCapturedWork: (
    days: number,
    options?: WorkflowAnalysisOptions,
  ) => Promise<WorkflowAnalysis>;
  loadCapturedWork?: (
    days: number,
    options?: WorkflowAnalysisOptions,
  ) => Promise<WorkflowAnalysis | null>;
  saveCapturedWork?: (
    analysis: WorkflowAnalysis,
    options?: WorkflowAnalysisOptions,
  ) => Promise<void>;
  startAnalysisJob?: (
    days: number,
    options?: WorkflowAnalysisOptions,
  ) => Promise<WorkflowAnalysisJob>;
  getAnalysisJob?: (jobId: string) => Promise<WorkflowAnalysisJob>;
  loadWorkProfile?: (scope?: WorkflowScope) => Promise<WorkProfile | null>;
  saveWorkProfile?: (
    profile: WorkProfile,
    scope?: WorkflowScope,
  ) => Promise<WorkProfile>;
  library?: {
    downloadDocument?: (content: string, filename: string) => Promise<boolean>;
    listSkillDrafts: () => Promise<Array<{ workflowKey: string; draft: WorkflowSkillDraft }>>;
    saveSkillDraft: (workflowKey: string, draft: WorkflowSkillDraft) => Promise<void>;
    listInstalledSkills?: () => Promise<Array<{ name: string; description: string; path: string }>>;
  };
  guides?: {
    list?: () => Promise<WorkflowGuide[]>;
    loadSourceScreenshot?: WorkflowsPlatform["loadWorkflowScreenshot"];
    loadScreenshot?: (frameId: number, signal: AbortSignal) => Promise<string>;
    video?: import("./guide-video").GuideVideoPlatform;
    generate: (
      workflow: WorkflowMap,
      signal: AbortSignal,
      progress: (message: string) => void,
    ) => Promise<import("./guide").WorkflowGuide>;
    load: (
      workflow: WorkflowMap,
    ) => Promise<import("./guide").WorkflowGuide | null>;
    save: (guide: import("./guide").WorkflowGuide) => Promise<void>;
    edit?: (
      guide: WorkflowGuide,
      workflow: WorkflowMap,
      instruction: string,
      signal: AbortSignal,
      progress: (message: string) => void,
    ) => Promise<WorkflowGuide>;
    openWeb?: (guide: WorkflowGuide, workflow: WorkflowMap) => Promise<void>;
    export: (html: string, title: string) => Promise<boolean>;
  };
  generateWorkflowSkill?: (
    workflow: WorkflowMap,
    profile?: WorkProfile | null,
    onProgress?: (progress: WorkflowSkillProgress) => void,
  ) => Promise<WorkflowSkillDraft>;
  saveWorkflowSkill?: (
    draft: WorkflowSkillDraft,
  ) => Promise<SavedWorkflowSkill>;
  skillInstallMode?: "local" | "preview";
  openAccount?: () => Promise<void>;
  startWindowDrag?: () => Promise<void> | void;
};

export type WorkflowRecording = {
  kind: "video" | "image";
  url: string;
  timestamp: string;
  frameId: number;
  offsetSeconds: number;
  matchDistanceSeconds: number;
};

export type WorkflowsAppProps = {
  /** Optional content-free usage events; the host owns consent and identity. */
  onUsageEvent?: (event: import("./use-workflow-usage").WorkflowUsageEvent) => void;
  modelControl?: import("react").ReactNode;
  /** Quiet in-app alternative to interrupting a focused workflow reader. */
  readyWorkflowIds?: string[];
  /** Host-owned request survives cold startup until the saved catalog loads. */
  reviewRequest?: { key: string; workflowId?: string; workflowIds?: string[] };
  onReviewRequestHandled?: (found: boolean) => void;
  platform: WorkflowsPlatform;
  initialAnalysis?: WorkflowAnalysis | null;
  storageKey?: string | null;
  initialScopeId?: string;
  embedded?: boolean;
  /** Keep mounted while another workspace is visible, without global shortcuts. */
  active?: boolean;
  /** Native fullscreen state supplied by the host window. */
  fullscreen?: boolean;
  /** Use the desktop app's sidebar preference, typography and navigation chrome. */
  desktopAppearance?: boolean;
  navigationFooter?: (actions: {
    openKeyboardShortcuts: () => void;
  }) => import("react").ReactNode;
  navigationBrand?: import("react").ReactNode;
  /** Data-source selection stays in the toolbar when navigation is collapsed. */
  sourceControl?: import("react").ReactNode;
  composerAccessory?: import("./assistant").WorkflowComposerAccessory;
  /** Open the host sharing review; clicking must not send the workflow. */
  onShareDocument?: (document: import("./document-actions").LibraryShareDocument) => void;
  onShareWorkflow?: (workflow: WorkflowMap) => void;
  /** Optional host integration with the existing external-agent launchers. */
  workflowAgentActions?: (workflow: WorkflowMap) => import("react").ReactNode;
  /** Host-owned live recorder status and controls. */
  recordingStatus?: import("react").ReactNode;
  analysisUnavailableReason?: string;
  /** Explain access only after the user requests an update. */
  onAnalysisUnavailable?: () => void;
  statusNotice?: import("react").ReactNode;
  /** Host controls beside the model selector, available in every workflow view. */
  toolbarAccessory?: import("react").ReactNode;
};