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

1.1 KB
Raw Blame
// screenpipe — AI that knows everything you've seen, said, or heard
// https://screenpipe.com
import type { WorkflowScreenshot, WorkflowStage } from "./model";

// New catalogs store an array; legacy catalogs may still have one image.
export function stageScreenshots(stage: WorkflowStage): WorkflowScreenshot[] {
  const seen = new Set<number>();
  return [...(stage.screenshots ?? []), ...(stage.screenshot ? [stage.screenshot] : [])]
    .filter(image => image && Number.isSafeInteger(image.frameId) && image.frameId > 0
      && !seen.has(image.frameId) && !!seen.add(image.frameId));
}
export function verifiedStageScreenshots(stage: WorkflowStage): WorkflowScreenshot[] {
  return stageScreenshots(stage).filter(image => image.visualVerified);
}

/** Keep recorder identities in saved state; pixel copies belong only in explicit exports. */
export function serializeWorkflowData(value: unknown): string {
  return JSON.stringify(value, function (key, child) {
    return key === "dataUrl" && Number.isSafeInteger(this?.frameId)
      && this.frameId > 0 && typeof this.timestamp === "string" ? "" : child;
  });
}