@@ -5,61 +5,73 @@ import { dirname, join, resolve } from "node:path";
55import { fileURLToPath } from "node:url" ;
66import { expect , it } from "vitest" ;
77import { approveAll } from "../../src/index.js" ;
8- import { createSdkTestContext , DEFAULT_GITHUB_TOKEN } from "./harness/sdkTestContext.js" ;
8+ import {
9+ createSdkTestContext ,
10+ DEFAULT_GITHUB_TOKEN ,
11+ isInProcessTransport ,
12+ } from "./harness/sdkTestContext.js" ;
913import { retry } from "./harness/sdkTestHelper.js" ;
1014
1115const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
12- const factoryTestContext = await createSdkTestContext ( {
13- copilotClientOptions : {
14- env : {
15- COPILOT_CLI_ENABLED_FEATURE_FLAGS : "EXTENSIONS,AGENT_FACTORIES" ,
16- } ,
17- } ,
18- } ) ;
16+ const factoryTestContext = isInProcessTransport
17+ ? undefined
18+ : await createSdkTestContext ( {
19+ copilotClientOptions : {
20+ env : {
21+ COPILOT_CLI_ENABLED_FEATURE_FLAGS : "EXTENSIONS,AGENT_FACTORIES" ,
22+ } ,
23+ } ,
24+ } ) ;
1925
20- it ( "runs an extension-authored factory across the SDK process boundary" , async ( ) => {
21- const { copilotClient, openAiEndpoint, workDir } = factoryTestContext ;
26+ it . skipIf ( isInProcessTransport ) (
27+ "runs an extension-authored factory across the SDK process boundary" ,
28+ async ( ) => {
29+ if ( ! factoryTestContext ) {
30+ throw new Error ( "Factory E2E requires the stdio transport" ) ;
31+ }
32+ const { copilotClient, openAiEndpoint, workDir } = factoryTestContext ;
2233
23- await openAiEndpoint . setCopilotUserByToken ( DEFAULT_GITHUB_TOKEN , {
24- login : "factory-e2e-user" ,
25- copilot_plan : "individual_pro" ,
26- token_based_billing : true ,
27- } ) ;
34+ await openAiEndpoint . setCopilotUserByToken ( DEFAULT_GITHUB_TOKEN , {
35+ login : "factory-e2e-user" ,
36+ copilot_plan : "individual_pro" ,
37+ token_based_billing : true ,
38+ } ) ;
2839
29- const extensionDir = join ( workDir , ".github" , "extensions" , "factory-smoke" ) ;
30- const readyFile = join ( extensionDir , "ready" ) ;
31- await mkdir ( extensionDir , { recursive : true } ) ;
32- await copyFile (
33- join ( __dirname , "fixtures" , "factory-extension.mjs" ) ,
34- join ( extensionDir , "extension.mjs" )
35- ) ;
36- execFileSync ( "git" , [ "init" , "--quiet" ] , { cwd : workDir } ) ;
40+ const extensionDir = join ( workDir , ".github" , "extensions" , "factory-smoke" ) ;
41+ const readyFile = join ( extensionDir , "ready" ) ;
42+ await mkdir ( extensionDir , { recursive : true } ) ;
43+ await copyFile (
44+ join ( __dirname , "fixtures" , "factory-extension.mjs" ) ,
45+ join ( extensionDir , "extension.mjs" )
46+ ) ;
47+ execFileSync ( "git" , [ "init" , "--quiet" ] , { cwd : workDir } ) ;
3748
38- await using session = await copilotClient . createSession ( {
39- requestExtensions : true ,
40- extensionSdkPath : resolve ( __dirname , ".." , ".." , "dist" ) ,
41- onPermissionRequest : approveAll ,
42- onElicitationRequest : async ( ) => ( {
43- action : "accept" ,
44- content : { action : "approve" } ,
45- } ) ,
46- } ) ;
49+ await using session = await copilotClient . createSession ( {
50+ requestExtensions : true ,
51+ extensionSdkPath : resolve ( __dirname , ".." , ".." , "dist" ) ,
52+ onPermissionRequest : approveAll ,
53+ onElicitationRequest : async ( ) => ( {
54+ action : "accept" ,
55+ content : { action : "approve" } ,
56+ } ) ,
57+ } ) ;
4758
48- await retry (
49- "wait for the factory extension to join the session" ,
50- async ( ) => {
51- expect ( existsSync ( readyFile ) ) . toBe ( true ) ;
52- } ,
53- 300 ,
54- 100
55- ) ;
59+ await retry (
60+ "wait for the factory extension to join the session" ,
61+ async ( ) => {
62+ expect ( existsSync ( readyFile ) ) . toBe ( true ) ;
63+ } ,
64+ 300 ,
65+ 100
66+ ) ;
5667
57- const result = await session . factory . run ( "argument-echo" , {
58- args : { source : "sdk-e2e" , count : 11 } ,
59- } ) ;
68+ const result = await session . factory . run ( "argument-echo" , {
69+ args : { source : "sdk-e2e" , count : 11 } ,
70+ } ) ;
6071
61- expect ( result ) . toMatchObject ( {
62- status : "completed" ,
63- result : { source : "sdk-e2e" , count : 11 } ,
64- } ) ;
65- } ) ;
72+ expect ( result ) . toMatchObject ( {
73+ status : "completed" ,
74+ result : { source : "sdk-e2e" , count : 11 } ,
75+ } ) ;
76+ }
77+ ) ;
0 commit comments