baa-conductor


baa-conductor / apps / codexd / src
im_wower  ·  2026-03-22

contracts.ts

  1export type CodexdCliAction = "config" | "help" | "smoke" | "start" | "status";
  2export type CodexdChildStrategy = "external" | "spawn";
  3export type CodexdManagedChildStatus = "external" | "failed" | "idle" | "running" | "starting" | "stopped";
  4export type CodexdEventLevel = "error" | "info" | "warn";
  5export type CodexdRunStatus = "completed" | "failed" | "queued" | "running";
  6export type CodexdServerMode = "app-server" | "exec";
  7export type CodexdSessionPurpose = "duplex" | "smoke" | "worker";
  8export type CodexdSessionStatus = "active" | "closed";
  9
 10export type CodexdEnvironment = Record<string, string | undefined>;
 11
 12export interface CodexdRuntimePaths {
 13  repoRoot: string;
 14  logsRootDir: string;
 15  stateRootDir: string;
 16  logsDir: string;
 17  stateDir: string;
 18  structuredEventLogPath: string;
 19  stdoutLogPath: string;
 20  stderrLogPath: string;
 21  identityPath: string;
 22  daemonStatePath: string;
 23  sessionRegistryPath: string;
 24  runRegistryPath: string;
 25  recentEventsPath: string;
 26}
 27
 28export interface CodexdServerConfig {
 29  mode: CodexdServerMode;
 30  endpoint: string;
 31  childStrategy: CodexdChildStrategy;
 32  childCommand: string;
 33  childArgs: string[];
 34  childCwd: string;
 35}
 36
 37export interface CodexdLocalServiceConfig {
 38  eventStreamPath: string;
 39  localApiBase: string;
 40}
 41
 42export interface CodexdResolvedConfig {
 43  nodeId: string;
 44  version: string | null;
 45  eventCacheSize: number;
 46  smokeLifetimeMs: number;
 47  paths: CodexdRuntimePaths;
 48  service: CodexdLocalServiceConfig;
 49  server: CodexdServerConfig;
 50}
 51
 52export interface CodexdDaemonIdentity {
 53  daemonId: string;
 54  nodeId: string;
 55  repoRoot: string;
 56  createdAt: string;
 57  version: string | null;
 58}
 59
 60export interface CodexdManagedChildState {
 61  strategy: CodexdChildStrategy;
 62  mode: CodexdServerMode;
 63  endpoint: string;
 64  status: CodexdManagedChildStatus;
 65  command: string | null;
 66  args: string[];
 67  cwd: string | null;
 68  pid: number | null;
 69  startedAt: string | null;
 70  exitedAt: string | null;
 71  exitCode: number | null;
 72  signal: string | null;
 73  lastError: string | null;
 74}
 75
 76export interface CodexdDaemonState {
 77  started: boolean;
 78  startedAt: string | null;
 79  stoppedAt: string | null;
 80  updatedAt: string;
 81  pid: number | null;
 82  child: CodexdManagedChildState;
 83}
 84
 85export interface CodexdSessionRecord {
 86  sessionId: string;
 87  purpose: CodexdSessionPurpose;
 88  threadId: string | null;
 89  status: CodexdSessionStatus;
 90  endpoint: string;
 91  childPid: number | null;
 92  createdAt: string;
 93  updatedAt: string;
 94  cwd: string | null;
 95  model: string | null;
 96  modelProvider: string | null;
 97  serviceTier: string | null;
 98  reasoningEffort: string | null;
 99  currentTurnId: string | null;
100  lastTurnId: string | null;
101  lastTurnStatus: string | null;
102  metadata: Record<string, string>;
103}
104
105export interface CodexdSessionRegistryState {
106  updatedAt: string | null;
107  sessions: CodexdSessionRecord[];
108}
109
110export interface CodexdRunRecord {
111  runId: string;
112  sessionId: string | null;
113  status: CodexdRunStatus;
114  adapter: string;
115  prompt: string;
116  purpose: string | null;
117  cwd: string | null;
118  createdAt: string;
119  updatedAt: string;
120  startedAt: string | null;
121  finishedAt: string | null;
122  error: string | null;
123  summary: string | null;
124  metadata: Record<string, string>;
125  result: Record<string, unknown> | null;
126}
127
128export interface CodexdRunRegistryState {
129  updatedAt: string | null;
130  runs: CodexdRunRecord[];
131}
132
133export interface CodexdRecentEvent {
134  seq: number;
135  createdAt: string;
136  level: CodexdEventLevel;
137  type: string;
138  message: string;
139  detail: Record<string, unknown> | null;
140}
141
142export interface CodexdRecentEventCacheState {
143  maxEntries: number;
144  updatedAt: string | null;
145  events: CodexdRecentEvent[];
146}
147
148export interface CodexdStatusSnapshot {
149  config: CodexdResolvedConfig;
150  identity: CodexdDaemonIdentity;
151  daemon: CodexdDaemonState;
152  sessionRegistry: CodexdSessionRegistryState;
153  runRegistry: CodexdRunRegistryState;
154  recentEvents: CodexdRecentEventCacheState;
155}
156
157export interface CodexdSmokeCheck {
158  name: string;
159  status: "failed" | "ok";
160  detail: string;
161}
162
163export interface CodexdSmokeResult {
164  checks: CodexdSmokeCheck[];
165  snapshot: CodexdStatusSnapshot;
166}