@@ -30,6 +30,14 @@ const oauthMocks = vi.hoisted(() => ({
3030 refreshOpenAICodexToken : vi . fn ( ) ,
3131} ) ) ;
3232
33+ const computerUseServiceMocks = vi . hoisted ( ( ) => ( {
34+ ensureCodexComputerUseServiceApp : vi . fn ( async ( ) => ( {
35+ status : "already_installed" as const ,
36+ changed : false ,
37+ message : "Computer Use service app is installed." ,
38+ } ) ) ,
39+ } ) ) ;
40+
3341const providerRuntimeMocks = vi . hoisted ( ( ) => ( {
3442 formatProviderAuthProfileApiKeyWithPlugin : vi . fn ( ) ,
3543 refreshProviderOAuthCredentialWithPlugin : vi . fn (
@@ -117,12 +125,17 @@ vi.mock("openclaw/plugin-sdk/agent-runtime", async (importOriginal) => {
117125 } ;
118126} ) ;
119127
128+ vi . mock ( "./computer-use-service.js" , ( ) => ( {
129+ ensureCodexComputerUseServiceApp : computerUseServiceMocks . ensureCodexComputerUseServiceApp ,
130+ } ) ) ;
131+
120132afterEach ( ( ) => {
121133 vi . unstubAllEnvs ( ) ;
122134 clearRuntimeAuthProfileStoreSnapshots ( ) ;
123135 oauthMocks . refreshOpenAICodexToken . mockReset ( ) ;
124136 providerRuntimeMocks . formatProviderAuthProfileApiKeyWithPlugin . mockReset ( ) ;
125137 providerRuntimeMocks . refreshProviderOAuthCredentialWithPlugin . mockClear ( ) ;
138+ computerUseServiceMocks . ensureCodexComputerUseServiceApp . mockClear ( ) ;
126139} ) ;
127140
128141function createStartOptions (
@@ -241,6 +254,36 @@ describe("bridgeCodexAppServerStartOptions", () => {
241254 }
242255 } ) ;
243256
257+ it ( "provisions the Computer Use service app before auto-install startup" , async ( ) => {
258+ await withTempDir ( "openclaw-codex-computer-use-service-" , async ( agentDir ) => {
259+ const startOptions = createStartOptions ( ) ;
260+ const codexHome = resolveCodexAppServerHomeDir ( agentDir ) ;
261+
262+ await bridgeCodexAppServerStartOptions ( {
263+ startOptions,
264+ agentDir,
265+ pluginConfig : { computerUse : { enabled : true , autoInstall : true } } ,
266+ } ) ;
267+
268+ expect ( computerUseServiceMocks . ensureCodexComputerUseServiceApp ) . toHaveBeenCalledWith ( {
269+ codexHome,
270+ appServerCommand : startOptions . command ,
271+ } ) ;
272+ } ) ;
273+ } ) ;
274+
275+ it ( "does not provision the Computer Use service app without auto-install authorization" , async ( ) => {
276+ await withTempDir ( "openclaw-codex-computer-use-service-" , async ( agentDir ) => {
277+ await bridgeCodexAppServerStartOptions ( {
278+ startOptions : createStartOptions ( ) ,
279+ agentDir,
280+ pluginConfig : { computerUse : { enabled : true , autoInstall : false } } ,
281+ } ) ;
282+
283+ expect ( computerUseServiceMocks . ensureCodexComputerUseServiceApp ) . not . toHaveBeenCalled ( ) ;
284+ } ) ;
285+ } ) ;
286+
244287 it ( "uses the native user Codex home for coexistence mode" , async ( ) => {
245288 await withTempDir ( "openclaw-codex-user-home-" , async ( root ) => {
246289 const agentDir = path . join ( root , "agent" ) ;
0 commit comments