( candidate: StartBlockCandidate<TriggerBlockLike>, isDefault: boolean )
| 206 | } |
| 207 | |
| 208 | function buildTriggerRunOption( |
| 209 | candidate: StartBlockCandidate<TriggerBlockLike>, |
| 210 | isDefault: boolean |
| 211 | ): TriggerRunOption { |
| 212 | const { blockId, block, path } = candidate |
| 213 | const blockConfig = getBlock(block.type) |
| 214 | const blockName = block.name || blockConfig?.name || block.type |
| 215 | const inputKind = resolveInputKind(path, block) |
| 216 | const inputFormat = normalizeInputFormatValue(readSubBlockValue(block, 'inputFormat')) |
| 217 | |
| 218 | let inputSchema: Record<string, unknown> |
| 219 | let mockPayload: unknown |
| 220 | |
| 221 | switch (inputKind) { |
| 222 | case 'fields': { |
| 223 | inputSchema = generateToolInputSchema(inputFormat) |
| 224 | mockPayload = buildFieldsSample(inputFormat) |
| 225 | break |
| 226 | } |
| 227 | case 'event_payload': { |
| 228 | const triggerId = resolveEventTriggerId(block) |
| 229 | const outputs = safeTriggerOutputs(triggerId) |
| 230 | inputSchema = outputs |
| 231 | ? triggerOutputsToJsonSchema(outputs) |
| 232 | : { type: 'object', properties: {} } |
| 233 | mockPayload = extractEventMockPayload(candidate) |
| 234 | break |
| 235 | } |
| 236 | case 'chat': { |
| 237 | inputSchema = { |
| 238 | type: 'object', |
| 239 | required: ['input'], |
| 240 | properties: { |
| 241 | input: { type: 'string', description: 'User message' }, |
| 242 | conversationId: { type: 'string', description: 'Optional conversation ID' }, |
| 243 | }, |
| 244 | } |
| 245 | mockPayload = { input: 'mock_message' } |
| 246 | break |
| 247 | } |
| 248 | default: { |
| 249 | inputSchema = { type: 'object', properties: {} } |
| 250 | mockPayload = {} |
| 251 | break |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | return { |
| 256 | triggerBlockId: blockId, |
| 257 | blockName, |
| 258 | triggerType: block.type, |
| 259 | path, |
| 260 | isDefault, |
| 261 | inputKind, |
| 262 | inputSchema, |
| 263 | mockPayload, |
| 264 | inputFormat, |
| 265 | } |
no test coverage detected