@coder/aegis 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,144 @@
1
+ import type { ContrastDoc, GeneratedSuite, GraderSpecDoc, OverlayActionDoc, SkillApplicable } from "./schema.js";
2
+ export interface AuthoringGraderRef {
3
+ readonly kind: "aegis.grader-ref";
4
+ readonly id: string;
5
+ readonly spec: GraderSpecDoc;
6
+ readonly with?: Record<string, string>;
7
+ readonly inline?: boolean;
8
+ }
9
+ export interface ExperimentConfig {
10
+ backend: string;
11
+ backendOptions?: BackendOptionsInput;
12
+ hypothesis: string;
13
+ subject: ExperimentSubjectInput;
14
+ repeats: number;
15
+ budget: BudgetInput;
16
+ primaryMetric: string;
17
+ efficacyMetrics: string[];
18
+ guardrailMetrics: string[];
19
+ scheduling: SchedulingInput;
20
+ }
21
+ export interface BackendOptionsInput {
22
+ docker?: DockerBackendOptionsInput;
23
+ coder?: CoderBackendOptionsInput;
24
+ }
25
+ export interface DockerBackendOptionsInput {
26
+ image: string;
27
+ }
28
+ export interface CoderBackendOptionsInput {
29
+ template: string;
30
+ }
31
+ export interface ExperimentSubjectInput {
32
+ harness: string;
33
+ harnessVersion: string;
34
+ controlTransport: string;
35
+ model: string;
36
+ allowedTools: string[];
37
+ env?: Record<string, string>;
38
+ }
39
+ export interface BudgetInput {
40
+ maxUsd: number;
41
+ confirmRequired: boolean;
42
+ pilotMaxUsd: number;
43
+ }
44
+ export interface SchedulingInput {
45
+ order: string;
46
+ retry: string;
47
+ }
48
+ export interface SuiteInput {
49
+ setup?: string[];
50
+ defaultGraders?: AuthoringGraderRef[];
51
+ }
52
+ export interface BaseRepoInput {
53
+ git: {
54
+ repo: string;
55
+ ref: string;
56
+ };
57
+ tools?: string[];
58
+ env?: Record<string, string>;
59
+ }
60
+ export interface TestInput {
61
+ suite?: string;
62
+ baseRepo: string;
63
+ skillApplicable: SkillApplicable;
64
+ goldenOpCount?: number;
65
+ tags?: string[];
66
+ patches?: string[];
67
+ }
68
+ export interface AnalysisInput {
69
+ pairing: string;
70
+ perArmCI: string;
71
+ significance: string;
72
+ contrasts: Array<ContrastDoc | readonly [string, string]>;
73
+ }
74
+ export declare function defineExperiment(id: string, define: (evals: ExperimentBuilder) => void): GeneratedSuite;
75
+ export declare function graderRef(id: string, spec: GraderSpecDoc, withParams?: Record<string, string>): AuthoringGraderRef;
76
+ export declare function inlineGrader(id: string, spec: GraderSpecDoc): AuthoringGraderRef;
77
+ export declare class ExperimentBuilder {
78
+ private readonly id;
79
+ private config?;
80
+ private readonly suites;
81
+ private readonly baseRepos;
82
+ private readonly variants;
83
+ private readonly tasks;
84
+ private readonly registry;
85
+ private activeSuite?;
86
+ private analysisDoc?;
87
+ constructor(id: string);
88
+ configure(config: ExperimentConfig): void;
89
+ suite(id: string, input?: SuiteInput): void;
90
+ baseRepo(id: string, input: BaseRepoInput): void;
91
+ variant(id: string, define: (arm: VariantBuilder) => void): void;
92
+ test(id: string, input: TestInput, define: (test: TestBuilder) => void): void;
93
+ analysis(input: AnalysisInput): void;
94
+ customGrader(id: string, spec: GraderSpecDoc): CustomGraderHandle;
95
+ build(): GeneratedSuite;
96
+ private registerGrader;
97
+ private taskDoc;
98
+ }
99
+ export declare class VariantBuilder {
100
+ private readonly context;
101
+ private readonly overlay;
102
+ constructor(context: string);
103
+ remove(path: string): void;
104
+ file(path: string): OverlayFileSwapBuilder;
105
+ skill(skill: string): OverlaySkillSwapBuilder;
106
+ promptContext(value: string): void;
107
+ promptContextFile(file: string): void;
108
+ toolAllowlist(tools: string[]): void;
109
+ removeToolAllowlist(): void;
110
+ modelID(model: string): void;
111
+ harnessFlag(key: string, value: string): void;
112
+ removeHarnessFlag(key: string): void;
113
+ actions(): OverlayActionDoc[];
114
+ }
115
+ export declare class OverlayFileSwapBuilder {
116
+ private readonly overlay;
117
+ private readonly path;
118
+ constructor(overlay: OverlayActionDoc[], path: string);
119
+ from(file: string): void;
120
+ }
121
+ export declare class OverlaySkillSwapBuilder {
122
+ private readonly overlay;
123
+ private readonly skill;
124
+ constructor(overlay: OverlayActionDoc[], skill: string);
125
+ from(file: string): void;
126
+ remove(): void;
127
+ }
128
+ export declare class TestBuilder {
129
+ private readonly context;
130
+ private promptValue?;
131
+ private readonly expectations;
132
+ constructor(context: string);
133
+ promptText(): string | undefined;
134
+ prompt(strings: TemplateStringsArray | string, ...values: unknown[]): void;
135
+ expect(grader: AuthoringGraderRef): void;
136
+ graders(): AuthoringGraderRef[];
137
+ }
138
+ export declare class CustomGraderHandle {
139
+ private readonly id;
140
+ private readonly spec;
141
+ constructor(id: string, spec: GraderSpecDoc);
142
+ use(withParams?: Record<string, string>): AuthoringGraderRef;
143
+ }
144
+ export declare function assertCanonicalValue(context: string, value: unknown): void;
@@ -0,0 +1,33 @@
1
+ import { type ResolvedEvalSource } from "./layout.js";
2
+ import { type GeneratedSuite, type GraderRegistryDoc, type TaskDoc } from "./schema.js";
3
+ export declare const EVAL_BUNDLE_SCHEMA_VERSION = "aegis.eval_bundle/1.0";
4
+ export interface EvalBundleDoc {
5
+ schema_version: typeof EVAL_BUNDLE_SCHEMA_VERSION;
6
+ experiment: GeneratedSuite["experiment"];
7
+ tasks: TaskDoc[];
8
+ graders: GraderRegistryDoc;
9
+ assets: BundleAssetDoc[];
10
+ }
11
+ export interface BundleAssetDoc {
12
+ id: string;
13
+ kind: "inline_tree" | "git";
14
+ inline?: InlineTreeAssetDoc;
15
+ git?: GitAssetDoc;
16
+ }
17
+ export interface InlineTreeAssetDoc {
18
+ files: InlineFileDoc[];
19
+ }
20
+ export interface InlineFileDoc {
21
+ path: string;
22
+ encoding?: "base64";
23
+ content: string;
24
+ executable?: boolean;
25
+ }
26
+ export interface GitAssetDoc {
27
+ repo: string;
28
+ ref: string;
29
+ digest?: string;
30
+ }
31
+ export declare function cloneGeneratedSuite(suite: GeneratedSuite): GeneratedSuite;
32
+ export declare function buildEvalBundle(suite: GeneratedSuite, source: ResolvedEvalSource): Promise<EvalBundleDoc>;
33
+ export declare function serializeEvalBundle(bundle: EvalBundleDoc): string;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./index.js";
2
+ import "./cli.js";
@@ -0,0 +1,22 @@
1
+ import { type AuthoringGraderRef } from "./builder.js";
2
+ export type Pattern = string | RegExp;
3
+ export declare const qa: {
4
+ reportExists(): AuthoringGraderRef;
5
+ matches(pattern: Pattern): AuthoringGraderRef;
6
+ mentions(pattern: Pattern): AuthoringGraderRef;
7
+ mentionsBoth(patternA: Pattern, patternB: Pattern): AuthoringGraderRef;
8
+ };
9
+ export declare const trace: {
10
+ noAgentTtySession(): AuthoringGraderRef;
11
+ };
12
+ export interface JudgeSatisfiesOptions {
13
+ rubric: string;
14
+ criterion: string;
15
+ minScore: number;
16
+ model?: string;
17
+ validation?: Record<string, unknown>;
18
+ }
19
+ export declare const judge: {
20
+ satisfies(options: JudgeSatisfiesOptions): AuthoringGraderRef;
21
+ };
22
+ export declare function serializePattern(pattern: Pattern): string;
@@ -0,0 +1,4 @@
1
+ export { CustomGraderHandle, ExperimentBuilder, OverlayFileSwapBuilder, OverlaySkillSwapBuilder, TestBuilder, VariantBuilder, assertCanonicalValue, defineExperiment, graderRef, inlineGrader, type AnalysisInput, type AuthoringGraderRef, type BaseRepoInput, type BudgetInput, type ExperimentConfig, type ExperimentSubjectInput, type SchedulingInput, type SuiteInput, type TestInput, } from "./builder.js";
2
+ export { judge, qa, serializePattern, trace, type JudgeSatisfiesOptions, type Pattern } from "./graders.js";
3
+ export { SUPPORTED_GRADER_TYPES } from "./schema.js";
4
+ export type { AnalysisDoc, BaseRepoDoc, BudgetDoc, ContrastDoc, ExperimentDoc, ExperimentSubjectDoc, GeneratedSuite, GraderRegistryDoc, GraderSpecDoc, OverlayActionDoc, OverlayKindDoc, SchedulingDoc, SkillApplicable, SupportedGraderType, SuiteDoc, TaskDoc, TaskGraderDoc, TaskSeedDoc, VariantDoc, } from "./schema.js";
@@ -0,0 +1,23 @@
1
+ import type { GeneratedSuite, TaskDoc } from "./schema.js";
2
+ export type ResolvedEvalSource = FileEvalSource | LayoutEvalSource;
3
+ export interface FileEvalSource {
4
+ kind: "file";
5
+ sourcePath: string;
6
+ }
7
+ export interface LayoutEvalSource {
8
+ kind: "layout";
9
+ sourcePath: string;
10
+ layoutDir: string;
11
+ layoutName: string;
12
+ promptPath: string;
13
+ seedSrcDir: string;
14
+ }
15
+ export declare function resolveEvalSource(src: string): Promise<ResolvedEvalSource>;
16
+ export declare function layoutTask(suite: GeneratedSuite, layout: LayoutEvalSource): TaskDoc;
17
+ export declare function readLayoutPrompt(layout: LayoutEvalSource): Promise<string>;
18
+ export interface LayoutSeedFile {
19
+ path: string;
20
+ content: Buffer;
21
+ executable: boolean;
22
+ }
23
+ export declare function collectLayoutSeedFiles(seedSrcDir: string): Promise<LayoutSeedFile[]>;
@@ -0,0 +1,148 @@
1
+ export type SkillApplicable = "applicable" | "not_applicable" | "ambiguous";
2
+ export interface ExperimentDoc {
3
+ id: string;
4
+ backend: string;
5
+ backend_options?: BackendOptionsDoc;
6
+ hypothesis: string;
7
+ subject: ExperimentSubjectDoc;
8
+ suite: string;
9
+ grader_registry: string[];
10
+ suites: Record<string, SuiteDoc>;
11
+ base_repos: Record<string, BaseRepoDoc>;
12
+ variants: VariantDoc[];
13
+ repeats: number;
14
+ budget: BudgetDoc;
15
+ primary_metric: string;
16
+ efficacy_metrics: string[];
17
+ guardrail_metrics: string[];
18
+ scheduling: SchedulingDoc;
19
+ analysis: AnalysisDoc;
20
+ }
21
+ export interface BackendOptionsDoc {
22
+ docker?: DockerBackendOptionsDoc;
23
+ coder?: CoderBackendOptionsDoc;
24
+ }
25
+ export interface DockerBackendOptionsDoc {
26
+ image: string;
27
+ }
28
+ export interface CoderBackendOptionsDoc {
29
+ template: string;
30
+ }
31
+ export interface ExperimentSubjectDoc {
32
+ harness: string;
33
+ harness_version: string;
34
+ control_transport: string;
35
+ model: string;
36
+ allowed_tools: string[];
37
+ env: Record<string, string>;
38
+ }
39
+ export interface SuiteDoc {
40
+ default_graders: string[];
41
+ setup: string[];
42
+ }
43
+ export interface BaseRepoDoc {
44
+ git: GitRefDoc;
45
+ tools: string[];
46
+ env: Record<string, string>;
47
+ }
48
+ export interface GitRefDoc {
49
+ repo: string;
50
+ ref: string;
51
+ }
52
+ export interface VariantDoc {
53
+ id: string;
54
+ overlay: OverlayActionDoc[];
55
+ }
56
+ export type OverlayKindDoc = "file" | "skill" | "prompt/context-delta" | "tool-allowlist-delta" | "model-id-delta" | "harness-flag-delta";
57
+ export interface OverlayActionDoc {
58
+ kind: OverlayKindDoc;
59
+ op: "swap" | "remove";
60
+ path?: string;
61
+ skill?: string;
62
+ file?: string;
63
+ value?: string;
64
+ key?: string;
65
+ tools?: string[];
66
+ model?: string;
67
+ }
68
+ export interface BudgetDoc {
69
+ max_usd: number;
70
+ confirm_required: boolean;
71
+ pilot_max_usd: number;
72
+ }
73
+ export interface SchedulingDoc {
74
+ order: string;
75
+ retry: string;
76
+ }
77
+ export interface AnalysisDoc {
78
+ pairing: string;
79
+ per_arm_ci: string;
80
+ significance: string;
81
+ contrasts: ContrastDoc[];
82
+ }
83
+ export interface ContrastDoc {
84
+ from: string;
85
+ to: string;
86
+ }
87
+ export interface TaskDoc {
88
+ id: string;
89
+ suite: string;
90
+ prompt: string;
91
+ seed: TaskSeedDoc;
92
+ skill_applicable: SkillApplicable;
93
+ golden_op_count?: number;
94
+ graders: TaskGraderDoc[];
95
+ tags: string[];
96
+ }
97
+ export interface TaskSeedDoc {
98
+ base_repo: string;
99
+ patches?: string[];
100
+ }
101
+ export interface TaskGraderDoc {
102
+ use?: string;
103
+ with?: Record<string, string | number | boolean>;
104
+ id?: string;
105
+ type?: SupportedGraderType;
106
+ run?: string;
107
+ timeout_s?: number;
108
+ assert?: string;
109
+ path?: string;
110
+ baseline?: string;
111
+ file?: string;
112
+ section?: string;
113
+ params?: string[];
114
+ match?: string;
115
+ regression?: boolean;
116
+ exploit?: boolean;
117
+ }
118
+ export type GraderRegistryDoc = Record<string, GraderSpecDoc>;
119
+ export declare const SUPPORTED_GRADER_TYPES: readonly ["command", "state", "trace", "judge", "subprocess"];
120
+ export type SupportedGraderType = (typeof SUPPORTED_GRADER_TYPES)[number];
121
+ export interface GraderSpecDoc {
122
+ id?: string;
123
+ type: SupportedGraderType;
124
+ run?: string;
125
+ binary?: string;
126
+ env?: Record<string, string>;
127
+ timeout_s?: number;
128
+ assert?: string;
129
+ guardrail?: boolean;
130
+ metric?: boolean;
131
+ regression?: boolean;
132
+ exploit?: boolean;
133
+ path?: string;
134
+ baseline?: string;
135
+ file?: string;
136
+ section?: string;
137
+ params?: string[];
138
+ match?: string;
139
+ probe?: string;
140
+ rubric?: string;
141
+ model?: string;
142
+ args?: Record<string, unknown>;
143
+ }
144
+ export interface GeneratedSuite {
145
+ experiment: ExperimentDoc;
146
+ tasks: TaskDoc[];
147
+ graders: GraderRegistryDoc;
148
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@coder/aegis",
3
+ "version": "0.1.0",
4
+ "description": "aegis CLI and TypeScript eval-authoring facade (Go binary with embedded TS eval compiler and web UI, plus the @coder/aegis import surface)",
5
+ "type": "module",
6
+ "bin": {
7
+ "aegis": "bin/aegis.mjs"
8
+ },
9
+ "types": "./lib/types/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./lib/types/index.d.ts",
13
+ "import": "./lib/index.js",
14
+ "default": "./lib/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "lib"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/coder/aegis.git"
24
+ },
25
+ "optionalDependencies": {
26
+ "@coder/aegis-linux-x64": "0.1.0",
27
+ "@coder/aegis-linux-arm64": "0.1.0",
28
+ "@coder/aegis-darwin-x64": "0.1.0",
29
+ "@coder/aegis-darwin-arm64": "0.1.0",
30
+ "@coder/aegis-win32-x64": "0.1.0"
31
+ }
32
+ }