feat: sync codex thread metadata

This commit is contained in:
AI Bot
2026-06-03 14:38:15 +08:00
parent 0186ef7057
commit 5537fde7a6
11 changed files with 518 additions and 1 deletions

View File

@@ -489,6 +489,7 @@ export type ComputerControlIntentCategory =
| "thread_unarchive"
| "thread_rename"
| "thread_goal_sync"
| "thread_metadata_sync"
| "browser_control"
| "desktop_control";
export type ComputerControlRuntimeKind =
@@ -684,6 +685,12 @@ export interface ThreadConversationMeta {
codexFolderRef?: string;
}
export interface ThreadMetadataGitInfoPatch {
sha?: string | null;
branch?: string | null;
originUrl?: string | null;
}
export interface GroupConversationMember {
projectId: string;
deviceId: string;
@@ -1362,6 +1369,8 @@ export interface MasterAgentTask {
threadGoalStatus?: "active" | "paused" | "blocked" | "usageLimited" | "budgetLimited" | "complete";
threadGoalTokenBudget?: number;
threadGoalReason?: string;
threadMetadataGitInfo?: ThreadMetadataGitInfoPatch;
threadMetadataReason?: string;
intentCategory?: ComputerControlIntentCategory;
runtimeKind?: ComputerControlRuntimeKind;
controlPlatform?: ComputerControlPlatform;
@@ -2489,6 +2498,30 @@ function trimToDefined(value?: string) {
return trimmed ? trimmed : undefined;
}
function normalizeThreadMetadataGitInfoPatch(value: unknown): ThreadMetadataGitInfoPatch | undefined {
if (!value || typeof value !== "object" || Array.isArray(value)) {
return undefined;
}
const input = value as {
sha?: unknown;
branch?: unknown;
originUrl?: unknown;
};
const patch: ThreadMetadataGitInfoPatch = {};
for (const key of ["sha", "branch", "originUrl"] as const) {
const field = input[key];
if (field === null) {
patch[key] = null;
} else if (typeof field === "string") {
const trimmed = field.trim();
if (trimmed) {
patch[key] = trimmed;
}
}
}
return Object.keys(patch).length > 0 ? patch : undefined;
}
function normalizeAuditSnapshot(value: unknown): PermissionAuditSnapshot | undefined {
if (!value || typeof value !== "object" || Array.isArray(value)) {
return undefined;
@@ -4772,6 +4805,8 @@ export function migrateBossState(raw: Partial<BossState> | undefined): BossState
? Math.floor(Number(task.threadGoalTokenBudget))
: undefined,
threadGoalReason: trimToDefined(task.threadGoalReason),
threadMetadataGitInfo: normalizeThreadMetadataGitInfoPatch(task.threadMetadataGitInfo),
threadMetadataReason: trimToDefined(task.threadMetadataReason),
intentCategory:
task.intentCategory === "discussion_only" ||
task.intentCategory === "project_development" ||
@@ -4782,6 +4817,7 @@ export function migrateBossState(raw: Partial<BossState> | undefined): BossState
task.intentCategory === "thread_unarchive" ||
task.intentCategory === "thread_rename" ||
task.intentCategory === "thread_goal_sync" ||
task.intentCategory === "thread_metadata_sync" ||
task.intentCategory === "browser_control" ||
task.intentCategory === "desktop_control"
? task.intentCategory
@@ -8857,6 +8893,8 @@ export async function queueMasterAgentTask(payload: {
threadGoalStatus?: "active" | "paused" | "blocked" | "usageLimited" | "budgetLimited" | "complete";
threadGoalTokenBudget?: number;
threadGoalReason?: string;
threadMetadataGitInfo?: ThreadMetadataGitInfoPatch;
threadMetadataReason?: string;
intentCategory?: ComputerControlIntentCategory;
runtimeKind?: ComputerControlRuntimeKind;
controlPlatform?: ComputerControlPlatform;
@@ -8946,6 +8984,8 @@ export async function queueMasterAgentTask(payload: {
? Math.floor(Number(payload.threadGoalTokenBudget))
: undefined,
threadGoalReason: trimToDefined(payload.threadGoalReason),
threadMetadataGitInfo: normalizeThreadMetadataGitInfoPatch(payload.threadMetadataGitInfo),
threadMetadataReason: trimToDefined(payload.threadMetadataReason),
intentCategory: payload.intentCategory,
runtimeKind: payload.runtimeKind,
controlPlatform: payload.controlPlatform,