@@ -10,9 +10,7 @@ import {
1010 type EmbeddedRunAttemptParamsV2 as EmbeddedRunAttemptParams ,
1111 wrapToolWithBeforeToolCallHook ,
1212} from "openclaw/plugin-sdk/agent-harness-runtime" ;
13- import { saveExecApprovals } from "openclaw/plugin-sdk/infra-runtime" ;
1413import { readMemoryArtifactProvenance } from "openclaw/plugin-sdk/memory-core-host-runtime-core" ;
15- import { closeOpenClawStateDatabaseForTest } from "openclaw/plugin-sdk/sqlite-runtime-testing" ;
1614import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
1715import { dynamicToolBuildState } from "./dynamic-tool-build-state.js" ;
1816import {
@@ -640,13 +638,6 @@ describe("Codex app-server dynamic tool build", () => {
640638 ] ) ( "enforces the final $mode policy for an allowlisted Gateway command" , async ( testCase ) => {
641639 const workspaceDir = path . join ( tempDir , `${ testCase . mode } -allowlisted-workspace` ) ;
642640 await fs . mkdir ( workspaceDir , { recursive : true } ) ;
643- vi . stubEnv ( "OPENCLAW_STATE_DIR" , path . join ( tempDir , `${ testCase . mode } -state` ) ) ;
644- closeOpenClawStateDatabaseForTest ( ) ;
645- saveExecApprovals ( {
646- version : 1 ,
647- defaults : { security : "allowlist" , ask : "on-miss" , askFallback : "deny" } ,
648- agents : { main : { allowlist : [ { pattern : process . execPath } ] } } ,
649- } ) ;
650641 const params = createParams (
651642 path . join ( tempDir , `${ testCase . mode } -allowlisted.jsonl` ) ,
652643 workspaceDir ,
@@ -655,6 +646,9 @@ describe("Codex app-server dynamic tool build", () => {
655646 params . permissionMode = testCase . mode ;
656647 params . sessionRoot = workspaceDir ;
657648 params . execOverrides = { host : "gateway" , mode : testCase . execMode } ;
649+ params . config = {
650+ tools : { exec : { safeBins : [ "echo" ] , safeBinProfiles : { echo : { maxPositional : 1 } } } } ,
651+ } ;
658652 params . runtimePlan = createCodexRuntimePlanFixture ( ) ;
659653 setOpenClawCodingToolsFactoryForTests ( ( options ) =>
660654 createOpenClawCodingTools ( {
@@ -664,28 +658,24 @@ describe("Codex app-server dynamic tool build", () => {
664658 } ) . filter ( ( tool ) => [ "exec" , "process" ] . includes ( tool . name ) ) ,
665659 ) ;
666660
667- try {
668- const tools = await buildDynamicToolsForTest ( params , workspaceDir , {
669- sessionPermissionPolicy : {
670- mode : testCase . mode ,
671- root : workspaceDir ,
672- execMode : testCase . execMode ,
673- } ,
674- } ) ;
675- const gatewayExec = expectDefined (
676- tools . find ( ( tool ) => tool . name === "gateway_exec" ) ,
677- `${ testCase . mode } Gateway shell alias` ,
678- ) ;
679- const result = await gatewayExec . execute ( `${ testCase . mode } -allowlisted` , {
680- command : `${ JSON . stringify ( process . execPath ) } --version` ,
681- ask : "off" ,
682- security : "full" ,
683- } ) ;
661+ const tools = await buildDynamicToolsForTest ( params , workspaceDir , {
662+ sessionPermissionPolicy : {
663+ mode : testCase . mode ,
664+ root : workspaceDir ,
665+ execMode : testCase . execMode ,
666+ } ,
667+ } ) ;
668+ const gatewayExec = expectDefined (
669+ tools . find ( ( tool ) => tool . name === "gateway_exec" ) ,
670+ `${ testCase . mode } Gateway shell alias` ,
671+ ) ;
672+ const result = await gatewayExec . execute ( `${ testCase . mode } -allowlisted` , {
673+ command : `echo ${ testCase . mode } ` ,
674+ ask : "off" ,
675+ security : "full" ,
676+ } ) ;
684677
685- expect ( result . details ) . toMatchObject ( testCase . expected ) ;
686- } finally {
687- closeOpenClawStateDatabaseForTest ( ) ;
688- }
678+ expect ( result . details ) . toMatchObject ( testCase . expected ) ;
689679 } ) ;
690680
691681 it ( "removes managed web_search when domain-restricted Codex hosted search is active" , async ( ) => {
0 commit comments