CREATE TABLE IF NOT EXISTS "harness_agent_configs" (
	"id" text PRIMARY KEY NOT NULL,
	"name" text NOT NULL,
	"runtime" text NOT NULL,
	"model_id" text NOT NULL,
	"provider" text NOT NULL,
	"max_tokens" integer,
	"env" jsonb,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "harness_credentials" (
	"id" text PRIMARY KEY NOT NULL,
	"provider" text NOT NULL,
	"label" text NOT NULL,
	"token" text NOT NULL,
	"base_url" text,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "harness_curated_models" (
	"id" text PRIMARY KEY NOT NULL,
	"name" text NOT NULL,
	"provider" text NOT NULL,
	"enabled" boolean DEFAULT true NOT NULL,
	"context_window" integer,
	"cost_per_1k_input" real,
	"cost_per_1k_output" real,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "harness_iterations" (
	"id" serial PRIMARY KEY NOT NULL,
	"task_id" text NOT NULL,
	"n" integer NOT NULL,
	"status" text DEFAULT 'pending' NOT NULL,
	"diagnosis" text,
	"agent_output" text,
	"evals" jsonb,
	"diff_stats" text,
	"started_at" bigint,
	"completed_at" bigint
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "harness_model_usage" (
	"id" serial PRIMARY KEY NOT NULL,
	"model_id" text NOT NULL,
	"provider" text NOT NULL,
	"task_id" text NOT NULL,
	"task_slug" text NOT NULL,
	"iteration" integer NOT NULL,
	"input_tokens" integer NOT NULL,
	"output_tokens" integer NOT NULL,
	"duration_ms" integer NOT NULL,
	"timestamp" bigint NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "harness_tasks" (
	"id" text PRIMARY KEY NOT NULL,
	"slug" text NOT NULL,
	"goal" text NOT NULL,
	"status" text DEFAULT 'pending' NOT NULL,
	"iteration" integer DEFAULT 0 NOT NULL,
	"max_iterations" integer DEFAULT 6 NOT NULL,
	"started_at" bigint,
	"completed_at" bigint,
	"project" text DEFAULT '—' NOT NULL,
	"evals" jsonb DEFAULT '{}'::jsonb NOT NULL,
	"pr" jsonb,
	"spec" jsonb NOT NULL,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "users" (
	"id" serial PRIMARY KEY NOT NULL,
	"email" text NOT NULL,
	"name" text,
	"created_at" timestamp DEFAULT now() NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL,
	CONSTRAINT "users_email_unique" UNIQUE("email")
);
