( workflowInput: unknown, structuredInput: Record<string, unknown>, hasStructured: boolean )
| 408 | } |
| 409 | |
| 410 | function buildUnifiedStartOutput( |
| 411 | workflowInput: unknown, |
| 412 | structuredInput: Record<string, unknown>, |
| 413 | hasStructured: boolean |
| 414 | ): NormalizedBlockOutput { |
| 415 | const output: NormalizedBlockOutput = {} |
| 416 | const structuredKeys = hasStructured ? new Set(Object.keys(structuredInput)) : null |
| 417 | |
| 418 | if (hasStructured) { |
| 419 | for (const [key, value] of Object.entries(structuredInput)) { |
| 420 | output[key] = value |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | if (isRecordLike(workflowInput)) { |
| 425 | for (const [key, value] of Object.entries(workflowInput)) { |
| 426 | if (key === 'onUploadError') continue |
| 427 | // Skip keys already set by schema-coerced structuredInput to |
| 428 | // prevent raw workflowInput strings from overwriting typed values. |
| 429 | if (structuredKeys?.has(key)) continue |
| 430 | // Runtime values override defaults (except undefined/null which mean "not provided") |
| 431 | if (value !== undefined && value !== null) { |
| 432 | output[key] = value |
| 433 | } else if (!Object.hasOwn(output, key)) { |
| 434 | output[key] = value |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | if (!Object.hasOwn(output, 'input')) { |
| 440 | const fallbackInput = |
| 441 | isRecordLike(workflowInput) && typeof workflowInput.input !== 'undefined' |
| 442 | ? ensureString(workflowInput.input) |
| 443 | : '' |
| 444 | output.input = fallbackInput ? fallbackInput : undefined |
| 445 | } else if (typeof output.input === 'string' && output.input.length === 0) { |
| 446 | output.input = undefined |
| 447 | } |
| 448 | |
| 449 | if (!Object.hasOwn(output, 'conversationId')) { |
| 450 | const conversationId = |
| 451 | isRecordLike(workflowInput) && workflowInput.conversationId |
| 452 | ? ensureString(workflowInput.conversationId) |
| 453 | : undefined |
| 454 | if (conversationId) { |
| 455 | output.conversationId = conversationId |
| 456 | } |
| 457 | } else if (typeof output.conversationId === 'string' && output.conversationId.length === 0) { |
| 458 | output.conversationId = undefined |
| 459 | } |
| 460 | |
| 461 | return mergeFilesIntoOutput(output, workflowInput) |
| 462 | } |
| 463 | |
| 464 | function buildApiOrInputOutput(finalInput: unknown, workflowInput: unknown): NormalizedBlockOutput { |
| 465 | const isObjectInput = isRecordLike(finalInput) |
no test coverage detected