Skip to content
Myr

event.ts

This file

Path

scripts/lib/swarm/harnesses/event.ts

60 lines · 1.9 KiB · TypeScript

Last changed by

Merge build/comments-ops into mainoscabrielbefore adoptione4c407e

History of this file

Take it

Merge build/comments-ops into mainoscabrielbefore adoptione4c407e

line 1why, one step back
1// Apart from `index.ts`, so no driver imports the module that imports it.

Merge branch 'build/711-swarm-drivers-and-verdict-loop'oscabrielbefore adoption3210514

lines 2–9why, one step back
2import type { Option } from "effect";
3import { Data, Schema } from "effect";45import type { Harness } from "../results.ts";6import type { AgentWorkspace } from "../workspace.ts";78export type HarnessEvent = Data.TaggedEnum<{9 SessionStarted: { readonly id: string };

Merge build/comments-ops into mainoscabrielbefore adoptione4c407e

line 10why, one step back
10 // Per response (pi, OpenCode, Amp) or per run (Claude Code); cached input counts as input.

Merge branch 'build/711-swarm-drivers-and-verdict-loop'oscabrielbefore adoption3210514

lines 11–16why, one step back
11 Usage: {
12 readonly input: number;13 readonly output: number;14 readonly stopReason: Option.Option<string>;15 };16 Settled: { readonly stopReason: Option.Option<string> };

Merge build/comments-ops into mainoscabrielbefore adoptione4c407e

line 17why, one step back
17 // A `Usage` after it means the harness recovered (pi retries on its own).

Merge branch 'build/711-swarm-drivers-and-verdict-loop'oscabrielbefore adoption3210514

lines 18–60why, one step back
18 Failed: { readonly reason: string };
19}>;2021export const HarnessEvent = Data.taggedEnum<HarnessEvent>();2223export interface WorkspaceFile {24 readonly path: string;25 readonly content: string;26}2728export interface StartInput {29 readonly workspace: AgentWorkspace;30 readonly brief: string;31 readonly model: string;32 readonly adapter: boolean;33 readonly sessionDir: string;34 readonly sessionKey: string;35}3637export interface ResumeInput {38 readonly session: string;39 readonly prompt: string;40 readonly model: string;41 readonly workspace: AgentWorkspace;42 readonly adapter: boolean;43}4445export interface HarnessDriver {46 readonly harness: Harness;47 readonly start: (input: StartInput) => readonly string[];48 readonly resume: (input: ResumeInput) => readonly string[];49 readonly parse: (line: string) => readonly HarnessEvent[];50 readonly files: (workspace: AgentWorkspace) => readonly WorkspaceFile[];51}5253export const sessionDirOf = (dir: string) => `${dir}/sessions`;5455export const lineAs =56 <A, I>(schema: Schema.Codec<A, I>) =>57 (line: string): Option.Option<A> =>58 Schema.decodeOption(Schema.fromJsonString(schema))(line);5960export const Tokens = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));