沙箱会话生命周期:provider→session→execute→close

沙箱会话生命周期:provider→session→execute→close 由 Archify 生成的生命周期图。 01 / 获取会话 02 / 执行面 03 / 关闭 bash 请求 · 宿主侧命令 · 获取会话 · entry 01 bash 请求 宿主侧命令 entry supports 选型 · Provider 探测 · 获取会话 02 supports 选型 Provider 探测 createSession · 会话打开 · 获取会话 03 createSession 会话打开 execute · SandboxCommand · 执行面 04 execute SandboxCommand SandboxResult · exit/output/artifacts · 执行面 · pass 05 SandboxResult exit/output/artifacts pass close · 释放远端资源 · 关闭 · done 06 close 释放远端资源 done 图例 开始 活动状态 成功终态 中性状态

职责边界

  • • Provider:supports 探测+createSession;实现接 Docker/远端/本地受限环境
  • • Session:execute/cancel/listArtifacts/close;SandboxResult 带 exit/输出/产物

消费侧适配

  • • SandboxShellCommandExecutor 把 bash 命令翻译成 SandboxCommand 交 session
  • • 工具层只面对 SPI,provider 变化不扩散到业务代码

复用与清理

  • • 同一会话可多次 execute(虚线回路),各产独立 SandboxResult
  • • cancel 中断进行中命令;close 幂等释放远端资源