feat: map codex realtime thread status
This commit is contained in:
@@ -138,6 +138,27 @@ export interface ExecutionProgressFileChange {
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export interface ExecutionProgressThreadStatus {
|
||||
type: string;
|
||||
activeFlags?: string[];
|
||||
waitingOnApproval?: boolean;
|
||||
waitingOnUserInput?: boolean;
|
||||
}
|
||||
|
||||
export type ExecutionProgressRealtimeStatus = "started" | "streaming" | "closed" | "error";
|
||||
|
||||
export interface ExecutionProgressRealtime {
|
||||
status: ExecutionProgressRealtimeStatus;
|
||||
sessionId?: string;
|
||||
version?: string;
|
||||
transcriptRole?: string;
|
||||
transcriptPreview?: string;
|
||||
audioChunkCount?: number;
|
||||
itemCount?: number;
|
||||
lastError?: string;
|
||||
closeReason?: string;
|
||||
}
|
||||
|
||||
export interface ExecutionProgressSnapshot {
|
||||
taskId: string;
|
||||
projectId: string;
|
||||
@@ -156,6 +177,8 @@ export interface ExecutionProgressSnapshot {
|
||||
approvals?: ExecutionProgressApproval[];
|
||||
warnings?: ExecutionProgressWarning[];
|
||||
fileChanges?: ExecutionProgressFileChange[];
|
||||
threadStatus?: ExecutionProgressThreadStatus;
|
||||
realtime?: ExecutionProgressRealtime;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
@@ -167,6 +190,8 @@ export interface ExecutionProgressInput {
|
||||
approvals?: Array<Partial<ExecutionProgressApproval> & { label?: string }>;
|
||||
warnings?: Array<Partial<ExecutionProgressWarning> & { message?: string }>;
|
||||
fileChanges?: Array<Partial<ExecutionProgressFileChange> & { path?: string }>;
|
||||
threadStatus?: Partial<ExecutionProgressThreadStatus>;
|
||||
realtime?: Partial<ExecutionProgressRealtime>;
|
||||
}
|
||||
|
||||
export interface ForwardSource {
|
||||
@@ -3838,6 +3863,8 @@ function normalizeExecutionProgressSnapshot(raw: Partial<ExecutionProgressSnapsh
|
||||
approvals: nativeRemoteControl ? undefined : normalizeExecutionProgressApprovals(raw.approvals),
|
||||
warnings: nativeRemoteControl ? undefined : normalizeExecutionProgressWarnings(raw.warnings),
|
||||
fileChanges: nativeRemoteControl ? undefined : normalizeExecutionProgressFileChanges(raw.fileChanges),
|
||||
threadStatus: nativeRemoteControl ? undefined : normalizeExecutionProgressThreadStatus(raw.threadStatus),
|
||||
realtime: nativeRemoteControl ? undefined : normalizeExecutionProgressRealtime(raw.realtime),
|
||||
updatedAt: raw.updatedAt ?? nowIso(),
|
||||
};
|
||||
}
|
||||
@@ -5364,6 +5391,60 @@ function normalizeExecutionProgressFileChanges(input?: ExecutionProgressInput["f
|
||||
.slice(0, 12);
|
||||
}
|
||||
|
||||
function normalizeExecutionProgressThreadStatus(
|
||||
input?: ExecutionProgressInput["threadStatus"],
|
||||
): ExecutionProgressThreadStatus | undefined {
|
||||
if (!input) {
|
||||
return undefined;
|
||||
}
|
||||
const type = safeExecutionProgressText(input.type);
|
||||
if (!type) {
|
||||
return undefined;
|
||||
}
|
||||
const activeFlags = Array.isArray(input.activeFlags)
|
||||
? input.activeFlags
|
||||
.map((flag) => safeExecutionProgressText(flag))
|
||||
.filter(Boolean)
|
||||
.slice(0, 6)
|
||||
: [];
|
||||
return {
|
||||
type,
|
||||
...(activeFlags.length > 0 ? { activeFlags } : {}),
|
||||
...(input.waitingOnApproval === true || activeFlags.includes("waitingOnApproval")
|
||||
? { waitingOnApproval: true }
|
||||
: {}),
|
||||
...(input.waitingOnUserInput === true || activeFlags.includes("waitingOnUserInput")
|
||||
? { waitingOnUserInput: true }
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeExecutionProgressRealtime(
|
||||
input?: ExecutionProgressInput["realtime"],
|
||||
): ExecutionProgressRealtime | undefined {
|
||||
if (!input) {
|
||||
return undefined;
|
||||
}
|
||||
const status =
|
||||
input.status === "started" || input.status === "streaming" || input.status === "closed" || input.status === "error"
|
||||
? input.status
|
||||
: undefined;
|
||||
if (!status) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
status,
|
||||
sessionId: safeExecutionProgressText(input.sessionId) || undefined,
|
||||
version: safeExecutionProgressText(input.version) || undefined,
|
||||
transcriptRole: safeExecutionProgressText(input.transcriptRole) || undefined,
|
||||
transcriptPreview: safeExecutionProgressText(input.transcriptPreview) || undefined,
|
||||
audioChunkCount: normalizeOptionalNumber(input.audioChunkCount),
|
||||
itemCount: normalizeOptionalNumber(input.itemCount),
|
||||
lastError: safeExecutionProgressText(input.lastError) || undefined,
|
||||
closeReason: safeExecutionProgressText(input.closeReason) || undefined,
|
||||
};
|
||||
}
|
||||
|
||||
function defaultExecutionProgressStepTexts(task: Pick<MasterAgentTask, "taskType" | "relayViaMasterAgent">) {
|
||||
if (task.taskType === "browser_control") {
|
||||
return [
|
||||
@@ -5499,6 +5580,8 @@ function buildExecutionProgressSnapshot(
|
||||
approvals: nativeRemoteControl ? undefined : normalizeExecutionProgressApprovals(input?.approvals),
|
||||
warnings: nativeRemoteControl ? undefined : normalizeExecutionProgressWarnings(input?.warnings),
|
||||
fileChanges: nativeRemoteControl ? undefined : normalizeExecutionProgressFileChanges(input?.fileChanges),
|
||||
threadStatus: nativeRemoteControl ? undefined : normalizeExecutionProgressThreadStatus(input?.threadStatus),
|
||||
realtime: nativeRemoteControl ? undefined : normalizeExecutionProgressRealtime(input?.realtime),
|
||||
updatedAt: nowIso(),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user