( commandType: 'workflow' | 'skill', targetId: string, targetName: string | undefined, result: CheckResult, )
| 79 | * @returns Error payload suitable for fail() |
| 80 | */ |
| 81 | export function buildMissingVariablesError( |
| 82 | commandType: 'workflow' | 'skill', |
| 83 | targetId: string, |
| 84 | targetName: string | undefined, |
| 85 | result: CheckResult, |
| 86 | ): { |
| 87 | code: string; |
| 88 | message: string; |
| 89 | details: Record<string, unknown>; |
| 90 | hint: string; |
| 91 | suggestedFix: SuggestedFix; |
| 92 | recoverable: true; |
| 93 | } { |
| 94 | const displayName = targetName ? `"${targetName}"` : targetId; |
| 95 | |
| 96 | // Build suggested command based on command type |
| 97 | const inputJson = JSON.stringify(result.suggestedInput); |
| 98 | const suggestedCommand = |
| 99 | commandType === 'workflow' |
| 100 | ? `refly workflow run ${targetId} --input '${inputJson}'` |
| 101 | : `refly skill run --name <name> --input '${inputJson}'`; |
| 102 | |
| 103 | return { |
| 104 | code: 'MISSING_VARIABLES', |
| 105 | message: `Missing required variables for ${commandType} ${displayName}`, |
| 106 | details: { |
| 107 | missingVariables: result.missing.map((v) => ({ |
| 108 | name: v.name, |
| 109 | type: v.variableType || 'string', |
| 110 | required: true, |
| 111 | default: v.default, |
| 112 | description: v.description, |
| 113 | })), |
| 114 | suggestedInput: result.suggestedInput, |
| 115 | suggestedCommand, |
| 116 | }, |
| 117 | hint: 'Provide the missing variables via --input. See suggestedInput for the expected format.', |
| 118 | suggestedFix: { |
| 119 | field: '--input', |
| 120 | format: 'json-object', |
| 121 | example: inputJson, |
| 122 | }, |
| 123 | recoverable: true, |
| 124 | }; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Convert workflow variables array to a simple key-value object. |
no outgoing calls
no test coverage detected