Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

1.2 KB
Raw Blame
import assert from "node:assert/strict";
import test from "node:test";

import { BuildMachine } from "@hypit/kernel";
import type { BuildFact, InvokeProducerCommand } from "@hypit/protocol";

import { completeChainStep, createChainDefinition } from "./chain-fixture.js";

test("BuildMachine advances a long chain through only its newly ready command and restores from Facts", () => {
  const definition = createChainDefinition(512);
  const machine = new BuildMachine(definition);
  const facts: BuildFact[] = [];
  for (let index = 0; index < 512; index += 1) {
    assert.equal(machine.commands().length, 1);
    const command = machine.commands()[0];
    assert.equal(command?.kind, "invoke-producer");
    assert.equal(command.step, `step:${index}`);
    const fact = machine.evaluate(completeChainStep(command as InvokeProducerCommand));
    assert.ok(fact);
    facts.push(fact);
    machine.commit();
  }
  assert.equal(machine.status, "complete");
  assert.equal(machine.commands().length, 0);
  assert.deepEqual(machine.record("record:512")?.value, { kind: "inline", value: 512 });

  const restored = new BuildMachine(definition, facts);
  assert.equal(restored.status, "complete");
  assert.deepEqual(restored.view(), machine.view());
});