(value: unknown)
| 16212 | } |
| 16213 | |
| 16214 | function parseAutomationCommandSkillResult(value: unknown): AutomationCommandSkillResult | null { |
| 16215 | const parsed = parseJsonObject(value); |
| 16216 | if (!parsed) { |
| 16217 | return null; |
| 16218 | } |
| 16219 | const action = normalizeAutomationCommandSkillAction(parsed.action); |
| 16220 | if (!action) { |
| 16221 | return null; |
| 16222 | } |
| 16223 | const confidence = clampAssistantConfidence(Number(parsed.confidence ?? 0.8)); |
| 16224 | if (action === 'create_draft' || action === 'update_pending_draft') { |
| 16225 | const candidate = parseAutomationDraftCandidateFromObject(parsed); |
| 16226 | return candidate |
| 16227 | ? { |
| 16228 | action, |
| 16229 | confidence, |
| 16230 | candidate, |
| 16231 | changes: normalizeStringArray(parsed.changes), |
| 16232 | } |
| 16233 | : null; |
| 16234 | } |
| 16235 | if (action === 'propose_update_job') { |
| 16236 | const target = parseAutomationOperationTarget(parsed.target); |
| 16237 | const patch = parseAutomationJobPatch(parsed.patch); |
| 16238 | return target && Object.keys(patch).length > 0 |
| 16239 | ? { |
| 16240 | action, |
| 16241 | confidence, |
| 16242 | target, |
| 16243 | patch, |
| 16244 | changes: normalizeStringArray(parsed.changes), |
| 16245 | } |
| 16246 | : null; |
| 16247 | } |
| 16248 | if (action === 'propose_delete_job' || action === 'propose_pause_job' || action === 'propose_resume_job') { |
| 16249 | const target = parseAutomationOperationTarget(parsed.target); |
| 16250 | return target |
| 16251 | ? { |
| 16252 | action, |
| 16253 | confidence, |
| 16254 | target, |
| 16255 | reason: normalizeNullableText(parsed.reason), |
| 16256 | } |
| 16257 | : null; |
| 16258 | } |
| 16259 | if (action === 'propose_rename_job') { |
| 16260 | const target = parseAutomationOperationTarget(parsed.target); |
| 16261 | const newTitle = compactWhitespace(parsed.newTitle ?? parsed.title ?? ''); |
| 16262 | return target && newTitle |
| 16263 | ? { |
| 16264 | action, |
| 16265 | confidence, |
| 16266 | target, |
| 16267 | newTitle, |
| 16268 | } |
| 16269 | : null; |
| 16270 | } |
| 16271 | if (action === 'query_jobs') { |
nothing calls this directly
no test coverage detected