import { WorkspaceRepository, CommandStatus, JobStatus, TokenUsageInsert } from "@mcoda/db"; export type JobState = JobStatus; export type CommandRunStatus = CommandStatus; export interface CommandRunRecord { id: string; commandName: string; workspaceId: string; projectKey?: string; jobId?: string; agentId?: string; taskIds?: string[]; gitBranch?: string; gitBaseBranch?: string; startedAt: string; completedAt?: string; status: CommandRunStatus; errorSummary?: string; durationSeconds?: number; spProcessed?: number | null; } export interface JobRecord { id: string; type: string; state: JobState; jobState?: JobState; jobStateDetail?: string; commandRunId?: string; commandName?: string; workspaceId: string; projectKey?: string; payload?: Record; agentId?: string; agentIds?: string[]; totalItems?: number; processedItems?: number; totalUnits?: number; completedUnits?: number; lastCheckpoint?: string; createdAt: string; updatedAt: string; completedAt?: string; errorSummary?: string; durationSeconds?: number; } export interface TokenUsageRecord extends TokenUsageInsert { commandName?: string; action?: string; invocationKind?: string; provider?: string; currency?: string; promptTokens?: number; completionTokens?: number; tokensCached?: number; tokensCacheRead?: number; tokensCacheWrite?: number; costUsd?: number; durationMs?: number; startedAt?: string; finishedAt?: string; metadata?: Record; } export interface JobCheckpoint { stage: string; timestamp: string; details?: Record; } export interface JobIterationProgress { current: number; max: number; phase?: string; } export interface JobProgressUpdate { stage: string; message: string; iteration?: JobIterationProgress; details?: Record; totalItems?: number; processedItems?: number; payload?: Record; heartbeat?: boolean; } export interface JobLogRow { timestamp: string; sequence?: number | null; level?: string | null; source?: string | null; message?: string | null; taskId?: string | null; taskKey?: string | null; phase?: string | null; details?: Record | null; } export interface TaskRunSnapshotRow { taskId?: string | null; taskKey?: string | null; status?: string | null; startedAt?: string | null; finishedAt?: string | null; command?: string | null; } type JobServiceWorkspace = string | { workspaceRoot: string; workspaceId?: string; mcodaDir?: string; }; export declare class JobService { private workspaceRepo?; private static activeJobs; private static signalHandlersRegistered; private static handlingSignal; private checkpointCounters; private workspaceRepoInit; private telemetryConfig?; private telemetryWarningShown; private telemetryRemoteWarningShown; private perRunTelemetryDisabled; private envTelemetryDisabled; private requireRepo; private workspaceRoot; private workspaceId; private mcodaDirOverride?; private static ensureSignalHandlers; private static registerActiveJob; private static unregisterActiveJob; static cancelActiveJobs(signal: NodeJS.Signals): Promise; private static handleProcessSignal; constructor(workspace: JobServiceWorkspace, workspaceRepo?: WorkspaceRepository | undefined, options?: { noTelemetry?: boolean; requireRepo?: boolean; }); private get mcodaDir(); private get commandRunsPath(); private get jobsStorePath(); private get tokenUsagePath(); private jobDir; private manifestPath; private checkpointDir; private logsDir; private ensureMcoda; private cancelJobOnSignal; private cancelRunningTaskRuns; private readJsonArray; private writeJsonArray; private appendJsonArray; listJobs(): Promise; getJob(jobId: string): Promise; readManifest(jobId: string): Promise | undefined>; readCheckpoints(jobId: string): Promise; readLog(jobId: string): Promise; listJobLogs(jobId: string, options?: { since?: string; after?: { timestamp: string; sequence?: number | null; }; }): Promise; summarizeTaskRuns(jobId: string): Promise; startCommandRun(commandName: string, projectKey?: string, options?: { gitBranch?: string; gitBaseBranch?: string; taskIds?: string[]; jobId?: string; agentId?: string; }): Promise; finishCommandRun(runId: string, status: CommandRunStatus, errorSummary?: string, spProcessed?: number): Promise; startJob(type: string, commandRunId?: string, projectKey?: string, options?: { payload?: Record; commandName?: string; totalItems?: number; processedItems?: number; agentId?: string; agentIds?: string[]; }): Promise; private attachCommandRunToJob; updateJobStatus(jobId: string, state: JobState, metadata?: { payload?: Record; totalItems?: number; processedItems?: number; totalUnits?: number; completedUnits?: number; lastCheckpoint?: string; errorSummary?: string; [key: string]: unknown; }): Promise; private computeElapsed; recordJobProgress(jobId: string, input: JobProgressUpdate): Promise; recordIterationProgress(jobId: string, input: { current: number; max: number; phase: string; details?: Record; }): Promise; writeCheckpoint(jobId: string, checkpoint: JobCheckpoint): Promise; appendLog(jobId: string, content: string): Promise; private readTelemetryConfig; private shouldRecordTokenUsage; recordTokenUsage(entry: TokenUsageRecord): Promise; writeManifest(job: JobRecord, extras?: Record): Promise; close(): Promise; } export {}; //# sourceMappingURL=JobService.d.ts.map