Skip to content
预计 1 分钟右侧目录可快速定位

Shell / Command Lifecycle ​

Source Map ​

Symbol作用
createShellWatchReadAccessor()将远端 resource accessor 投影成 terminal read capability
readShellTerminalSnapshot()把 read result 归一化为 exists/content 或显式错误
pollShellTerminalFile()轮询长期命令的 terminal artifact,直到 completion/cancel/error
parseShellTerminalFooter() call site从 output artifact 中提取 exit completion fact
SandLocalToolPermissionDeniedError branch权限撤销后停止观察并记录明确原因
SHELL_REWATCH_MAX_WAIT_MSrewatch 的时间边界
SHELL_REWATCH_MISSING_FILE_GIVE_UPoutput artifact 消失的失败边界

Control Flow ​

text
execution_id
  ↓
ensureBoxReady(scopedContext)
  ↓
resolve terminal output path
  ↓
readShellTerminalSnapshot()
  ↓
parse terminal footer
  ├─ complete + exit 0 → success
  ├─ complete + nonzero → error
  ├─ file missing repeatedly → error
  ├─ permission revoked → error / process may keep running
  ├─ cancelled → stop watcher
  └─ max wait exceeded → observer stops, command may keep running

这里能直接看到三个经常混淆的状态:observer stopped、command stopped、command completed 并不是一回事。

Resume / Reattach ​

Shell watch 的价值不只是第一次执行命令。Host restart 后只要还能恢复 execution identity 和 output path,就可以重新 watch 外部工作;因此 Command state 必须和 Turn memory 分离。

Local Locate ​

bash
rg -n "createShellWatchReadAccessor|readShellTerminalSnapshot|pollShellTerminalFile|SandLocalToolPermissionDeniedError|SHELL_REWATCH" source/host/runner/shell-terminal-watch.ts

Fixed Source ​

AI Engineering · Agent · Harness · Backend Systems