feat: adapt codex app-server protocol updates
This commit is contained in:
@@ -1105,10 +1105,16 @@ export interface MasterAgentTask {
|
||||
attachmentDownloadUrl?: string;
|
||||
attachmentTextExcerpt?: string;
|
||||
dispatchExecutionId?: string;
|
||||
sourceProjectId?: string;
|
||||
sourceThreadId?: string;
|
||||
sourceThreadDisplayName?: string;
|
||||
sourceCodexThreadRef?: string;
|
||||
targetProjectId?: string;
|
||||
targetThreadId?: string;
|
||||
targetThreadDisplayName?: string;
|
||||
targetCodexThreadRef?: string;
|
||||
targetTurnId?: string;
|
||||
targetCodexTurnId?: string;
|
||||
targetCodexFolderRef?: string;
|
||||
orchestrationBackendId?: OrchestrationBackendId;
|
||||
orchestrationBackendLabel?: string;
|
||||
@@ -4447,10 +4453,16 @@ export function migrateBossState(raw: Partial<BossState> | undefined): BossState
|
||||
attachmentDownloadUrl: task.attachmentDownloadUrl,
|
||||
attachmentTextExcerpt: task.attachmentTextExcerpt,
|
||||
dispatchExecutionId: task.dispatchExecutionId,
|
||||
sourceProjectId: task.sourceProjectId,
|
||||
sourceThreadId: task.sourceThreadId,
|
||||
sourceThreadDisplayName: task.sourceThreadDisplayName,
|
||||
sourceCodexThreadRef: task.sourceCodexThreadRef,
|
||||
targetProjectId: task.targetProjectId,
|
||||
targetThreadId: task.targetThreadId,
|
||||
targetThreadDisplayName: task.targetThreadDisplayName,
|
||||
targetCodexThreadRef: task.targetCodexThreadRef,
|
||||
targetTurnId: task.targetTurnId,
|
||||
targetCodexTurnId: task.targetCodexTurnId,
|
||||
targetCodexFolderRef: task.targetCodexFolderRef,
|
||||
orchestrationBackendId:
|
||||
task.orchestrationBackendId === "omx-team" || task.orchestrationBackendId === "boss-native-orchestrator"
|
||||
@@ -8085,10 +8097,16 @@ export async function queueMasterAgentTask(payload: {
|
||||
attachmentTextExcerpt?: string;
|
||||
deviceImportDraftId?: string;
|
||||
dispatchExecutionId?: string;
|
||||
sourceProjectId?: string;
|
||||
sourceThreadId?: string;
|
||||
sourceThreadDisplayName?: string;
|
||||
sourceCodexThreadRef?: string;
|
||||
targetProjectId?: string;
|
||||
targetThreadId?: string;
|
||||
targetThreadDisplayName?: string;
|
||||
targetCodexThreadRef?: string;
|
||||
targetTurnId?: string;
|
||||
targetCodexTurnId?: string;
|
||||
targetCodexFolderRef?: string;
|
||||
orchestrationBackendId?: OrchestrationBackendId;
|
||||
orchestrationBackendLabel?: string;
|
||||
@@ -8138,10 +8156,16 @@ export async function queueMasterAgentTask(payload: {
|
||||
attachmentTextExcerpt: payload.attachmentTextExcerpt,
|
||||
deviceImportDraftId: payload.deviceImportDraftId,
|
||||
dispatchExecutionId: payload.dispatchExecutionId,
|
||||
sourceProjectId: payload.sourceProjectId,
|
||||
sourceThreadId: payload.sourceThreadId,
|
||||
sourceThreadDisplayName: payload.sourceThreadDisplayName,
|
||||
sourceCodexThreadRef: payload.sourceCodexThreadRef,
|
||||
targetProjectId: payload.targetProjectId,
|
||||
targetThreadId: payload.targetThreadId,
|
||||
targetThreadDisplayName: payload.targetThreadDisplayName,
|
||||
targetCodexThreadRef: payload.targetCodexThreadRef,
|
||||
targetTurnId: payload.targetTurnId,
|
||||
targetCodexTurnId: payload.targetCodexTurnId,
|
||||
targetCodexFolderRef: payload.targetCodexFolderRef,
|
||||
orchestrationBackendId: payload.orchestrationBackendId,
|
||||
orchestrationBackendLabel: payload.orchestrationBackendLabel,
|
||||
@@ -9291,6 +9315,50 @@ export async function cancelMasterAgentTask(input: {
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function updateMasterAgentTaskProgress(payload: {
|
||||
taskId: string;
|
||||
deviceId: string;
|
||||
status?: "queued" | "running";
|
||||
executionProgress?: ExecutionProgressInput;
|
||||
requestId?: string;
|
||||
}) {
|
||||
const result = await mutateState((state) => {
|
||||
const task = state.masterAgentTasks.find((item) => item.taskId === payload.taskId);
|
||||
if (!task) {
|
||||
throw new Error("MASTER_AGENT_TASK_NOT_FOUND");
|
||||
}
|
||||
if (task.deviceId !== payload.deviceId) {
|
||||
throw new Error("MASTER_AGENT_TASK_DEVICE_MISMATCH");
|
||||
}
|
||||
if (isTerminalMasterAgentTaskStatus(task.status)) {
|
||||
return { ...task };
|
||||
}
|
||||
const progressStatus = payload.status === "queued" ? "queued" : "running";
|
||||
if (task.status === "queued" && progressStatus === "running") {
|
||||
task.status = "running";
|
||||
task.claimedAt = task.claimedAt ?? nowIso();
|
||||
task.lastClaimedAt = task.lastClaimedAt ?? task.claimedAt;
|
||||
task.attemptCount = task.attemptCount ?? 1;
|
||||
task.maxAttempts = task.maxAttempts ?? defaultMasterAgentTaskMaxAttempts(task.taskType);
|
||||
task.leaseExpiresAt = task.leaseExpiresAt ?? new Date(Date.now() + masterAgentTaskLeaseMs(task)).toISOString();
|
||||
}
|
||||
task.requestId = payload.requestId?.trim() || task.requestId;
|
||||
upsertTaskExecutionProgressMessageInState(state, task, progressStatus, payload.executionProgress);
|
||||
return { ...task };
|
||||
});
|
||||
publishBossEvent("master_agent.task.updated", {
|
||||
taskId: result.taskId,
|
||||
deviceId: result.deviceId,
|
||||
status: result.status,
|
||||
});
|
||||
const progressProjectId = resolveTaskExecutionProgressProjectId(result);
|
||||
if (progressProjectId) {
|
||||
publishBossEvent("project.messages.updated", { projectId: progressProjectId });
|
||||
publishBossEvent("conversation.updated", { projectId: progressProjectId });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function completeMasterAgentTask(payload: {
|
||||
taskId: string;
|
||||
deviceId: string;
|
||||
|
||||
Reference in New Issue
Block a user