@@ -14,7 +14,7 @@ import {
1414 type WorkflowEvent ,
1515} from "rig" ;
1616import { s } from "rig" ;
17- import { call as ambientCall } from "rig/globals" ;
17+ import { call as ambientCall , pipeline as ambientPipeline , parallel as ambientParallel } from "rig/globals" ;
1818
1919function fakeAgent < Input , Output > (
2020 name : string ,
@@ -468,4 +468,27 @@ describe("rig/globals", () => {
468468 const worker = fakeAgent < number , number > ( "worker" , ( value ) => value ) ;
469469 expect ( ( ) => ambientCall ( worker , 1 ) ) . toThrow ( "requires an active workflow run" ) ;
470470 } ) ;
471+
472+ it ( "pipeline() and parallel() from rig/globals run inside the active context — flat Claude workflow port pattern" , async ( ) => {
473+ // Mirrors the incremental migration: import call/pipeline/parallel from "rig/globals"
474+ // at the module top level so a flat Claude dynamic workflow can be ported without
475+ // restructuring into a workflow({ body }) immediately.
476+ const worker = fakeAgent < number , number > ( "worker" , ( value ) => value * 10 ) ;
477+ const definition = workflow ( {
478+ meta : { name : "globals-pipeline-parallel" , description : "flat port pattern" } ,
479+ body : async ( ) => {
480+ const pipelineResult = await ambientPipeline ( [ 1 , 2 , 3 ] , ( item : number ) => ambientCall ( worker , item ) ) ;
481+ const parallelResult = await ambientParallel ( [
482+ ( ) => ambientCall ( worker , 4 ) ,
483+ ( ) => ambientCall ( worker , 5 ) ,
484+ ] ) ;
485+ return { pipelineResult, parallelResult } ;
486+ } ,
487+ } ) ;
488+
489+ await expect ( runWorkflow ( definition ) ) . resolves . toEqual ( {
490+ pipelineResult : [ 10 , 20 , 30 ] ,
491+ parallelResult : [ 40 , 50 ] ,
492+ } ) ;
493+ } ) ;
471494} ) ;
0 commit comments