( version: string, stagingPath: string, )
| 485 | } |
| 486 | |
| 487 | export async function downloadVersion( |
| 488 | version: string, |
| 489 | stagingPath: string, |
| 490 | ): Promise<'npm' | 'binary'> { |
| 491 | // Test-fixture versions route to the private sentinel bucket. DCE'd in all |
| 492 | // shipped builds — the string 'claude-code-ci-sentinel' and the gcloud call |
| 493 | // never exist in compiled binaries. Same gcloud-token pattern as |
| 494 | // remoteSkillLoader.ts:175-195. |
| 495 | if (feature('ALLOW_TEST_VERSIONS') && /^99\.99\./.test(version)) { |
| 496 | const { stdout } = await execFileNoThrowWithCwd('gcloud', [ |
| 497 | 'auth', |
| 498 | 'print-access-token', |
| 499 | ]) |
| 500 | await downloadVersionFromBinaryRepo( |
| 501 | version, |
| 502 | stagingPath, |
| 503 | 'https://storage.googleapis.com/claude-code-ci-sentinel', |
| 504 | { headers: { Authorization: `Bearer ${stdout.trim()}` } }, |
| 505 | ) |
| 506 | return 'binary' |
| 507 | } |
| 508 | |
| 509 | if (process.env.USER_TYPE === 'ant') { |
| 510 | // Use Artifactory for ant users |
| 511 | await downloadVersionFromArtifactory(version, stagingPath) |
| 512 | return 'npm' |
| 513 | } |
| 514 | |
| 515 | // Use GCS for external users |
| 516 | await downloadVersionFromBinaryRepo(version, stagingPath, GCS_BUCKET_URL) |
| 517 | return 'binary' |
| 518 | } |
| 519 | |
| 520 | // Exported for testing |
| 521 | export { StallTimeoutError, MAX_DOWNLOAD_RETRIES } |
no test coverage detected