21 lines
869 B
TypeScript
21 lines
869 B
TypeScript
export function decideManagedResumeProfile(input: {
|
|
storedProfile: string | undefined
|
|
overrideProfile: string | undefined
|
|
inferredProfile: string | null
|
|
}): { effective: string | undefined, persist: string | undefined } {
|
|
const override = input.overrideProfile?.trim() || undefined
|
|
const stored = input.storedProfile?.trim() || undefined
|
|
|
|
if (override) { // ① 行内覆盖:与 store 不同才写回;忽略 jsonl 推断
|
|
return {
|
|
effective: override,
|
|
persist: override !== stored ? override : undefined,
|
|
}
|
|
}
|
|
if (stored) // ② store 已有 → 沿用,不写回
|
|
return { effective: stored, persist: undefined }
|
|
if (input.inferredProfile) // ③ 缺 profile 才用 jsonl 回填并写回
|
|
return { effective: input.inferredProfile, persist: input.inferredProfile }
|
|
return { effective: undefined, persist: undefined }
|
|
}
|