refactor: add typed content helpers for FlowPilot step card actions
Replace unsafe `as string` casts with type guard functions (isScriptGenerationAction, isScriptBuilderAction, getActionType) for compile-time safety on step content parsing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,33 @@ export interface AISessionStepResponse {
|
||||
confidence_score: number
|
||||
}
|
||||
|
||||
// ── Step content type guards ──
|
||||
|
||||
export interface ScriptGenerationContent {
|
||||
action_type: 'script_generation'
|
||||
template_id?: string
|
||||
pre_filled_params?: Record<string, string>
|
||||
instructions?: string
|
||||
}
|
||||
|
||||
export interface ScriptBuilderContent {
|
||||
action_type: 'open_script_builder'
|
||||
script_prompt?: string
|
||||
script_language?: string
|
||||
}
|
||||
|
||||
export function isScriptGenerationAction(content: Record<string, unknown>): content is ScriptGenerationContent {
|
||||
return content.action_type === 'script_generation'
|
||||
}
|
||||
|
||||
export function isScriptBuilderAction(content: Record<string, unknown>): content is ScriptBuilderContent {
|
||||
return content.action_type === 'open_script_builder'
|
||||
}
|
||||
|
||||
export function getActionType(content: Record<string, unknown>): string | undefined {
|
||||
return typeof content.action_type === 'string' ? content.action_type : undefined
|
||||
}
|
||||
|
||||
export interface StepResponseRequest {
|
||||
selected_option?: string | null
|
||||
free_text_input?: string | null
|
||||
|
||||
Reference in New Issue
Block a user