@@ -20,8 +20,10 @@ const HOST_SMOKE_RUNNER_PATH = `${HARNESS_DIRECTORY}/run-host-smoke.mjs`;
2020const LIVE_PIPELINE_RUNNER_PATH = `${ HARNESS_DIRECTORY } /run-live-asset-pack-pipeline.ts` ;
2121const EVIDENCE_PATH = `${ HARNESS_DIRECTORY } /evidence.json` ;
2222const TELEMETRY_PATH = `${ HARNESS_DIRECTORY } /telemetry.jsonl` ;
23+ const TSCONFIG_PATHS_REGISTER_PATH = `${ HARNESS_DIRECTORY } /node_modules/tsconfig-paths/register` ;
2324const SANDBOX_WORKING_DIRECTORY = '/vercel/sandbox' ;
2425const DEFAULT_LONG_TIMEOUT_MS = 45 * 60 * 1000 ;
26+ const SANDBOX_PNPM_VERSION = '10.33.0' ;
2527
2628export interface BuildAssetPackSandboxHarnessOptions {
2729 mode ?: PipelineHarnessMode ;
@@ -116,7 +118,7 @@ function buildCommands(
116118 commands . push ( {
117119 label : 'package-manager-readiness' ,
118120 cmd : 'corepack' ,
119- args : [ 'enable ' ] ,
121+ args : [ 'prepare' , `pnpm@ ${ SANDBOX_PNPM_VERSION } ` , '--activate '] ,
120122 required : true ,
121123 } ) ;
122124
@@ -129,6 +131,13 @@ function buildCommands(
129131 } ) ;
130132 }
131133
134+ commands . push ( {
135+ label : 'harness-runtime-install' ,
136+ cmd : 'npm' ,
137+ args : [ 'install' , '--prefix' , HARNESS_DIRECTORY , 'tsconfig-paths@4.2.0' ] ,
138+ required : true ,
139+ } ) ;
140+
132141 commands . push ( {
133142 label : 'asset-pack-pipeline-run' ,
134143 cmd : 'pnpm' ,
@@ -137,6 +146,10 @@ function buildCommands(
137146 '@bitcode/pipeline-hosts' ,
138147 'exec' ,
139148 'ts-node' ,
149+ '--project' ,
150+ '../../tsconfig.json' ,
151+ '-r' ,
152+ `../../${ TSCONFIG_PATHS_REGISTER_PATH } ` ,
140153 '--transpile-only' ,
141154 `../../${ LIVE_PIPELINE_RUNNER_PATH } ` ,
142155 ] ,
@@ -229,18 +242,16 @@ await writeFile(\`\${artifactDir}/evidence.json\`, JSON.stringify(evidence, null
229242function createLiveAssetPackPipelineRunner ( ) : string {
230243 return `import { mkdir, readFile, writeFile } from 'node:fs/promises';
231244import { createHash, randomUUID } from 'node:crypto';
232- import { assetPackPipeline } from '../../packages/pipelines/asset-pack/src/index';
233- import { enablePipelineStreaming, factoryPipelineExecution } from '../../packages/pipelines-generics/src/index';
234245
235246const manifestPath = process.env.BITCODE_PIPELINE_HARNESS_MANIFEST || '${ MANIFEST_PATH } ';
236247const artifactDir = process.env.BITCODE_PIPELINE_HARNESS_ARTIFACT_DIR || '${ HARNESS_DIRECTORY } ';
237- const manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
238248const runId = process.env.BITCODE_PIPELINE_RUN_ID || randomUUID();
239249const DEFAULT_USER_ID = '00000000-0000-4000-8000-000000000000';
240250const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
241- let userId = process.env.BITCODE_PIPELINE_USER_ID || manifest.deposit?.userId || DEFAULT_USER_ID;
242251const startedAt = new Date().toISOString();
243- const manifestRoot = createHash('sha256').update(JSON.stringify(manifest)).digest('hex');
252+ let manifest = null;
253+ let manifestRoot = null;
254+ let userId = process.env.BITCODE_PIPELINE_USER_ID || DEFAULT_USER_ID;
244255const events = [];
245256let resultState = 'blocked_readiness';
246257let output = null;
@@ -334,14 +345,14 @@ async function insertPipelineRun() {
334345 started_at: startedAt,
335346 metadata: {
336347 bitcodePipelineHarness: true,
337- harnessMode: manifest.harnessMode,
348+ harnessMode: manifest? .harnessMode || 'asset_pack_pipeline' ,
338349 manifestRoot,
339- sourceRevision: manifest.sourceRevision,
350+ sourceRevision: manifest? .sourceRevision || null ,
340351 },
341352 input: {
342- read: manifest.read,
343- deposit: manifest.deposit,
344- sourceRevision: manifest.sourceRevision,
353+ read: manifest? .read || null ,
354+ deposit: manifest? .deposit || null ,
355+ sourceRevision: manifest? .sourceRevision || null ,
345356 },
346357 }).select('id').single();
347358 if (insertError) {
@@ -444,17 +455,25 @@ async function insertHarnessStreamLog(status) {
444455 status,
445456 resultState,
446457 manifestRoot,
447- harnessMode: manifest.harnessMode,
458+ harnessMode: manifest? .harnessMode || 'asset_pack_pipeline' ,
448459 },
449460 });
450461 } catch (persistError) {
451462 record({ type: 'stream-log-persist-blocked', stage: 'telemetry-readback', error: persistError?.message || String(persistError) });
452463 }
453464}
454465
466+ async function main() {
455467await mkdir(artifactDir, { recursive: true });
456468
457469try {
470+ manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
471+ manifestRoot = createHash('sha256').update(JSON.stringify(manifest)).digest('hex');
472+ userId = process.env.BITCODE_PIPELINE_USER_ID || manifest.deposit?.userId || DEFAULT_USER_ID;
473+ const [{ assetPackPipeline }, { enablePipelineStreaming, factoryPipelineExecution }] = await Promise.all([
474+ import('../../packages/pipelines/asset-pack/src/index'),
475+ import('../../packages/pipelines-generics/src/index'),
476+ ]);
458477 const execution = factoryPipelineExecution('asset_pack', undefined, {
459478 pipelineName: 'asset_pack',
460479 family: 'asset_pack',
@@ -548,7 +567,7 @@ try {
548567
549568 const evidence = {
550569 schema: 'bitcode.pipeline-harness.evidence',
551- harnessMode: manifest.harnessMode,
570+ harnessMode: manifest? .harnessMode || 'asset_pack_pipeline' ,
552571 resultState: 'blocked_readiness',
553572 resultReasons: [
554573 'AssetPack pipeline execution did not produce admissible commercial result evidence.',
@@ -577,5 +596,12 @@ try {
577596 await insertHarnessStreamLog(process.exitCode ? 'failed' : 'completed');
578597 await writeFile(\`\${artifactDir}/telemetry.jsonl\`, events.map((event) => JSON.stringify(event)).join('\\n') + '\\n');
579598}
599+
600+ }
601+
602+ main().catch((caught) => {
603+ process.stderr.write(\`\${caught?.message || String(caught)}\\n\`);
604+ process.exitCode = 1;
605+ });
580606` ;
581607}
0 commit comments