(input: ActivityInput)
| 440 | * NOT using runAgentActivity — preflight doesn't run an agent via the SDK. |
| 441 | */ |
| 442 | export async function runPreflightValidation(input: ActivityInput): Promise<void> { |
| 443 | const startTime = Date.now(); |
| 444 | const attemptNumber = Context.current().info.attempt; |
| 445 | |
| 446 | const heartbeatInterval = setInterval(() => { |
| 447 | const elapsed = Math.floor((Date.now() - startTime) / 1000); |
| 448 | heartbeat({ phase: 'preflight', elapsedSeconds: elapsed, attempt: attemptNumber }); |
| 449 | }, HEARTBEAT_INTERVAL_MS); |
| 450 | |
| 451 | try { |
| 452 | const logger = createActivityLogger(); |
| 453 | logger.info('Running preflight validation...', { attempt: attemptNumber }); |
| 454 | |
| 455 | const result = await runPreflightChecks( |
| 456 | input.webUrl, |
| 457 | input.repoPath, |
| 458 | input.configPath, |
| 459 | logger, |
| 460 | input.apiKey, |
| 461 | input.providerConfig, |
| 462 | ); |
| 463 | |
| 464 | if (isErr(result)) { |
| 465 | const classified = classifyErrorForTemporal(result.error); |
| 466 | const message = truncateErrorMessage(result.error.message); |
| 467 | |
| 468 | if (classified.retryable) { |
| 469 | const failure = ApplicationFailure.create({ |
| 470 | message, |
| 471 | type: classified.type, |
| 472 | details: [{ phase: 'preflight', attemptNumber, elapsed: Date.now() - startTime }], |
| 473 | }); |
| 474 | truncateStackTrace(failure); |
| 475 | throw failure; |
| 476 | } else { |
| 477 | const failure = ApplicationFailure.nonRetryable(message, classified.type, [ |
| 478 | { phase: 'preflight', attemptNumber, elapsed: Date.now() - startTime }, |
| 479 | ]); |
| 480 | truncateStackTrace(failure); |
| 481 | throw failure; |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | logger.info('Preflight validation passed'); |
| 486 | } catch (error) { |
| 487 | if (error instanceof ApplicationFailure) { |
| 488 | throw error; |
| 489 | } |
| 490 | |
| 491 | const classified = classifyErrorForTemporal(error); |
| 492 | const rawMessage = error instanceof Error ? error.message : String(error); |
| 493 | const message = truncateErrorMessage(rawMessage); |
| 494 | |
| 495 | const failure = ApplicationFailure.nonRetryable(message, classified.type, [ |
| 496 | { phase: 'preflight', attemptNumber, elapsed: Date.now() - startTime }, |
| 497 | ]); |
| 498 | truncateStackTrace(failure); |
| 499 | throw failure; |
nothing calls this directly
no test coverage detected