Skip to content
TypeScript
3.6 KB
Raw Blame
/**
 * W1 — 신규 하네스 (oh-my-openagent=omo / ponytail / mattpocock).
 * 호환 매핑(combo 유효성), mock fan-out(오케스트레이션 × 에이전트), 적용 메커니즘.
 */
import { mkdtempSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { expand } from "../src/combos";
import { HARNESSES } from "../src/config";
import { MockRunner } from "../src/runners/mock";
import { parserFor } from "../src/transcripts/index";

function tmp(): string {
  return mkdtempSync(join(tmpdir(), "theseus-h-"));
}

async function fanout(
  comboId: string,
  agent: string,
  model: string,
  harness: string,
): Promise<number> {
  const art = await new MockRunner(0).run({
    combo: { comboId, agent, model, harness, valid: true },
    taskId: "subagent-102",
    runIdx: 0,
    workDir: tmp(),
    timeoutS: 5,
    seed: 1,
    bench: "subagent",
  });
  return parserFor(agent).parse(art.transcriptPath, { model }).subagentCount;
}

describe("new harness registry + mapping", () => {
  it("registers omo/ponytail/mattpocock with correct agents + orchestration", () => {
    expect(HARNESSES.omo?.agents.sort()).toEqual(["codex", "opencode"]);
    expect(HARNESSES.omo?.orchestration).toBe(true);
    expect(HARNESSES.ponytail?.agents.sort()).toEqual([
      "cc",
      "codex",
      "hermes",
      "openclaw",
      "opencode",
    ]);
    expect(HARNESSES.ponytail?.orchestration).toBe(false);
    expect(HARNESSES.mattpocock?.agents.sort()).toEqual(["cc", "codex", "opencode"]);
    expect(HARNESSES.mattpocock?.orchestration).toBe(false);
  });

  it("expand: combos valid/excluded per researched mapping", () => {
    const { valid, excluded } = expand(
      ["opus4.8", "gpt5.5"],
      ["cc", "codex", "opencode", "openclaw", "hermes"],
      ["omo", "ponytail", "mattpocock"],
    );
    const ids = new Set(valid.map((c) => c.comboId));
    // omo → opencode + codex
    expect(ids.has("opencode+gpt5.5+omo")).toBe(true);
    expect(ids.has("codex+gpt5.5+omo")).toBe(true);
    expect(excluded.find((c) => c.comboId === "cc+opus4.8+omo")?.excludeReason).toMatch(
      /not compatible/,
    );
    // ponytail → everyone
    expect(ids.has("cc+opus4.8+ponytail")).toBe(true);
    expect(ids.has("hermes+gpt5.5+ponytail")).toBe(true);
    // mattpocock → cc/codex/opencode; hermes & openclaw excluded
    expect(ids.has("opencode+opus4.8+mattpocock")).toBe(true);
    expect(excluded.find((c) => c.comboId === "hermes+gpt5.5+mattpocock")?.excludeReason).toMatch(
      /not compatible/,
    );
    expect(
      excluded.find((c) => c.comboId === "openclaw+opus4.8+mattpocock")?.excludeReason,
    ).toMatch(/not compatible/);
  });
});

describe("mock fan-out: orchestration × agent capability", () => {
  it("opencode+omo fans out (subagents>0); opencode+none stays flat", async () => {
    expect(await fanout("opencode+gpt5.5+omo", "opencode", "gpt5.5", "omo")).toBeGreaterThan(0);
    expect(await fanout("opencode+gpt5.5+none", "opencode", "gpt5.5", "none")).toBe(0);
  });
  it("cc+mattpocock fans out; codex+omo stays flat (single loop)", async () => {
    expect(await fanout("cc+opus4.8+mattpocock", "cc", "opus4.8", "mattpocock")).toBeGreaterThan(0);
    expect(await fanout("codex+gpt5.5+omo", "codex", "gpt5.5", "omo")).toBe(0);
  });
  it("determinism: same combo+seed → identical subagent count", async () => {
    const a = await fanout("opencode+gpt5.5+omo", "opencode", "gpt5.5", "omo");
    const b = await fanout("opencode+gpt5.5+omo", "opencode", "gpt5.5", "omo");
    expect(a).toBe(b);
  });
});