simlock run holds a lease around one command, and a detached lease follows the agent process

未关闭
#944 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
android, ios, typescript
领域
cli, devtools

调研方向

Start with the CLI reference at website/src/content/docs/docs/reference/cli.mdx, the Android environment block in src/drivers/android/index.ts, and the renewal policy in src/lease-policy/index.ts. Then read src/leasing/AGENTS.md for the known holder lifecycle gap. The issue describes two features but leaves key design questions open; done means defining and implementing the chosen run and detached --bind-pid behavior, including renewal, child exit status, and release.

由索引模型根据 Issue 内容生成。

描述

request:new

Problem

An agent that uses the CLI runs one shell per tool call. The held form of simlock lease dies with that shell, so the docs steer agents to --detach with a 15 minute default TTL and manual simlock lease renew. In practice the agent copies the lease id and UDID out of the grant JSON by hand, starts a long build or test run, and forgets to renew. The lease ends mid-run and the device is wiped under the test runner.

Today, across several tool calls:

simlock lease --platform ios --device "iPhone 16" --detach --ttl 1h
# copy lease.id and device.driverDeviceId out of the JSON
xcodebuild -scheme MyApp -destination "generic/platform=iOS Simulator" build   # 12 min
simlock simctl install <UDID> build/Debug-iphonesimulator/MyApp.app
maestro test flows/                                                             # 20 min
simlock release <lease.id>

Two things are missing.

1. A command that holds a lease around one child process. The shape of xvfb-run, flock or timeout:

simlock run --platform ios --device "iPhone 16" -- sh -c '
  xcodebuild -scheme MyApp -destination "generic/platform=iOS Simulator" build &&
  simlock simctl install "$SIMLOCK_DEVICE_UDID" build/Debug-iphonesimulator/MyApp.app &&
  maestro test flows/'

run leases with the same options as lease, exports the lease into the child's environment (SIMLOCK_LEASE_ID, SIMLOCK_DEVICE_UDID, ANDROID_SERIAL, plus today's environment), renews every third of the TTL while the child runs, ends the child with a clear message when the lease is lost, releases on exit, and returns the child's exit code.

2. A detached lease that follows the agent's process. --bind-pid already releases a held lease when a named process exits, but it is ignored with --detach (website/src/content/docs/docs/reference/cli.mdx, --bind-pid row). Claude Code exports CLAUDE_PID into every shell it runs. --detach could leave a small keeper behind that renews the lease and releases it when that pid exits, by default when CLAUDE_PID (or an explicit --bind-pid) is present. A closed Claude Code window then frees the device in seconds instead of at the TTL, and nobody has to renew.

Context

Found in the 2026-10-23 product review. Related facts:

  • The grant environment carries no device identifier for virtual devices: only SIMLOCK_IOS_DEVICE_SET (iOS) and ANDROID_ADB_SERVER_PORT (Android). ANDROID_SERIAL is set only for physical phones (src/drivers/android/index.ts, environment block). Omitting -s on the shared adb server is ambiguous with several emulators up.
  • --export-env prints only environment, so the lease id and UDID are lost and the docs send the agent to simlock status, whose human line shows neither.
  • src/leasing/AGENTS.md lists "a SIGKILLed holder keeps its device until the TTL" as a known gap.
  • The MCP server and the held CLI already renew every TTL/3 (src/lease-policy/index.ts); run and the keeper reuse that policy.

Open questions for the spec session: whether run is a new command or a flag on lease; what the keeper does when the daemon restarts; whether run also accepts an existing lease id so a session can reuse a device across several run calls.

Written by an agent.

主要语言
TypeScript
星标
730
派生
44
平均合并
15 小时 28 分钟
30 天内合并 PR
387

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

callstackincubator/simlock 的其他 Issue

查看 callstackincubator/simlock 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。