TypeScript
Add three L1 agents (opencode, openclaw, hermes) with real CLI adapters
Claude81bc3e4f0f92
diff --git a/README.md b/README.mdindex 979cd84..ca5daf4 100644--- a/README.md+++ b/README.md@@ -29,16 +29,21 @@ Multi-select flags are comma-separated; unselected = skipped.```bash# shorthand (no subcommand → compare)-theseus --model opus4.8,gpt5.5 --agent cc,codex --harness none,superpowers+theseus --model opus4.8,gpt5.5 --agent cc,codex,opencode --harness none,superpowers# subcommands-theseus compare --model gpt5.5 --agent codex --harness none,superpowers --bench subagent+theseus compare --model gpt5.5 --agent codex,opencode,hermes --harness none --bench subagenttheseus results [--run <id>]-theseus install <cc|codex|tb|superpowers|omc|ecc|omx|lazycodex>+theseus install <cc|codex|opencode|openclaw|hermes|tb|superpowers|omc|ecc|omx|lazycodex>theseus doctortheseus tui [--out runs] [--rich] [--open]```+### L1 agents++`cc` (Claude Code, claude) · `codex` (Codex CLI, gpt) · `opencode` · `openclaw` · `hermes`.+The last three are model-agnostic (accept either family; theseus passes the model as `provider/id`).+Try it fully offline with the deterministic mock runner:```bashdiff --git a/docs/registry.md b/docs/registry.mdindex fcb74ea..c40119f 100644--- a/docs/registry.md+++ b/docs/registry.md@@ -14,7 +14,21 @@## L1 agents-`cc` (Claude Code, family=claude) · `codex` (Codex CLI, family=gpt).+| agent | binary | model families | model passing | harnesses |+|---|---|---|---|---|+| cc | claude | claude | `--model <id>` | none, superpowers, omc, ecc |+| codex | codex | gpt | `--model <id>` (omit for `default`) | none, superpowers, omx, lazycodex |+| opencode | opencode | claude + gpt | `--model <provider>/<id>` | none |+| openclaw | openclaw | claude + gpt | `--model <provider>/<id>` | none |+| hermes | hermes | claude + gpt | `--model <provider>/<id>` | none |++`opencode`/`openclaw`/`hermes` are model-agnostic: they accept either family, so theseus passes the model+as `provider/id` (`anthropic/…` or `openai/…`; `default` is omitted). They are conservatively limited to+the `none` harness. Real invocations:++- `opencode run --format json --model <provider>/<id> --dir <work> "<prompt>"`+- `openclaw agent --message "<prompt>" --model <provider>/<id> --json`+- `hermes -z "<prompt>" --model <provider>/<id>` (stdout = plain text)## L2 harnessesdiff --git a/docs/transcript_schema.md b/docs/transcript_schema.mdindex b1baa8c..2a8f653 100644--- a/docs/transcript_schema.md+++ b/docs/transcript_schema.md@@ -31,6 +31,14 @@ Per-node detail extracted at every level: `toolsUsed` (frequency-compressed, e.g`turn.completed.usage` (tokens), `item.completed` (tools). Real codex has no in-process subagents (flat);only an explicit `parent_idx` (mock / legacy schema) is honored as nesting.+## Multi-model agents (`transcripts/defensive.ts`)++`opencode` / `openclaw` / `hermes` outputs are only partially documented, so a single **defensive parser**+recursively scans the output (JSONL events, a single JSON object, or plain text) for token fields+(`input_tokens`/`prompt_tokens`/`output_tokens`/`completion_tokens`/`cache*`), tool/command events, a+session id, and result text. In-process subagents are 0 unless an explicit `task`/`subagent` marker+appears. Plain-text output (hermes `-z`) yields tokens=0 (honestly uncollected).+## Synthetic transcripts (mock)The mock runner emits the same shapes: cc → assistant + sidechain JSONL with `Task` tool_uses and adiff --git a/src/cli.ts b/src/cli.tsindex 4259e4f..df14058 100644--- a/src/cli.ts+++ b/src/cli.ts@@ -52,7 +52,7 @@ function toRunOptions(o: any): RunOptions {function addCompareOptions(cmd: Command): Command {return cmd.option("--model <list>", "L0 models (comma-separated)")- .option("--agent <list>", "L1 agents: cc,codex")+ .option("--agent <list>", "L1 agents: cc,codex,opencode,openclaw,hermes").option("--harness <list>", "L2 harnesses: none,superpowers,omc,ecc,omx,lazycodex", "none").option("--bench <name>", "benchmark", "terminal-bench-v2").option("--tasks <n>", "task subset size", "20")@@ -203,7 +203,7 @@ function buildProgram(): Command {program.command("install <component>")- .description("install agent/harness/bench (cc|codex|tb|<harness>)")+ .description("install agent/harness/bench (cc|codex|opencode|openclaw|hermes|tb|<harness>)").action((component) => runInstall(component));program@@ -216,6 +216,8 @@ function buildProgram(): Command {commandExists("claude") ? pc.green("available") : pc.red("missing"),]);table.push(["codex", commandExists("codex") ? pc.green("available") : pc.red("missing")]);+ for (const a of ["opencode", "openclaw", "hermes"])+ table.push([a, commandExists(a) ? pc.green("available") : pc.red("missing")]);table.push(["tb", commandExists("tb") ? pc.green("available") : pc.red("missing")]);table.push(["docker", commandExists("docker") ? pc.green("available") : pc.red("missing")]);table.push(["mock runner", pc.green("always available")]);@@ -226,7 +228,9 @@ function buildProgram(): Command {// 러너 인스턴스화 확인(가용성)console.log(pc.dim(- `runners: ${["mock", "cc", "codex", "tb"].map((n) => `${n}=${getRunner(n).isAvailable()}`).join(" ")}`,+ `runners: ${["mock", "cc", "codex", "opencode", "openclaw", "hermes", "tb"]+ .map((n) => `${n}=${getRunner(n).isAvailable()}`)+ .join(" ")}`,),);});diff --git a/src/combos.ts b/src/combos.tsindex d669dfe..e8dbf2e 100644--- a/src/combos.ts+++ b/src/combos.ts@@ -3,7 +3,7 @@* expand(models, agents, harnesses) → { valid, excluded }.* silent drop 금지 — 비호환은 excludeReason 과 함께 excluded 에 기록.*/-import { AGENTS, HARNESSES, modelFamily } from "./config";+import { AGENTS, HARNESSES, agentFamilies, modelFamily } from "./config";import type { Combo } from "./models";export interface ExpandResult {@@ -31,15 +31,16 @@ function checkCombo(agent: string, model: string, harness: string): string | nulconst hdef = HARNESSES[harness];if (!hdef) return `unknown harness '${harness}'`;- const aFam = AGENTS[agent].family;+ const aFams = agentFamilies(agent);const mFam = modelFamily(model);- // 1. cc 는 claude 모델만, codex 는 gpt 모델만- if (aFam !== mFam) {- return `agent '${agent}' (${aFam}) is incompatible with model '${model}' (${mFam})`;+ // 1. agent 가 지원하는 family 안에 모델 family 가 있어야 함+ // (cc→claude, codex→gpt, opencode/openclaw/hermes→any)+ if (!aFams.includes(mFam)) {+ return `agent '${agent}' (${aFams.join("/")}) is incompatible with model '${model}' (${mFam})`;}// 2. 하네스-에이전트 호환- if (!hdef.agents.includes(agent as "cc" | "codex")) {+ if (!hdef.agents.includes(agent)) {return `harness '${harness}' is not compatible with agent '${agent}'`;}return null;diff --git a/src/config.ts b/src/config.tsindex d0c1189..8d6c5a2 100644--- a/src/config.ts+++ b/src/config.ts@@ -11,14 +11,15 @@ export interface ModelDef {}export interface AgentDef {- name: string; // 'cc' | 'codex'- family: Family; // cc→claude, codex→gpt+ name: string; // 'cc' | 'codex' | 'opencode' | 'openclaw' | 'hermes'+ families: Family[]; // 호환 모델 family. cc→[claude], codex→[gpt], 그 외 멀티모델→[claude,gpt]bin: string;+ multiModel: boolean; // provider/model 형식으로 모델 지정(opencode/openclaw/hermes)}export interface HarnessDef {name: string;- agents: ("cc" | "codex")[]; // 호환 에이전트+ agents: string[]; // 호환 에이전트orchestration: boolean; // 오케스트레이션 계열(조합당 1개)}@@ -44,14 +45,23 @@ export const MODELS: Record<string, ModelDef> = {};// ── L1 에이전트 ──────────────────────────────────────────+// cc/codex 는 단일 family. opencode/openclaw/hermes 는 멀티모델(provider/model) → 모든 family 허용.export const AGENTS: Record<string, AgentDef> = {- cc: { name: "cc", family: "claude", bin: "claude" },- codex: { name: "codex", family: "gpt", bin: "codex" },+ cc: { name: "cc", families: ["claude"], bin: "claude", multiModel: false },+ codex: { name: "codex", families: ["gpt"], bin: "codex", multiModel: false },+ opencode: { name: "opencode", families: ["claude", "gpt"], bin: "opencode", multiModel: true },+ openclaw: { name: "openclaw", families: ["claude", "gpt"], bin: "openclaw", multiModel: true },+ hermes: { name: "hermes", families: ["claude", "gpt"], bin: "hermes", multiModel: true },};// ── L2 하네스 ────────────────────────────────────────────+// 멀티모델 에이전트(opencode/openclaw/hermes)는 보수적으로 none 만 지원.export const HARNESSES: Record<string, HarnessDef> = {- none: { name: "none", agents: ["cc", "codex"], orchestration: false },+ none: {+ name: "none",+ agents: ["cc", "codex", "opencode", "openclaw", "hermes"],+ orchestration: false,+ },superpowers: { name: "superpowers", agents: ["cc", "codex"], orchestration: true },omc: { name: "omc", agents: ["cc"], orchestration: true },ecc: { name: "ecc", agents: ["cc"], orchestration: true },@@ -84,8 +94,17 @@ export function isKnownModel(alias: string): boolean {return alias in MODELS || Object.values(MODELS).some((m) => m.resolvedId === alias);}-export function agentFamily(agent: string): Family | null {- return AGENTS[agent]?.family ?? null;+export function agentFamilies(agent: string): Family[] {+ return AGENTS[agent]?.families ?? [];+}++export function isMultiModelAgent(agent: string): boolean {+ return AGENTS[agent]?.multiModel === true;+}++/** 멀티모델 에이전트(opencode/openclaw/hermes)의 provider/model 형식 매핑. */+export function providerFor(family: Family): string {+ return family === "gpt" ? "openai" : "anthropic";}export function harnessDef(name: string): HarnessDef | undefined {diff --git a/src/install.ts b/src/install.tsindex bd94375..1c5c692 100644--- a/src/install.ts+++ b/src/install.ts@@ -12,12 +12,18 @@ const BIN_MAP: Record<string, string> = {codex: "codex",tb: "tb","terminal-bench": "tb",+ opencode: "opencode",+ openclaw: "openclaw",+ hermes: "hermes",};const INSTALL_HINTS: Record<string, string> = {claude: "npm i -g @anthropic-ai/claude-code",codex: "npm i -g @openai/codex",tb: "uv tool install terminal-bench",+ opencode: "npm i -g opencode-ai (or: curl -fsSL https://opencode.ai/install | bash)",+ openclaw: "npm i -g openclaw",+ hermes: "curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash",};// 하네스 → marketplace source / plugin iddiff --git a/src/runners/mock.ts b/src/runners/mock.tsindex 4917024..8b216d0 100644--- a/src/runners/mock.ts+++ b/src/runners/mock.ts@@ -86,10 +86,10 @@ export class MockRunner implements RunnerAdapter {// 실행 성공 여부(fail-soft 경로 검증용)const failed = det.chance(this.failRate);- // 서브에이전트 수+ // 서브에이전트 수 — cc 만 하네스 경향으로 fan-out. codex/멀티모델 에이전트는 단일 루프(0).const fam = modelFamily(model);let subagentCount = 0;- if (agent !== "codex" && fam !== "gpt") {+ if (agent === "cc") {const [lo, hi] = HARNESS_SUBAGENTS[harness] ?? [0, 0];subagentCount = det.randint(lo, hi);}@@ -103,11 +103,10 @@ export class MockRunner implements RunnerAdapter {const rawResolved = failed ? false : det.chance(0.7 - (scale - 1) * 0.15);- // transcript 합성+ // transcript 합성 — cc 만 트리(sidechain), 그 외(codex/opencode/openclaw/hermes)는 평탄.const lines: string[] =- agent === "codex"- ? this.codexTranscript(det, model, inputTokens, outputTokens, cacheRead, cacheCreate)- : this.ccTranscript(+ agent === "cc"+ ? this.ccTranscript(det,model,harness,@@ -116,7 +115,8 @@ export class MockRunner implements RunnerAdapter {outputTokens,cacheRead,cacheCreate,- );+ )+ : this.codexTranscript(det, model, inputTokens, outputTokens, cacheRead, cacheCreate);writeFileSync(transcriptPath, lines.join("\n"));writeFileSync(diff --git a/src/runners/multiModel.ts b/src/runners/multiModel.tsnew file mode 100644index 0000000..9cd6c1e--- /dev/null+++ b/src/runners/multiModel.ts@@ -0,0 +1,156 @@+/**+ * 멀티모델 에이전트 러너 (opencode / openclaw / hermes).+ * 이 도구들은 provider/model 형식으로 모델을 받는 모델-불문 에이전트다.+ * 각 도구의 실제 호출 규약(웹 문서 기준):+ * - opencode: `opencode run --format json --model <provider>/<model> --dir <work> "<prompt>"`+ * - openclaw: `openclaw agent --message "<prompt>" --model <provider>/<model> --json`+ * - hermes: `hermes -z "<prompt>" --model <provider>/<model>` (stdout = 평문 결과)+ * fail-soft: 절대 throw 금지, 항상 output.txt + transcript.jsonl.+ */+import { mkdirSync, writeFileSync } from "node:fs";+import { join } from "node:path";+import { instructionFor, isLocalBench, setupTask, taskIds, verify } from "../benches/index";+import { parseComboId } from "../combos";+import { modelFamily, providerFor, resolveModelAlias } from "../config";+import type { RawRunArtifact, RunInvocation } from "../models";+import { type RunnerAdapter, RunnerUnavailable } from "./base";+import { commandExists, execCapture } from "./util";++export interface MultiModelSpec {+ name: string;+ bin: string;+ /** 인자 빌더. modelArg 는 'provider/model' 또는 null('default' → 생략). */+ buildArgs(instruction: string, modelArg: string | null, work: string): string[];+ /** stdout 에서 사람이 읽을 결과 텍스트 추출. */+ extractResult(stdout: string): string;+}++export class MultiModelRunner implements RunnerAdapter {+ constructor(private spec: MultiModelSpec) {}++ get name(): string {+ return this.spec.name;+ }++ isAvailable(): boolean {+ return commandExists(this.spec.bin);+ }++ loadTaskCatalog(bench: string): string[] {+ if (isLocalBench(bench)) return taskIds(bench);+ throw new RunnerUnavailable(+ `${this.spec.name}: external bench '${bench}' not supported directly`,+ );+ }++ async run(inv: RunInvocation): Promise<RawRunArtifact> {+ const { model } = parseComboId(inv.combo.comboId);+ const work = inv.workDir;+ mkdirSync(work, { recursive: true });+ const resultPath = join(work, "output.txt");+ const transcriptPath = join(work, "transcript.jsonl");++ if (isLocalBench(inv.bench)) setupTask(inv.taskId, work);++ const instruction =+ inv.instruction ?? instructionFor(inv.taskId) ?? `Complete task ${inv.taskId}`;+ const resolved = resolveModelAlias(model);+ // 'default'(계정 기본)은 명시 모델 생략, 그 외엔 provider/model+ const modelArg =+ resolved === "default" ? null : `${providerFor(modelFamily(model))}/${resolved}`;++ const args = this.spec.buildArgs(instruction, modelArg, work);+ const res = await execCapture(this.spec.bin, args, { cwd: work, timeoutS: inv.timeoutS });++ writeFileSync(transcriptPath, res.stdout || "");+ writeFileSync(+ resultPath,+ res.stdout ? this.spec.extractResult(res.stdout) : res.stderr || "(no output)",+ );++ const ok = res.error === null && !res.timedOut && res.code === 0;+ const rawResolved = isLocalBench(inv.bench) ? verify(inv.taskId, work) : null;++ return {+ invocation: inv,+ success: ok,+ resultPath,+ transcriptPath,+ wallTimeMs: res.wallTimeMs,+ rawResolved,+ totalCostUsd: null, // 비용은 단가맵 추정으로 위임+ numTurns: null,+ error: res.error ?? (res.timedOut ? "timeout" : res.code !== 0 ? `exit ${res.code}` : null),+ };+ }+}++// ── 도구별 spec ──────────────────────────────────────────+function jsonTextFields(stdout: string): string {+ const texts: string[] = [];+ const collect = (n: unknown): void => {+ if (!n || typeof n !== "object") return;+ if (Array.isArray(n)) {+ for (const v of n) collect(v);+ return;+ }+ const o = n as Record<string, unknown>;+ if (typeof o.text === "string") texts.push(o.text);+ for (const v of Object.values(o)) collect(v);+ };+ for (const line of stdout.split("\n")) {+ const s = line.trim();+ if (!s) continue;+ try {+ collect(JSON.parse(s));+ } catch {+ // ignore+ }+ }+ return texts.join("\n") || stdout.trim();+}++export const OPENCODE_SPEC: MultiModelSpec = {+ name: "opencode",+ bin: "opencode",+ buildArgs: (instruction, modelArg, work) => [+ "run",+ "--format",+ "json",+ "--dir",+ work,+ ...(modelArg ? ["--model", modelArg] : []),+ instruction,+ ],+ extractResult: (stdout) => jsonTextFields(stdout),+};++export const OPENCLAW_SPEC: MultiModelSpec = {+ name: "openclaw",+ bin: "openclaw",+ buildArgs: (instruction, modelArg) => [+ "agent",+ "--message",+ instruction,+ "--json",+ ...(modelArg ? ["--model", modelArg] : []),+ ],+ extractResult: (stdout) => jsonTextFields(stdout),+};++export const HERMES_SPEC: MultiModelSpec = {+ name: "hermes",+ bin: "hermes",+ buildArgs: (instruction, modelArg) => [+ "-z",+ instruction,+ ...(modelArg ? ["--model", modelArg] : []),+ ],+ extractResult: (stdout) => stdout.trim(), // 평문+};++export const MULTIMODEL_SPECS: Record<string, MultiModelSpec> = {+ opencode: OPENCODE_SPEC,+ openclaw: OPENCLAW_SPEC,+ hermes: HERMES_SPEC,+};diff --git a/src/runners/registry.ts b/src/runners/registry.tsindex 2790fde..6c27abd 100644--- a/src/runners/registry.ts+++ b/src/runners/registry.ts@@ -9,6 +9,7 @@ import type { RunnerAdapter } from "./base";import { ClaudeCodeRunner } from "./claudeCode";import { CodexCliRunner } from "./codexCli";import { MockRunner } from "./mock";+import { MULTIMODEL_SPECS, MultiModelRunner } from "./multiModel";import { TerminalBenchRunner } from "./terminalBench";export interface RunnerChoice {@@ -18,17 +19,18 @@ export interface RunnerChoice {const AUTO_NAMES = new Set(["", "none", "auto"]);+function agentRunner(agent: string): RunnerAdapter | null {+ if (agent === "cc") return new ClaudeCodeRunner();+ if (agent === "codex") return new CodexCliRunner();+ const spec = MULTIMODEL_SPECS[agent];+ return spec ? new MultiModelRunner(spec) : null;+}+export function getRunner(name: string, failRate = 0): RunnerAdapter {- switch (name) {- case "cc":- return new ClaudeCodeRunner();- case "codex":- return new CodexCliRunner();- case "tb":- return new TerminalBenchRunner();- default:- return new MockRunner(failRate);- }+ if (name === "tb") return new TerminalBenchRunner();+ const r = agentRunner(name);+ if (r) return r;+ return new MockRunner(failRate);}export function runnerFor(@@ -41,9 +43,9 @@ export function runnerFor(if (opt === "mock") return { runner: new MockRunner(failRate), mock: true };- // 명시 러너 강제- if (opt === "cc") return { runner: new ClaudeCodeRunner(), mock: false };- if (opt === "codex") return { runner: new CodexCliRunner(), mock: false };+ // 명시 러너 강제 (cc / codex / opencode / openclaw / hermes)+ const forced = agentRunner(opt);+ if (forced) return { runner: forced, mock: false };if (opt === "tb") {const tb = new TerminalBenchRunner();return tb.isAvailable()@@ -54,10 +56,13 @@ export function runnerFor(// 자동 디스패치if (AUTO_NAMES.has(opt)) {if (isLocalBench(opts.bench)) {- const r = agent === "codex" ? new CodexCliRunner() : new ClaudeCodeRunner();- return r.isAvailable()- ? { runner: r, mock: false }- : { runner: new MockRunner(failRate), mock: true };+ const r = agentRunner(agent);+ if (r) {+ return r.isAvailable()+ ? { runner: r, mock: false }+ : { runner: new MockRunner(failRate), mock: true };+ }+ return { runner: new MockRunner(failRate), mock: true };}// 외부 벤치 → tb, 미설치 시 mockconst tb = new TerminalBenchRunner();diff --git a/src/transcripts/defensive.ts b/src/transcripts/defensive.tsnew file mode 100644index 0000000..bc66a28--- /dev/null+++ b/src/transcripts/defensive.ts@@ -0,0 +1,162 @@+/**+ * 방어적 파서 (opencode / openclaw / hermes).+ * 이 도구들의 출력 스키마는 부분적으로만 문서화돼 있어, 알려진 형태(JSONL 이벤트, 단일 JSON+ * 객체, 평문)를 모두 견디도록 재귀 스캔으로 토큰/도구/세션을 best-effort 추출한다.+ * 실제 codex 처럼 in-process 서브에이전트는 명시 마커가 없으면 0.+ */+import { readFileSync } from "node:fs";+import type { ParsedTranscript, TranscriptEvent } from "../models";+import { type TranscriptParser, compressTools, isMcp, truncate } from "./base";++interface Acc {+ in: number;+ out: number;+ cr: number;+ cc: number;+ toolCalls: number;+ subagents: number;+ mcp: number;+ tools: string[];+ steps: string[];+ logs: string[];+ session: string;+}++const TOKEN_KEYS: Record<string, keyof Pick<Acc, "in" | "out" | "cr" | "cc">> = {+ input_tokens: "in",+ prompt_tokens: "in",+ output_tokens: "out",+ completion_tokens: "out",+ cache_read_input_tokens: "cr",+ cached_input_tokens: "cr",+ cache_creation_input_tokens: "cc",+};++const TOOL_TYPE_RE = /tool|command|item\.completed|file_change|step/i;+const SUBAGENT_RE = /\b(task|subagent)\b/i;++function scan(node: unknown, acc: Acc, depth = 0): void {+ if (depth > 8 || node === null || typeof node !== "object") return;+ if (Array.isArray(node)) {+ for (const v of node) scan(v, acc, depth + 1);+ return;+ }+ const obj = node as Record<string, unknown>;+ for (const [k, v] of Object.entries(obj)) {+ if (typeof v === "number" && k in TOKEN_KEYS) acc[TOKEN_KEYS[k]!] += v;+ }+ // 세션 id+ for (const k of ["session_id", "thread_id", "sessionId", "threadId"]) {+ if (typeof obj[k] === "string" && !acc.session) acc.session = obj[k] as string;+ }+ // payloads[].text (openclaw) / text (opencode/hermes)+ if (typeof obj.text === "string") acc.logs.push(obj.text as string);+ // 이벤트/아이템 타입 → 도구·서브에이전트+ const type = typeof obj.type === "string" ? (obj.type as string) : "";+ const name = typeof obj.name === "string" ? (obj.name as string) : "";+ if (type && TOOL_TYPE_RE.test(type)) {+ acc.toolCalls += 1;+ acc.tools.push(name || type);+ acc.steps.push(name || type);+ if (SUBAGENT_RE.test(type) || SUBAGENT_RE.test(name)) acc.subagents += 1;+ if (isMcp(name) || isMcp(type)) acc.mcp += 1;+ }+ for (const v of Object.values(obj)) scan(v, acc, depth + 1);+}++export class DefensiveParser implements TranscriptParser {+ // 멀티모델 에이전트는 cc/codex 둘 다 아니므로 타입상 'codex' 로 분류(평탄 구조).+ agent = "codex" as const;+ constructor(private displayAgent: string) {}++ parse(transcriptPath: string, opts?: { model?: string }): ParsedTranscript {+ let raw = "";+ try {+ raw = readFileSync(transcriptPath, "utf8");+ } catch {+ // ignore+ }+ const acc: Acc = {+ in: 0,+ out: 0,+ cr: 0,+ cc: 0,+ toolCalls: 0,+ subagents: 0,+ mcp: 0,+ tools: [],+ steps: [],+ logs: [],+ session: "",+ };++ // JSONL 또는 단일 JSON 객체 모두 처리+ const lines = raw+ .split("\n")+ .map((l) => l.trim())+ .filter(Boolean);+ let parsedAny = false;+ for (const line of lines) {+ try {+ scan(JSON.parse(line), acc);+ parsedAny = true;+ } catch {+ // 평문 라인(hermes -z) — 로그로만 수집+ acc.logs.push(line);+ }+ }+ if (!parsedAny && raw.trim()) {+ try {+ scan(JSON.parse(raw), acc);+ } catch {+ // 전체가 평문+ }+ }++ const total = acc.in + acc.out + acc.cr + acc.cc;+ const rootEvent: TranscriptEvent = {+ idx: 0,+ tsMs: 0,+ endMs: 0,+ durationMs: 0,+ kind: "assistant",+ name: "main",+ parentIdx: null,+ inputTokens: acc.in,+ outputTokens: acc.out,+ cacheReadTokens: acc.cr,+ cacheCreationTokens: acc.cc,+ summaryIn: truncate(acc.logs[0] ?? ""),+ summaryOut: truncate(acc.logs[acc.logs.length - 1] ?? ""),+ status: "success",+ isSidechain: false,+ toolCalls: acc.toolCalls,+ skillFires: 0,+ toolsUsed: compressTools(acc.tools),+ skillsUsed: [],+ steps: acc.steps,+ logText: truncate(acc.logs.join("\n"), 1000),+ };++ return {+ agent: "codex",+ events: [rootEvent],+ sessionId: acc.session || `${this.displayAgent}-session`,+ model: opts?.model ?? "unknown",+ numTurns: Math.max(1, acc.toolCalls),+ toolCalls: acc.toolCalls,+ subagentCount: acc.subagents,+ skillFires: 0,+ mcpCalls: acc.mcp,+ inputTokens: acc.in,+ outputTokens: acc.out,+ cacheReadTokens: acc.cr,+ cacheCreationTokens: acc.cc,+ totalTokens: total,+ latencyMs: 0,+ skillsUsed: [],+ toolsUsed: compressTools(acc.tools),+ steps: acc.steps,+ };+ }+}diff --git a/src/transcripts/index.ts b/src/transcripts/index.tsindex dbe0a6b..9c516ee 100644--- a/src/transcripts/index.ts+++ b/src/transcripts/index.ts@@ -1,11 +1,16 @@import type { TranscriptParser } from "./base";import { ClaudeCodeParser } from "./claudeCode";import { CodexParser } from "./codex";+import { DefensiveParser } from "./defensive";export function parserFor(agent: string): TranscriptParser {- return agent === "codex" ? new CodexParser() : new ClaudeCodeParser();+ if (agent === "cc") return new ClaudeCodeParser();+ if (agent === "codex") return new CodexParser();+ // opencode / openclaw / hermes → 방어적 파서+ return new DefensiveParser(agent);}export * from "./base";export { ClaudeCodeParser } from "./claudeCode";export { CodexParser } from "./codex";+export { DefensiveParser } from "./defensive";diff --git a/tests/agents.test.ts b/tests/agents.test.tsnew file mode 100644index 0000000..7c47b56--- /dev/null+++ b/tests/agents.test.ts@@ -0,0 +1,122 @@+/**+ * L1 멀티모델 에이전트 (opencode / openclaw / hermes) — 추가 검증.+ * any-family 호환, 멀티모델 provider/model 매핑, 방어적 파서, registry 디스패치, fail-soft.+ */+import { mkdtempSync, readFileSync } 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 { agentFamilies, isMultiModelAgent, providerFor } from "../src/config";+import { MockRunner } from "../src/runners/mock";+import { MultiModelRunner } from "../src/runners/multiModel";+import { runnerFor } from "../src/runners/registry";+import { parserFor } from "../src/transcripts/index";++function tmp(): string {+ return mkdtempSync(join(tmpdir(), "theseus-mm-"));+}++describe("multi-model agents accept any family", () => {+ it("opencode/openclaw/hermes support both claude and gpt; cc/codex stay single-family", () => {+ for (const a of ["opencode", "openclaw", "hermes"]) {+ expect(agentFamilies(a).sort()).toEqual(["claude", "gpt"]);+ expect(isMultiModelAgent(a)).toBe(true);+ }+ expect(agentFamilies("cc")).toEqual(["claude"]);+ expect(agentFamilies("codex")).toEqual(["gpt"]);+ expect(isMultiModelAgent("cc")).toBe(false);+ });++ it("expand: opencode valid with both families, none-only harness", () => {+ const { valid, excluded } = expand(+ ["opus4.8", "gpt5.5"],+ ["opencode", "openclaw", "hermes"],+ ["none", "omc"],+ );+ const ids = valid.map((c) => c.comboId);+ expect(ids).toContain("opencode+opus4.8+none");+ expect(ids).toContain("opencode+gpt5.5+none");+ expect(ids).toContain("hermes+gpt5.5+none");+ // omc is cc-only → excluded for these agents (with reason)+ const bad = excluded.find((c) => c.comboId === "opencode+opus4.8+omc");+ expect(bad?.excludeReason).toMatch(/not compatible/);+ });+});++describe("provider/model mapping", () => {+ it("maps families to providers", () => {+ expect(providerFor("claude")).toBe("anthropic");+ expect(providerFor("gpt")).toBe("openai");+ });+});++describe("registry dispatch", () => {+ it("forces the right MultiModelRunner per agent name", () => {+ for (const a of ["opencode", "openclaw", "hermes"]) {+ const choice = runnerFor(a, a, { bench: "subagent" });+ expect(choice.runner).toBeInstanceOf(MultiModelRunner);+ expect(choice.runner.name).toBe(a);+ }+ });+ it("auto dispatch falls back to mock when the agent binary is absent (local bench)", () => {+ const choice = runnerFor("opencode", "auto", { bench: "subagent" });+ // 오프라인: opencode 미설치 → mock 폴백+ expect(choice.mock).toBe(true);+ });+});++describe("defensive parser via mock (flat, tokens summed, no subagents)", () => {+ it("opencode+gpt5.5 yields tokens and zero subagents; total = sum", async () => {+ const runner = new MockRunner(0);+ const work = tmp();+ const art = await runner.run({+ combo: {+ comboId: "opencode+gpt5.5+none",+ agent: "opencode",+ model: "gpt5.5",+ harness: "none",+ valid: true,+ },+ taskId: "subagent-102",+ runIdx: 0,+ workDir: work,+ timeoutS: 5,+ seed: 2,+ bench: "subagent",+ });+ const parsed = parserFor("opencode").parse(art.transcriptPath, { model: "gpt-5.5" });+ expect(parsed.totalTokens).toBeGreaterThan(0);+ expect(parsed.totalTokens).toBe(+ parsed.inputTokens ++ parsed.outputTokens ++ parsed.cacheReadTokens ++ parsed.cacheCreationTokens,+ );+ expect(parsed.subagentCount).toBe(0);+ });+});++describe("MultiModelRunner fail-soft when binary missing", () => {+ it("returns success:false + artifacts (never throws)", async () => {+ const choice = runnerFor("hermes", "hermes", { bench: "local" });+ const art = await choice.runner.run({+ combo: {+ comboId: "hermes+opus4.8+none",+ agent: "hermes",+ model: "opus4.8",+ harness: "none",+ valid: true,+ },+ taskId: "local-hello",+ runIdx: 0,+ workDir: tmp(),+ timeoutS: 2,+ seed: 0,+ bench: "local",+ });+ expect(art.success).toBe(false);+ expect(() => readFileSync(art.transcriptPath, "utf8")).not.toThrow();+ expect(() => readFileSync(art.resultPath, "utf8")).not.toThrow();+ });+});