File size: 2,471 Bytes
4e23b01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | import type { TranscriptFrame } from './frame';
import type { AttachmentId, StepId, TaskId, TurnId } from './ids';
export type TurnOrigin =
| { kind: 'user'; payload?: unknown }
| { kind: 'cron'; taskId?: TaskId; payload?: unknown }
| { kind: 'task'; taskId: TaskId; payload?: unknown }
| { kind: 'hook'; payload?: unknown }
| { kind: 'compaction'; payload?: unknown }
| { kind: 'side'; payload?: unknown }
| { kind: 'other'; payload?: unknown };
export type TurnState = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
export type StepState = 'running' | 'completed' | 'interrupted' | 'failed';
export interface TranscriptUsage {
readonly inputTokens?: number;
readonly outputTokens?: number;
readonly cachedTokens?: number;
readonly cost?: number;
}
export interface StepUsage {
readonly inputOther: number;
readonly output: number;
readonly inputCacheRead: number;
readonly inputCacheCreation: number;
}
export interface StepTiming {
readonly llmFirstTokenLatencyMs?: number;
readonly llmStreamDurationMs?: number;
readonly llmRequestBuildMs?: number;
readonly llmServerFirstTokenMs?: number;
readonly llmServerDecodeMs?: number;
readonly llmClientConsumeMs?: number;
readonly llmClientBlockedMs?: number;
}
export interface StepRetry {
readonly failedAttempt: number;
readonly nextAttempt: number;
readonly maxAttempts: number;
readonly delayMs: number;
readonly errorName: string;
readonly errorMessage: string;
readonly statusCode?: number;
}
export interface TranscriptTurn {
readonly kind: 'turn';
readonly turnId: TurnId;
readonly triggerPromptId?: string;
readonly ordinal: number;
readonly state: TurnState;
readonly origin: TurnOrigin;
readonly prompt?: string;
readonly attachmentIds?: readonly AttachmentId[];
readonly steps: TranscriptStep[];
readonly startedAt?: string;
readonly endedAt?: string;
readonly usage?: TranscriptUsage;
readonly durationMs?: number;
readonly error?: string;
}
export interface TranscriptStep {
readonly kind: 'step';
readonly stepId: StepId;
readonly turnId: TurnId;
readonly ordinal: number;
readonly state: StepState;
readonly frames: TranscriptFrame[];
readonly startedAt?: string;
readonly endedAt?: string;
readonly usage?: StepUsage;
readonly finishReason?: string;
readonly timing?: StepTiming;
readonly retry?: StepRetry;
readonly endReason?: string;
readonly endMessage?: string;
}
|