feat: surface codex thread config progress

This commit is contained in:
AI Bot
2026-06-01 17:18:28 +08:00
parent 591638f35f
commit 26b5e97614
10 changed files with 540 additions and 5 deletions

View File

@@ -187,6 +187,33 @@ export interface ExecutionProgressRemoteControl {
environmentId?: string;
}
export interface ExecutionProgressThreadGoal {
objective?: string;
status: string;
tokenBudget?: number;
tokensUsed?: number;
timeUsedSeconds?: number;
}
export interface ExecutionProgressThreadSettings {
model?: string;
modelProvider?: string;
approvalPolicy?: string;
approvalsReviewer?: string;
sandboxPolicy?: string;
permissionProfile?: string;
serviceTier?: string;
effort?: string;
summary?: string;
collaborationMode?: string;
personality?: string;
}
export interface ExecutionProgressCompaction {
status: string;
message?: string;
}
export interface ExecutionProgressSnapshot {
taskId: string;
projectId: string;
@@ -211,6 +238,9 @@ export interface ExecutionProgressSnapshot {
tokenUsage?: ExecutionProgressTokenUsage;
mcpServers?: ExecutionProgressMcpServer[];
remoteControl?: ExecutionProgressRemoteControl;
threadGoal?: ExecutionProgressThreadGoal;
threadSettings?: ExecutionProgressThreadSettings;
compaction?: ExecutionProgressCompaction;
updatedAt: string;
}
@@ -228,6 +258,9 @@ export interface ExecutionProgressInput {
tokenUsage?: Partial<ExecutionProgressTokenUsage>;
mcpServers?: Array<Partial<ExecutionProgressMcpServer> & { name?: string }>;
remoteControl?: Partial<ExecutionProgressRemoteControl> & { installationId?: unknown };
threadGoal?: Partial<ExecutionProgressThreadGoal>;
threadSettings?: Partial<ExecutionProgressThreadSettings> & { cwd?: unknown };
compaction?: Partial<ExecutionProgressCompaction> & { turnId?: unknown };
}
export interface ForwardSource {
@@ -3905,6 +3938,9 @@ function normalizeExecutionProgressSnapshot(raw: Partial<ExecutionProgressSnapsh
tokenUsage: nativeRemoteControl ? undefined : normalizeExecutionProgressTokenUsage(raw.tokenUsage),
mcpServers: nativeRemoteControl ? undefined : normalizeExecutionProgressMcpServers(raw.mcpServers),
remoteControl: nativeRemoteControl ? undefined : normalizeExecutionProgressRemoteControl(raw.remoteControl),
threadGoal: nativeRemoteControl ? undefined : normalizeExecutionProgressThreadGoal(raw.threadGoal),
threadSettings: nativeRemoteControl ? undefined : normalizeExecutionProgressThreadSettings(raw.threadSettings),
compaction: nativeRemoteControl ? undefined : normalizeExecutionProgressCompaction(raw.compaction),
updatedAt: raw.updatedAt ?? nowIso(),
};
}
@@ -5565,6 +5601,65 @@ function normalizeExecutionProgressRemoteControl(
};
}
function normalizeExecutionProgressThreadGoal(
input?: ExecutionProgressInput["threadGoal"],
): ExecutionProgressThreadGoal | undefined {
if (!input) {
return undefined;
}
const status = safeExecutionProgressText(input.status);
const objective = safeExecutionProgressText(input.objective);
if (!status && !objective) {
return undefined;
}
return {
objective: objective || undefined,
status: status || "active",
tokenBudget: normalizeOptionalNumber(input.tokenBudget),
tokensUsed: normalizeOptionalNumber(input.tokensUsed),
timeUsedSeconds: normalizeOptionalNumber(input.timeUsedSeconds),
};
}
function normalizeExecutionProgressThreadSettings(
input?: ExecutionProgressInput["threadSettings"],
): ExecutionProgressThreadSettings | undefined {
if (!input) {
return undefined;
}
const settings: ExecutionProgressThreadSettings = {
model: safeExecutionProgressText(input.model) || undefined,
modelProvider: safeExecutionProgressText(input.modelProvider) || undefined,
approvalPolicy: safeExecutionProgressText(input.approvalPolicy) || undefined,
approvalsReviewer: safeExecutionProgressText(input.approvalsReviewer) || undefined,
sandboxPolicy: safeExecutionProgressText(input.sandboxPolicy) || undefined,
permissionProfile: safeExecutionProgressText(input.permissionProfile) || undefined,
serviceTier: safeExecutionProgressText(input.serviceTier) || undefined,
effort: safeExecutionProgressText(input.effort) || undefined,
summary: safeExecutionProgressText(input.summary) || undefined,
collaborationMode: safeExecutionProgressText(input.collaborationMode) || undefined,
personality: safeExecutionProgressText(input.personality) || undefined,
};
return Object.values(settings).some((value) => value !== undefined && value !== "") ? settings : undefined;
}
function normalizeExecutionProgressCompaction(
input?: ExecutionProgressInput["compaction"],
): ExecutionProgressCompaction | undefined {
if (!input) {
return undefined;
}
const status = safeExecutionProgressText(input.status);
const message = safeExecutionProgressText(input.message);
if (!status && !message) {
return undefined;
}
return {
status: status || "completed",
message: message || undefined,
};
}
function defaultExecutionProgressStepTexts(task: Pick<MasterAgentTask, "taskType" | "relayViaMasterAgent">) {
if (task.taskType === "browser_control") {
return [
@@ -5706,6 +5801,9 @@ function buildExecutionProgressSnapshot(
tokenUsage: nativeRemoteControl ? undefined : normalizeExecutionProgressTokenUsage(input?.tokenUsage),
mcpServers: nativeRemoteControl ? undefined : normalizeExecutionProgressMcpServers(input?.mcpServers),
remoteControl: nativeRemoteControl ? undefined : normalizeExecutionProgressRemoteControl(input?.remoteControl),
threadGoal: nativeRemoteControl ? undefined : normalizeExecutionProgressThreadGoal(input?.threadGoal),
threadSettings: nativeRemoteControl ? undefined : normalizeExecutionProgressThreadSettings(input?.threadSettings),
compaction: nativeRemoteControl ? undefined : normalizeExecutionProgressCompaction(input?.compaction),
updatedAt: nowIso(),
};
}