@@ -31,10 +31,20 @@ def _parse_args() -> argparse.Namespace:
3131 parser .add_argument ("--candidate-first" , action = "store_true" )
3232 parser .add_argument ("--pipeline-step-id" , choices = SELLING_STAGE_IDS )
3333 parser .add_argument ("--handoff-first" , action = "store_true" )
34+ parser .add_argument ("--sequential-permissions" , action = "store_true" )
35+ parser .add_argument ("--defer-staging-publisher" , action = "store_true" )
36+ parser .add_argument ("--staging-dir" , type = Path )
37+ parser .add_argument ("--backup-dir" , type = Path )
3438 return parser .parse_args ()
3539
3640
37- def _create_fixture_runtime (options : Any , * , execution_log : Path , handoff_first : bool = False ) -> Any :
41+ def _create_fixture_runtime (
42+ options : Any ,
43+ * ,
44+ execution_log : Path ,
45+ handoff_first : bool = False ,
46+ sequential_permissions : bool = False ,
47+ ) -> Any :
3848 from iac_code .agent .agent_loop import AgentLoop
3949 from iac_code .providers .base import ToolDefinition
4050 from iac_code .services .agent_factory import AgentRuntime
@@ -90,7 +100,7 @@ async def execute(self, *, tool_input: dict[str, Any], context: ToolContext) ->
90100 del context
91101 execution_log .parent .mkdir (parents = True , exist_ok = True )
92102 with execution_log .open ("a" , encoding = "utf-8" ) as handle :
93- handle .write ("executed \n " )
103+ handle .write ("{} \n " . format ( tool_input . get ( "value" , "executed" )) )
94104 handle .flush ()
95105 os .fsync (handle .fileno ())
96106 return ToolResult .success ("fixture write completed" )
@@ -126,6 +136,13 @@ async def stream(
126136 name = tool_name ,
127137 input = tool_input ,
128138 )
139+ if sequential_permissions :
140+ yield ToolUseStartEvent (tool_use_id = "fixture-tool-2" , name = tool_name )
141+ yield ToolUseEndEvent (
142+ tool_use_id = "fixture-tool-2" ,
143+ name = tool_name ,
144+ input = {"value" : "executed-2" },
145+ )
129146 yield MessageEndEvent (stop_reason = "tool_use" , usage = Usage ())
130147
131148 provider = FixtureProvider ()
@@ -498,12 +515,18 @@ def main() -> int:
498515 os .environ ["ALIBABA_CLOUD_ACCESS_KEY_ID" ] = "permission-wait-fixture-ak"
499516 os .environ ["ALIBABA_CLOUD_ACCESS_KEY_SECRET" ] = "permission-wait-fixture-secret"
500517 os .environ ["ALIBABA_CLOUD_REGION_ID" ] = "cn-hangzhou"
518+ if args .staging_dir is not None or args .backup_dir is not None :
519+ if args .staging_dir is None or args .backup_dir is None :
520+ raise ValueError ("--staging-dir and --backup-dir must be provided together" )
521+ os .environ ["IAC_CODE_CONFIG_BACKUP_TMP_DIR" ] = str (args .staging_dir .expanduser ().resolve ())
522+ os .environ ["IAC_CODE_CONFIG_BACKUP_DIR" ] = str (args .backup_dir .expanduser ().resolve ())
501523
502524 import uvicorn
503525
504526 from iac_code .a2a import executor as executor_module
505527 from iac_code .a2a import pipeline_executor as pipeline_executor_module
506528 from iac_code .a2a .app import create_app
529+ from iac_code .services import session_backup_staging as backup_staging_module
507530 from iac_code .services .providers .aliyun_identity import AliyunCallerIdentity , AliyunCallerIdentityResolver
508531
509532 async def resolve_fixture_identity (
@@ -516,10 +539,15 @@ async def resolve_fixture_identity(
516539
517540 AliyunCallerIdentityResolver .resolve = resolve_fixture_identity
518541
542+ if args .defer_staging_publisher :
543+ backup_staging_module .SessionBackupStagingProcess .start = lambda self : None
544+ backup_staging_module .SessionBackupStagingProcess .close = lambda self : None
545+
519546 executor_module .create_agent_runtime = lambda options : _create_fixture_runtime (
520547 options ,
521548 execution_log = execution_log ,
522549 handoff_first = args .handoff_first ,
550+ sequential_permissions = args .sequential_permissions ,
523551 )
524552 pipeline_executor_module .create_agent_runtime = executor_module .create_agent_runtime
525553 fixture_pipelines : dict [str , Any ] = {}
0 commit comments