@openrig/cli 0.7.17 → 0.7.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (986) hide show
  1. package/README.md +7 -6
  2. package/daemon/assets/claude-hook-bridge.cjs +146 -0
  3. package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +1 -1
  4. package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +1 -1
  5. package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
  6. package/daemon/assets/plugins/openrig/plugin.json +1 -1
  7. package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
  8. package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
  9. package/daemon/assets/plugins/openrig-core/README.md +1 -1
  10. package/daemon/assets/plugins/openrig-core/hooks/claude.json +14 -14
  11. package/daemon/assets/plugins/openrig-core/hooks/scripts/activity-relay.cjs +43 -22
  12. package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +6 -0
  13. package/daemon/assets/plugins/openrig-core/skills/messaging-the-human/SKILL.md +23 -0
  14. package/daemon/assets/plugins/openrig-core/skills/mission-slice-sop/SKILL.md +1 -1
  15. package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +11 -0
  16. package/daemon/assets/plugins/openrig-core/skills/refocusing/scripts/trace-to-root.py +95 -7
  17. package/daemon/assets/skills/rigs/SKILL.md +68 -33
  18. package/daemon/assets/skills/rigs/references/installing-for-someone.md +2 -2
  19. package/daemon/context-packs/help/manifest.yaml +1 -1
  20. package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
  21. package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +57 -14
  22. package/daemon/context-packs/reference/getting-started.md +9 -4
  23. package/daemon/context-packs/reference/manifest.yaml +1 -1
  24. package/daemon/context-packs/reference/rig-spec.md +197 -1
  25. package/daemon/context-packs/reference/whats-new.md +187 -15
  26. package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
  27. package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
  28. package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
  29. package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
  30. package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
  31. package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
  32. package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
  33. package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
  34. package/daemon/context-packs/skills/core/messaging-the-human/SKILL.md +23 -0
  35. package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
  36. package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
  37. package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
  38. package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
  39. package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
  40. package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
  41. package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
  42. package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
  43. package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
  44. package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
  45. package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
  46. package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
  47. package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
  48. package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +1 -1
  49. package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
  50. package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
  51. package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
  52. package/daemon/context-packs/skills/mission-slice-sop/SKILL.md +1 -1
  53. package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
  54. package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
  55. package/daemon/context-packs/skills/openrig-user/SKILL.md +11 -0
  56. package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
  57. package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
  58. package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
  59. package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
  60. package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
  61. package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
  62. package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
  63. package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
  64. package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
  65. package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
  66. package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
  67. package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
  68. package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
  69. package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
  70. package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
  71. package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
  72. package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
  73. package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
  74. package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
  75. package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
  76. package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
  77. package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
  78. package/daemon/context-packs/skills/refocusing/scripts/trace-to-root.py +95 -7
  79. package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
  80. package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
  81. package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
  82. package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
  83. package/daemon/context-packs/world-example/manifest.yaml +1 -1
  84. package/daemon/context-packs/world-public/manifest.yaml +1 -1
  85. package/daemon/dist/adapters/claude-code-adapter.d.ts +9 -0
  86. package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
  87. package/daemon/dist/adapters/claude-code-adapter.js +57 -9
  88. package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
  89. package/daemon/dist/adapters/claude-resume.d.ts +4 -1
  90. package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
  91. package/daemon/dist/adapters/claude-resume.js +15 -5
  92. package/daemon/dist/adapters/claude-resume.js.map +1 -1
  93. package/daemon/dist/adapters/codex-runtime-adapter.d.ts +5 -0
  94. package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
  95. package/daemon/dist/adapters/codex-runtime-adapter.js +45 -10
  96. package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
  97. package/daemon/dist/adapters/kernel-authority.d.ts +8 -1
  98. package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
  99. package/daemon/dist/adapters/kernel-authority.js +45 -10
  100. package/daemon/dist/adapters/kernel-authority.js.map +1 -1
  101. package/daemon/dist/adapters/pi-resume.d.ts.map +1 -1
  102. package/daemon/dist/adapters/pi-resume.js +5 -7
  103. package/daemon/dist/adapters/pi-resume.js.map +1 -1
  104. package/daemon/dist/adapters/pi-runner-protocol.d.ts +47 -0
  105. package/daemon/dist/adapters/pi-runner-protocol.d.ts.map +1 -1
  106. package/daemon/dist/adapters/pi-runner-protocol.js.map +1 -1
  107. package/daemon/dist/adapters/pi-runner.d.ts +84 -1
  108. package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
  109. package/daemon/dist/adapters/pi-runner.js +799 -16
  110. package/daemon/dist/adapters/pi-runner.js.map +1 -1
  111. package/daemon/dist/adapters/pi-runtime-adapter.d.ts +7 -1
  112. package/daemon/dist/adapters/pi-runtime-adapter.d.ts.map +1 -1
  113. package/daemon/dist/adapters/pi-runtime-adapter.js +29 -19
  114. package/daemon/dist/adapters/pi-runtime-adapter.js.map +1 -1
  115. package/daemon/dist/adapters/tmux-credential-env.d.ts +4 -0
  116. package/daemon/dist/adapters/tmux-credential-env.d.ts.map +1 -0
  117. package/daemon/dist/adapters/tmux-credential-env.js +14 -0
  118. package/daemon/dist/adapters/tmux-credential-env.js.map +1 -0
  119. package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
  120. package/daemon/dist/adapters/tmux-exec.js +4 -3
  121. package/daemon/dist/adapters/tmux-exec.js.map +1 -1
  122. package/daemon/dist/adapters/tmux-server.d.ts +2 -2
  123. package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
  124. package/daemon/dist/adapters/tmux-server.js +12 -4
  125. package/daemon/dist/adapters/tmux-server.js.map +1 -1
  126. package/daemon/dist/adapters/tmux.d.ts +242 -14
  127. package/daemon/dist/adapters/tmux.d.ts.map +1 -1
  128. package/daemon/dist/adapters/tmux.js +966 -34
  129. package/daemon/dist/adapters/tmux.js.map +1 -1
  130. package/daemon/dist/attention-surface.d.ts +4 -1
  131. package/daemon/dist/attention-surface.d.ts.map +1 -1
  132. package/daemon/dist/attention-surface.js.map +1 -1
  133. package/daemon/dist/build-info.js +3 -3
  134. package/daemon/dist/db/all-migrations.d.ts.map +1 -1
  135. package/daemon/dist/db/all-migrations.js +14 -0
  136. package/daemon/dist/db/all-migrations.js.map +1 -1
  137. package/daemon/dist/db/migrations/171_claude_auto_mode.d.ts +4 -0
  138. package/daemon/dist/db/migrations/171_claude_auto_mode.d.ts.map +1 -0
  139. package/daemon/dist/db/migrations/171_claude_auto_mode.js +9 -0
  140. package/daemon/dist/db/migrations/171_claude_auto_mode.js.map +1 -0
  141. package/daemon/dist/db/migrations/171_node_input_route.d.ts +4 -0
  142. package/daemon/dist/db/migrations/171_node_input_route.d.ts.map +1 -0
  143. package/daemon/dist/db/migrations/171_node_input_route.js +6 -0
  144. package/daemon/dist/db/migrations/171_node_input_route.js.map +1 -0
  145. package/daemon/dist/db/migrations/171_seat_hook_bridge.d.ts +5 -0
  146. package/daemon/dist/db/migrations/171_seat_hook_bridge.d.ts.map +1 -0
  147. package/daemon/dist/db/migrations/171_seat_hook_bridge.js +25 -0
  148. package/daemon/dist/db/migrations/171_seat_hook_bridge.js.map +1 -0
  149. package/daemon/dist/db/migrations/172_queue_return_route.d.ts +3 -0
  150. package/daemon/dist/db/migrations/172_queue_return_route.d.ts.map +1 -0
  151. package/daemon/dist/db/migrations/172_queue_return_route.js +13 -0
  152. package/daemon/dist/db/migrations/172_queue_return_route.js.map +1 -0
  153. package/daemon/dist/db/migrations/173_node_process_limits.d.ts +4 -0
  154. package/daemon/dist/db/migrations/173_node_process_limits.d.ts.map +1 -0
  155. package/daemon/dist/db/migrations/173_node_process_limits.js +6 -0
  156. package/daemon/dist/db/migrations/173_node_process_limits.js.map +1 -0
  157. package/daemon/dist/db/migrations/174_session_launched_cwd.d.ts +6 -0
  158. package/daemon/dist/db/migrations/174_session_launched_cwd.d.ts.map +1 -0
  159. package/daemon/dist/db/migrations/174_session_launched_cwd.js +8 -0
  160. package/daemon/dist/db/migrations/174_session_launched_cwd.js.map +1 -0
  161. package/daemon/dist/db/migrations/175_core_app_access.d.ts +3 -0
  162. package/daemon/dist/db/migrations/175_core_app_access.d.ts.map +1 -0
  163. package/daemon/dist/db/migrations/175_core_app_access.js +26 -0
  164. package/daemon/dist/db/migrations/175_core_app_access.js.map +1 -0
  165. package/daemon/dist/domain/activity-grants.d.ts.map +1 -1
  166. package/daemon/dist/domain/activity-grants.js +8 -4
  167. package/daemon/dist/domain/activity-grants.js.map +1 -1
  168. package/daemon/dist/domain/agent-activity-store.d.ts +59 -1
  169. package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
  170. package/daemon/dist/domain/agent-activity-store.js +250 -4
  171. package/daemon/dist/domain/agent-activity-store.js.map +1 -1
  172. package/daemon/dist/domain/agent-images/resume-token-discovery.d.ts +10 -0
  173. package/daemon/dist/domain/agent-images/resume-token-discovery.d.ts.map +1 -1
  174. package/daemon/dist/domain/agent-images/resume-token-discovery.js +21 -0
  175. package/daemon/dist/domain/agent-images/resume-token-discovery.js.map +1 -1
  176. package/daemon/dist/domain/applied-launch-observation-store.d.ts +5 -0
  177. package/daemon/dist/domain/applied-launch-observation-store.d.ts.map +1 -1
  178. package/daemon/dist/domain/applied-launch-observation-store.js +57 -21
  179. package/daemon/dist/domain/applied-launch-observation-store.js.map +1 -1
  180. package/daemon/dist/domain/builtin-startup-files.d.ts +26 -12
  181. package/daemon/dist/domain/builtin-startup-files.d.ts.map +1 -1
  182. package/daemon/dist/domain/builtin-startup-files.js +73 -34
  183. package/daemon/dist/domain/builtin-startup-files.js.map +1 -1
  184. package/daemon/dist/domain/claude-activity-hooks.d.ts +4 -2
  185. package/daemon/dist/domain/claude-activity-hooks.d.ts.map +1 -1
  186. package/daemon/dist/domain/claude-activity-hooks.js +5 -3
  187. package/daemon/dist/domain/claude-activity-hooks.js.map +1 -1
  188. package/daemon/dist/domain/claude-auto-mode.d.ts +64 -0
  189. package/daemon/dist/domain/claude-auto-mode.d.ts.map +1 -0
  190. package/daemon/dist/domain/claude-auto-mode.js +114 -0
  191. package/daemon/dist/domain/claude-auto-mode.js.map +1 -0
  192. package/daemon/dist/domain/claude-compaction-enforcer.d.ts +66 -3
  193. package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
  194. package/daemon/dist/domain/claude-compaction-enforcer.js +214 -10
  195. package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
  196. package/daemon/dist/domain/claude-continuation-launch.d.ts +5 -1
  197. package/daemon/dist/domain/claude-continuation-launch.d.ts.map +1 -1
  198. package/daemon/dist/domain/claude-continuation-launch.js +51 -2
  199. package/daemon/dist/domain/claude-continuation-launch.js.map +1 -1
  200. package/daemon/dist/domain/claude-core-plugin-env.d.ts +7 -3
  201. package/daemon/dist/domain/claude-core-plugin-env.d.ts.map +1 -1
  202. package/daemon/dist/domain/claude-core-plugin-env.js +11 -8
  203. package/daemon/dist/domain/claude-core-plugin-env.js.map +1 -1
  204. package/daemon/dist/domain/codex-daemon-support.d.ts.map +1 -1
  205. package/daemon/dist/domain/codex-daemon-support.js +6 -1
  206. package/daemon/dist/domain/codex-daemon-support.js.map +1 -1
  207. package/daemon/dist/domain/community-harness-launch-result.d.ts +2 -0
  208. package/daemon/dist/domain/community-harness-launch-result.d.ts.map +1 -1
  209. package/daemon/dist/domain/community-harness-launch-result.js +5 -1
  210. package/daemon/dist/domain/community-harness-launch-result.js.map +1 -1
  211. package/daemon/dist/domain/compaction-restore-notice.d.ts +3 -1
  212. package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -1
  213. package/daemon/dist/domain/compaction-restore-notice.js +22 -3
  214. package/daemon/dist/domain/compaction-restore-notice.js.map +1 -1
  215. package/daemon/dist/domain/configured-account.d.ts +3 -0
  216. package/daemon/dist/domain/configured-account.d.ts.map +1 -0
  217. package/daemon/dist/domain/configured-account.js +10 -0
  218. package/daemon/dist/domain/configured-account.js.map +1 -0
  219. package/daemon/dist/domain/connection-contract.d.ts +91 -0
  220. package/daemon/dist/domain/connection-contract.d.ts.map +1 -1
  221. package/daemon/dist/domain/connection-contract.js +73 -0
  222. package/daemon/dist/domain/connection-contract.js.map +1 -1
  223. package/daemon/dist/domain/context-usage-store.d.ts +5 -0
  224. package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
  225. package/daemon/dist/domain/context-usage-store.js +37 -2
  226. package/daemon/dist/domain/context-usage-store.js.map +1 -1
  227. package/daemon/dist/domain/core-app-access.d.ts +51 -0
  228. package/daemon/dist/domain/core-app-access.d.ts.map +1 -0
  229. package/daemon/dist/domain/core-app-access.js +107 -0
  230. package/daemon/dist/domain/core-app-access.js.map +1 -0
  231. package/daemon/dist/domain/core-app-job.d.ts +411 -0
  232. package/daemon/dist/domain/core-app-job.d.ts.map +1 -0
  233. package/daemon/dist/domain/core-app-job.js +537 -0
  234. package/daemon/dist/domain/core-app-job.js.map +1 -0
  235. package/daemon/dist/domain/current-park-arm.d.ts +4 -0
  236. package/daemon/dist/domain/current-park-arm.d.ts.map +1 -0
  237. package/daemon/dist/domain/current-park-arm.js +14 -0
  238. package/daemon/dist/domain/current-park-arm.js.map +1 -0
  239. package/daemon/dist/domain/current-work.d.ts +6 -1
  240. package/daemon/dist/domain/current-work.d.ts.map +1 -1
  241. package/daemon/dist/domain/current-work.js +41 -8
  242. package/daemon/dist/domain/current-work.js.map +1 -1
  243. package/daemon/dist/domain/cwd-resolution.d.ts +14 -0
  244. package/daemon/dist/domain/cwd-resolution.d.ts.map +1 -1
  245. package/daemon/dist/domain/cwd-resolution.js +28 -3
  246. package/daemon/dist/domain/cwd-resolution.js.map +1 -1
  247. package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
  248. package/daemon/dist/domain/draft-aware-delivery.js +5 -1
  249. package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
  250. package/daemon/dist/domain/errors.d.ts +4 -0
  251. package/daemon/dist/domain/errors.d.ts.map +1 -1
  252. package/daemon/dist/domain/errors.js +7 -0
  253. package/daemon/dist/domain/errors.js.map +1 -1
  254. package/daemon/dist/domain/execution-view.d.ts.map +1 -1
  255. package/daemon/dist/domain/execution-view.js +17 -4
  256. package/daemon/dist/domain/execution-view.js.map +1 -1
  257. package/daemon/dist/domain/existing-rig-restore.d.ts +2 -0
  258. package/daemon/dist/domain/existing-rig-restore.d.ts.map +1 -1
  259. package/daemon/dist/domain/existing-rig-restore.js +1 -0
  260. package/daemon/dist/domain/existing-rig-restore.js.map +1 -1
  261. package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
  262. package/daemon/dist/domain/gateway/operator-delivery-engine.js +107 -3
  263. package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
  264. package/daemon/dist/domain/gateway/participants.d.ts +2 -0
  265. package/daemon/dist/domain/gateway/participants.d.ts.map +1 -1
  266. package/daemon/dist/domain/gateway/participants.js +5 -1
  267. package/daemon/dist/domain/gateway/participants.js.map +1 -1
  268. package/daemon/dist/domain/gateway/slack/capabilities.d.ts +9 -1
  269. package/daemon/dist/domain/gateway/slack/capabilities.d.ts.map +1 -1
  270. package/daemon/dist/domain/gateway/slack/capabilities.js +6 -1
  271. package/daemon/dist/domain/gateway/slack/capabilities.js.map +1 -1
  272. package/daemon/dist/domain/gateway/slack/inbound-admission.js +1 -1
  273. package/daemon/dist/domain/gateway/slack/inbound-admission.js.map +1 -1
  274. package/daemon/dist/domain/gateway/slack/inbound.d.ts +4 -0
  275. package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
  276. package/daemon/dist/domain/gateway/slack/inbound.js +15 -1
  277. package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
  278. package/daemon/dist/domain/gateway/slack/manifest.d.ts +5 -1
  279. package/daemon/dist/domain/gateway/slack/manifest.d.ts.map +1 -1
  280. package/daemon/dist/domain/gateway/slack/manifest.js +12 -3
  281. package/daemon/dist/domain/gateway/slack/manifest.js.map +1 -1
  282. package/daemon/dist/domain/gateway/slack/message.d.ts +2 -0
  283. package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
  284. package/daemon/dist/domain/gateway/slack/message.js +41 -18
  285. package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
  286. package/daemon/dist/domain/gateway/slack/queue-access.d.ts +2 -0
  287. package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
  288. package/daemon/dist/domain/gateway/slack/queue-access.js +1 -0
  289. package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
  290. package/daemon/dist/domain/gateway/slack/settled-asks.d.ts.map +1 -1
  291. package/daemon/dist/domain/gateway/slack/settled-asks.js +6 -5
  292. package/daemon/dist/domain/gateway/slack/settled-asks.js.map +1 -1
  293. package/daemon/dist/domain/gateway/slack/slack-api.d.ts +1 -0
  294. package/daemon/dist/domain/gateway/slack/slack-api.d.ts.map +1 -1
  295. package/daemon/dist/domain/gateway/slack/slack-api.js +7 -2
  296. package/daemon/dist/domain/gateway/slack/slack-api.js.map +1 -1
  297. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts +1 -0
  298. package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
  299. package/daemon/dist/domain/gateway/slack/slack-delivery.js +2 -0
  300. package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
  301. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts +4 -0
  302. package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
  303. package/daemon/dist/domain/gateway/slack/slack-subsystem.js +26 -2
  304. package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
  305. package/daemon/dist/domain/harness-not-started-notice.d.ts +36 -0
  306. package/daemon/dist/domain/harness-not-started-notice.d.ts.map +1 -0
  307. package/daemon/dist/domain/harness-not-started-notice.js +81 -0
  308. package/daemon/dist/domain/harness-not-started-notice.js.map +1 -0
  309. package/daemon/dist/domain/hook-bridge.d.ts +345 -0
  310. package/daemon/dist/domain/hook-bridge.d.ts.map +1 -0
  311. package/daemon/dist/domain/hook-bridge.js +547 -0
  312. package/daemon/dist/domain/hook-bridge.js.map +1 -0
  313. package/daemon/dist/domain/hosted-wake.d.ts +9 -0
  314. package/daemon/dist/domain/hosted-wake.d.ts.map +1 -1
  315. package/daemon/dist/domain/hosted-wake.js +45 -6
  316. package/daemon/dist/domain/hosted-wake.js.map +1 -1
  317. package/daemon/dist/domain/hot-potato-enforcer.d.ts +1 -1
  318. package/daemon/dist/domain/human-ask-attention.d.ts +10 -0
  319. package/daemon/dist/domain/human-ask-attention.d.ts.map +1 -0
  320. package/daemon/dist/domain/human-ask-attention.js +22 -0
  321. package/daemon/dist/domain/human-ask-attention.js.map +1 -0
  322. package/daemon/dist/domain/input-read-diagnostic.js +1 -1
  323. package/daemon/dist/domain/input-read-diagnostic.js.map +1 -1
  324. package/daemon/dist/domain/instance-initialization.d.ts +2 -0
  325. package/daemon/dist/domain/instance-initialization.d.ts.map +1 -1
  326. package/daemon/dist/domain/instance-initialization.js +2 -1
  327. package/daemon/dist/domain/instance-initialization.js.map +1 -1
  328. package/daemon/dist/domain/member-connection.d.ts +14 -0
  329. package/daemon/dist/domain/member-connection.d.ts.map +1 -0
  330. package/daemon/dist/domain/member-connection.js +34 -0
  331. package/daemon/dist/domain/member-connection.js.map +1 -0
  332. package/daemon/dist/domain/mission-control/mission-control-action-log.d.ts +4 -0
  333. package/daemon/dist/domain/mission-control/mission-control-action-log.d.ts.map +1 -1
  334. package/daemon/dist/domain/mission-control/mission-control-action-log.js +8 -1
  335. package/daemon/dist/domain/mission-control/mission-control-action-log.js.map +1 -1
  336. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +10 -0
  337. package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
  338. package/daemon/dist/domain/mission-control/mission-control-write-contract.js +64 -12
  339. package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
  340. package/daemon/dist/domain/model-divergence/current-model-reader.d.ts +3 -1
  341. package/daemon/dist/domain/model-divergence/current-model-reader.d.ts.map +1 -1
  342. package/daemon/dist/domain/model-divergence/current-model-reader.js +32 -7
  343. package/daemon/dist/domain/model-divergence/current-model-reader.js.map +1 -1
  344. package/daemon/dist/domain/native-continuation-notice.d.ts +16 -0
  345. package/daemon/dist/domain/native-continuation-notice.d.ts.map +1 -0
  346. package/daemon/dist/domain/native-continuation-notice.js +79 -0
  347. package/daemon/dist/domain/native-continuation-notice.js.map +1 -0
  348. package/daemon/dist/domain/native-permission-store.d.ts +6 -2
  349. package/daemon/dist/domain/native-permission-store.d.ts.map +1 -1
  350. package/daemon/dist/domain/native-permission-store.js +12 -5
  351. package/daemon/dist/domain/native-permission-store.js.map +1 -1
  352. package/daemon/dist/domain/native-process-lineage.d.ts +16 -0
  353. package/daemon/dist/domain/native-process-lineage.d.ts.map +1 -1
  354. package/daemon/dist/domain/native-process-lineage.js +48 -3
  355. package/daemon/dist/domain/native-process-lineage.js.map +1 -1
  356. package/daemon/dist/domain/native-resume-probe.d.ts +5 -0
  357. package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
  358. package/daemon/dist/domain/native-resume-probe.js +94 -10
  359. package/daemon/dist/domain/native-resume-probe.js.map +1 -1
  360. package/daemon/dist/domain/network/network-connector.d.ts.map +1 -1
  361. package/daemon/dist/domain/network/network-connector.js +11 -2
  362. package/daemon/dist/domain/network/network-connector.js.map +1 -1
  363. package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
  364. package/daemon/dist/domain/node-inventory.js +55 -6
  365. package/daemon/dist/domain/node-inventory.js.map +1 -1
  366. package/daemon/dist/domain/node-launcher.d.ts +14 -0
  367. package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
  368. package/daemon/dist/domain/node-launcher.js +35 -6
  369. package/daemon/dist/domain/node-launcher.js.map +1 -1
  370. package/daemon/dist/domain/outbox-handler.d.ts +69 -1
  371. package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
  372. package/daemon/dist/domain/outbox-handler.js +337 -3
  373. package/daemon/dist/domain/outbox-handler.js.map +1 -1
  374. package/daemon/dist/domain/park-wake-text.d.ts +18 -0
  375. package/daemon/dist/domain/park-wake-text.d.ts.map +1 -1
  376. package/daemon/dist/domain/park-wake-text.js +44 -0
  377. package/daemon/dist/domain/park-wake-text.js.map +1 -1
  378. package/daemon/dist/domain/parked-query.d.ts.map +1 -1
  379. package/daemon/dist/domain/parked-query.js +3 -1
  380. package/daemon/dist/domain/parked-query.js.map +1 -1
  381. package/daemon/dist/domain/permission-account.d.ts +28 -1
  382. package/daemon/dist/domain/permission-account.d.ts.map +1 -1
  383. package/daemon/dist/domain/permission-account.js +55 -11
  384. package/daemon/dist/domain/permission-account.js.map +1 -1
  385. package/daemon/dist/domain/permission-drift.d.ts +2 -0
  386. package/daemon/dist/domain/permission-drift.d.ts.map +1 -1
  387. package/daemon/dist/domain/permission-drift.js.map +1 -1
  388. package/daemon/dist/domain/pi-compaction-request-store.d.ts +16 -0
  389. package/daemon/dist/domain/pi-compaction-request-store.d.ts.map +1 -0
  390. package/daemon/dist/domain/pi-compaction-request-store.js +40 -0
  391. package/daemon/dist/domain/pi-compaction-request-store.js.map +1 -0
  392. package/daemon/dist/domain/pi-compaction-service.d.ts +82 -0
  393. package/daemon/dist/domain/pi-compaction-service.d.ts.map +1 -0
  394. package/daemon/dist/domain/pi-compaction-service.js +229 -0
  395. package/daemon/dist/domain/pi-compaction-service.js.map +1 -0
  396. package/daemon/dist/domain/policies/idle-gate-qitem.d.ts +3 -0
  397. package/daemon/dist/domain/policies/idle-gate-qitem.d.ts.map +1 -1
  398. package/daemon/dist/domain/policies/idle-gate-qitem.js +15 -0
  399. package/daemon/dist/domain/policies/idle-gate-qitem.js.map +1 -1
  400. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +6 -1
  401. package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
  402. package/daemon/dist/domain/policies/parked-owner-consumer.js +28 -1
  403. package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
  404. package/daemon/dist/domain/process-limits.d.ts +47 -0
  405. package/daemon/dist/domain/process-limits.d.ts.map +1 -0
  406. package/daemon/dist/domain/process-limits.js +123 -0
  407. package/daemon/dist/domain/process-limits.js.map +1 -0
  408. package/daemon/dist/domain/process-table.d.ts +24 -0
  409. package/daemon/dist/domain/process-table.d.ts.map +1 -1
  410. package/daemon/dist/domain/process-table.js +60 -4
  411. package/daemon/dist/domain/process-table.js.map +1 -1
  412. package/daemon/dist/domain/proof/judgments.d.ts +7 -0
  413. package/daemon/dist/domain/proof/judgments.d.ts.map +1 -1
  414. package/daemon/dist/domain/proof/judgments.js +27 -1
  415. package/daemon/dist/domain/proof/judgments.js.map +1 -1
  416. package/daemon/dist/domain/ps-projection.d.ts +2 -1
  417. package/daemon/dist/domain/ps-projection.d.ts.map +1 -1
  418. package/daemon/dist/domain/ps-projection.js +6 -1
  419. package/daemon/dist/domain/ps-projection.js.map +1 -1
  420. package/daemon/dist/domain/queue-erasure.d.ts +11 -6
  421. package/daemon/dist/domain/queue-erasure.d.ts.map +1 -1
  422. package/daemon/dist/domain/queue-erasure.js +47 -21
  423. package/daemon/dist/domain/queue-erasure.js.map +1 -1
  424. package/daemon/dist/domain/queue-repository.d.ts +122 -21
  425. package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
  426. package/daemon/dist/domain/queue-repository.js +448 -101
  427. package/daemon/dist/domain/queue-repository.js.map +1 -1
  428. package/daemon/dist/domain/queue-stuck-sweep.d.ts +5 -0
  429. package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
  430. package/daemon/dist/domain/queue-stuck-sweep.js +74 -13
  431. package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
  432. package/daemon/dist/domain/queue-transition-log.d.ts +5 -3
  433. package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
  434. package/daemon/dist/domain/queue-transition-log.js +9 -6
  435. package/daemon/dist/domain/queue-transition-log.js.map +1 -1
  436. package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
  437. package/daemon/dist/domain/queue-waiting.js +28 -3
  438. package/daemon/dist/domain/queue-waiting.js.map +1 -1
  439. package/daemon/dist/domain/queue-wake-ladder.d.ts +20 -0
  440. package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
  441. package/daemon/dist/domain/queue-wake-ladder.js +264 -25
  442. package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
  443. package/daemon/dist/domain/queue-wake-repository.d.ts +10 -1
  444. package/daemon/dist/domain/queue-wake-repository.d.ts.map +1 -1
  445. package/daemon/dist/domain/queue-wake-repository.js +79 -12
  446. package/daemon/dist/domain/queue-wake-repository.js.map +1 -1
  447. package/daemon/dist/domain/reconciler.d.ts +18 -2
  448. package/daemon/dist/domain/reconciler.d.ts.map +1 -1
  449. package/daemon/dist/domain/reconciler.js +40 -0
  450. package/daemon/dist/domain/reconciler.js.map +1 -1
  451. package/daemon/dist/domain/restore-attempt-receipt.d.ts.map +1 -1
  452. package/daemon/dist/domain/restore-attempt-receipt.js +3 -2
  453. package/daemon/dist/domain/restore-attempt-receipt.js.map +1 -1
  454. package/daemon/dist/domain/restore-check-service.d.ts +10 -0
  455. package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
  456. package/daemon/dist/domain/restore-check-service.js +76 -3
  457. package/daemon/dist/domain/restore-check-service.js.map +1 -1
  458. package/daemon/dist/domain/restore-orchestrator.d.ts +65 -3
  459. package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
  460. package/daemon/dist/domain/restore-orchestrator.js +311 -55
  461. package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
  462. package/daemon/dist/domain/restore-plan-preview.d.ts +28 -1
  463. package/daemon/dist/domain/restore-plan-preview.d.ts.map +1 -1
  464. package/daemon/dist/domain/restore-plan-preview.js +17 -5
  465. package/daemon/dist/domain/restore-plan-preview.js.map +1 -1
  466. package/daemon/dist/domain/restore-preconditions.d.ts +24 -0
  467. package/daemon/dist/domain/restore-preconditions.d.ts.map +1 -1
  468. package/daemon/dist/domain/restore-preconditions.js +61 -1
  469. package/daemon/dist/domain/restore-preconditions.js.map +1 -1
  470. package/daemon/dist/domain/restore-topology.d.ts +7 -1
  471. package/daemon/dist/domain/restore-topology.d.ts.map +1 -1
  472. package/daemon/dist/domain/restore-topology.js +21 -0
  473. package/daemon/dist/domain/restore-topology.js.map +1 -1
  474. package/daemon/dist/domain/resume-metadata-refresher.d.ts +2 -3
  475. package/daemon/dist/domain/resume-metadata-refresher.d.ts.map +1 -1
  476. package/daemon/dist/domain/resume-metadata-refresher.js +6 -25
  477. package/daemon/dist/domain/resume-metadata-refresher.js.map +1 -1
  478. package/daemon/dist/domain/resume-token-validation.d.ts +3 -1
  479. package/daemon/dist/domain/resume-token-validation.d.ts.map +1 -1
  480. package/daemon/dist/domain/resume-token-validation.js +6 -3
  481. package/daemon/dist/domain/resume-token-validation.js.map +1 -1
  482. package/daemon/dist/domain/return-route.d.ts +73 -0
  483. package/daemon/dist/domain/return-route.d.ts.map +1 -0
  484. package/daemon/dist/domain/return-route.js +124 -0
  485. package/daemon/dist/domain/return-route.js.map +1 -0
  486. package/daemon/dist/domain/rig-expansion-service.js +1 -1
  487. package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
  488. package/daemon/dist/domain/rig-repository.d.ts +12 -0
  489. package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
  490. package/daemon/dist/domain/rig-repository.js +74 -0
  491. package/daemon/dist/domain/rig-repository.js.map +1 -1
  492. package/daemon/dist/domain/rig-teardown.d.ts +20 -5
  493. package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
  494. package/daemon/dist/domain/rig-teardown.js +105 -22
  495. package/daemon/dist/domain/rig-teardown.js.map +1 -1
  496. package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
  497. package/daemon/dist/domain/rigspec-codec.js +9 -0
  498. package/daemon/dist/domain/rigspec-codec.js.map +1 -1
  499. package/daemon/dist/domain/rigspec-exporter.d.ts +6 -0
  500. package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
  501. package/daemon/dist/domain/rigspec-exporter.js +30 -0
  502. package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
  503. package/daemon/dist/domain/rigspec-instantiator.d.ts +27 -2
  504. package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
  505. package/daemon/dist/domain/rigspec-instantiator.js +95 -26
  506. package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
  507. package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
  508. package/daemon/dist/domain/rigspec-schema.js +44 -1
  509. package/daemon/dist/domain/rigspec-schema.js.map +1 -1
  510. package/daemon/dist/domain/rosters.d.ts +23 -0
  511. package/daemon/dist/domain/rosters.d.ts.map +1 -1
  512. package/daemon/dist/domain/rosters.js +37 -5
  513. package/daemon/dist/domain/rosters.js.map +1 -1
  514. package/daemon/dist/domain/runner-channel.d.ts +65 -0
  515. package/daemon/dist/domain/runner-channel.d.ts.map +1 -0
  516. package/daemon/dist/domain/runner-channel.js +348 -0
  517. package/daemon/dist/domain/runner-channel.js.map +1 -0
  518. package/daemon/dist/domain/runner-grant-launch.js +2 -2
  519. package/daemon/dist/domain/runner-permissions.d.ts +26 -3
  520. package/daemon/dist/domain/runner-permissions.d.ts.map +1 -1
  521. package/daemon/dist/domain/runner-permissions.js +160 -39
  522. package/daemon/dist/domain/runner-permissions.js.map +1 -1
  523. package/daemon/dist/domain/runtime-adapter.d.ts +2 -0
  524. package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
  525. package/daemon/dist/domain/runtime-adapter.js.map +1 -1
  526. package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -1
  527. package/daemon/dist/domain/runtime-switch-materials.js +4 -3
  528. package/daemon/dist/domain/runtime-switch-materials.js.map +1 -1
  529. package/daemon/dist/domain/scope/mission-parent.d.ts +19 -0
  530. package/daemon/dist/domain/scope/mission-parent.d.ts.map +1 -0
  531. package/daemon/dist/domain/scope/mission-parent.js +134 -0
  532. package/daemon/dist/domain/scope/mission-parent.js.map +1 -0
  533. package/daemon/dist/domain/scope/scope-audit.d.ts.map +1 -1
  534. package/daemon/dist/domain/scope/scope-audit.js +63 -3
  535. package/daemon/dist/domain/scope/scope-audit.js.map +1 -1
  536. package/daemon/dist/domain/scope/types.d.ts +3 -1
  537. package/daemon/dist/domain/scope/types.d.ts.map +1 -1
  538. package/daemon/dist/domain/scope/types.js +5 -1
  539. package/daemon/dist/domain/scope/types.js.map +1 -1
  540. package/daemon/dist/domain/seat-attention-reconciler.d.ts +6 -4
  541. package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
  542. package/daemon/dist/domain/seat-attention-reconciler.js +17 -10
  543. package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
  544. package/daemon/dist/domain/seat-delivery-guard.d.ts +14 -2
  545. package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
  546. package/daemon/dist/domain/seat-delivery-guard.js +55 -15
  547. package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
  548. package/daemon/dist/domain/seat-handover-service.d.ts +27 -4
  549. package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
  550. package/daemon/dist/domain/seat-handover-service.js +210 -65
  551. package/daemon/dist/domain/seat-handover-service.js.map +1 -1
  552. package/daemon/dist/domain/seat-identity-reconciler.d.ts +12 -4
  553. package/daemon/dist/domain/seat-identity-reconciler.d.ts.map +1 -1
  554. package/daemon/dist/domain/seat-identity-reconciler.js +92 -17
  555. package/daemon/dist/domain/seat-identity-reconciler.js.map +1 -1
  556. package/daemon/dist/domain/seat-lifecycle-service.d.ts +31 -6
  557. package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
  558. package/daemon/dist/domain/seat-lifecycle-service.js +172 -24
  559. package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
  560. package/daemon/dist/domain/seat-restart-in-place.d.ts +9 -2
  561. package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
  562. package/daemon/dist/domain/seat-restart-in-place.js +38 -3
  563. package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
  564. package/daemon/dist/domain/seat-runtime-switch-service.d.ts +4 -0
  565. package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
  566. package/daemon/dist/domain/seat-runtime-switch-service.js +11 -3
  567. package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
  568. package/daemon/dist/domain/seat-skill-apply.d.ts +1 -1
  569. package/daemon/dist/domain/seat-skill-apply.d.ts.map +1 -1
  570. package/daemon/dist/domain/seat-skill-apply.js +3 -2
  571. package/daemon/dist/domain/seat-skill-apply.js.map +1 -1
  572. package/daemon/dist/domain/seat-status-service.d.ts +4 -0
  573. package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
  574. package/daemon/dist/domain/seat-status-service.js +31 -6
  575. package/daemon/dist/domain/seat-status-service.js.map +1 -1
  576. package/daemon/dist/domain/session-registry.d.ts +5 -1
  577. package/daemon/dist/domain/session-registry.d.ts.map +1 -1
  578. package/daemon/dist/domain/session-registry.js +12 -1
  579. package/daemon/dist/domain/session-registry.js.map +1 -1
  580. package/daemon/dist/domain/session-transport.d.ts +56 -4
  581. package/daemon/dist/domain/session-transport.d.ts.map +1 -1
  582. package/daemon/dist/domain/session-transport.js +344 -18
  583. package/daemon/dist/domain/session-transport.js.map +1 -1
  584. package/daemon/dist/domain/shared-conversation.d.ts +58 -0
  585. package/daemon/dist/domain/shared-conversation.d.ts.map +1 -0
  586. package/daemon/dist/domain/shared-conversation.js +98 -0
  587. package/daemon/dist/domain/shared-conversation.js.map +1 -0
  588. package/daemon/dist/domain/shared-history-selection.d.ts.map +1 -1
  589. package/daemon/dist/domain/shared-history-selection.js +9 -5
  590. package/daemon/dist/domain/shared-history-selection.js.map +1 -1
  591. package/daemon/dist/domain/slices/slice-indexer.d.ts +1 -1
  592. package/daemon/dist/domain/slices/slice-indexer.d.ts.map +1 -1
  593. package/daemon/dist/domain/slices/slice-indexer.js +4 -0
  594. package/daemon/dist/domain/slices/slice-indexer.js.map +1 -1
  595. package/daemon/dist/domain/startup-orchestrator.d.ts +1 -0
  596. package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
  597. package/daemon/dist/domain/startup-orchestrator.js +6 -4
  598. package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
  599. package/daemon/dist/domain/startup-phase-timing.d.ts +19 -0
  600. package/daemon/dist/domain/startup-phase-timing.d.ts.map +1 -0
  601. package/daemon/dist/domain/startup-phase-timing.js +23 -0
  602. package/daemon/dist/domain/startup-phase-timing.js.map +1 -0
  603. package/daemon/dist/domain/successor-session-launcher.d.ts +9 -0
  604. package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
  605. package/daemon/dist/domain/successor-session-launcher.js +33 -10
  606. package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
  607. package/daemon/dist/domain/team-operations.d.ts +6 -6
  608. package/daemon/dist/domain/team-operations.d.ts.map +1 -1
  609. package/daemon/dist/domain/team-operations.js +2 -4
  610. package/daemon/dist/domain/team-operations.js.map +1 -1
  611. package/daemon/dist/domain/terminal/herdr-adapter.d.ts +35 -1
  612. package/daemon/dist/domain/terminal/herdr-adapter.d.ts.map +1 -1
  613. package/daemon/dist/domain/terminal/herdr-adapter.js +231 -33
  614. package/daemon/dist/domain/terminal/herdr-adapter.js.map +1 -1
  615. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts +6 -0
  616. package/daemon/dist/domain/terminal/herdr-app-provider.d.ts.map +1 -1
  617. package/daemon/dist/domain/terminal/herdr-app-provider.js +23 -1
  618. package/daemon/dist/domain/terminal/herdr-app-provider.js.map +1 -1
  619. package/daemon/dist/domain/terminal/herdr-sessions.d.ts.map +1 -1
  620. package/daemon/dist/domain/terminal/herdr-sessions.js +2 -1
  621. package/daemon/dist/domain/terminal/herdr-sessions.js.map +1 -1
  622. package/daemon/dist/domain/terminal/rig-viewer-records.d.ts +59 -0
  623. package/daemon/dist/domain/terminal/rig-viewer-records.d.ts.map +1 -0
  624. package/daemon/dist/domain/terminal/rig-viewer-records.js +210 -0
  625. package/daemon/dist/domain/terminal/rig-viewer-records.js.map +1 -0
  626. package/daemon/dist/domain/terminal/terminal-provider.d.ts +2 -0
  627. package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -1
  628. package/daemon/dist/domain/terminal/terminal-service.d.ts +99 -4
  629. package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
  630. package/daemon/dist/domain/terminal/terminal-service.js +556 -36
  631. package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
  632. package/daemon/dist/domain/terminal/tile-layout.js +1 -1
  633. package/daemon/dist/domain/terminal/tile-layout.js.map +1 -1
  634. package/daemon/dist/domain/terminal/tmux-viewer-guard.d.ts +25 -0
  635. package/daemon/dist/domain/terminal/tmux-viewer-guard.d.ts.map +1 -0
  636. package/daemon/dist/domain/terminal/tmux-viewer-guard.js +70 -0
  637. package/daemon/dist/domain/terminal/tmux-viewer-guard.js.map +1 -0
  638. package/daemon/dist/domain/terminal-policy.js +1 -1
  639. package/daemon/dist/domain/terminal-policy.js.map +1 -1
  640. package/daemon/dist/domain/transcript-grep-worker.d.ts +2 -0
  641. package/daemon/dist/domain/transcript-grep-worker.d.ts.map +1 -0
  642. package/daemon/dist/domain/transcript-grep-worker.js +108 -0
  643. package/daemon/dist/domain/transcript-grep-worker.js.map +1 -0
  644. package/daemon/dist/domain/transcript-grep.d.ts +26 -0
  645. package/daemon/dist/domain/transcript-grep.d.ts.map +1 -0
  646. package/daemon/dist/domain/transcript-grep.js +90 -0
  647. package/daemon/dist/domain/transcript-grep.js.map +1 -0
  648. package/daemon/dist/domain/transcript-store.d.ts +8 -2
  649. package/daemon/dist/domain/transcript-store.d.ts.map +1 -1
  650. package/daemon/dist/domain/transcript-store.js +10 -60
  651. package/daemon/dist/domain/transcript-store.js.map +1 -1
  652. package/daemon/dist/domain/types.d.ts +149 -5
  653. package/daemon/dist/domain/types.d.ts.map +1 -1
  654. package/daemon/dist/domain/types.js.map +1 -1
  655. package/daemon/dist/domain/watchdog-delivery-receipts.d.ts +4 -0
  656. package/daemon/dist/domain/watchdog-delivery-receipts.d.ts.map +1 -1
  657. package/daemon/dist/domain/watchdog-delivery-receipts.js +35 -2
  658. package/daemon/dist/domain/watchdog-delivery-receipts.js.map +1 -1
  659. package/daemon/dist/domain/watchdog-delivery.d.ts +45 -1
  660. package/daemon/dist/domain/watchdog-delivery.d.ts.map +1 -1
  661. package/daemon/dist/domain/watchdog-delivery.js +66 -5
  662. package/daemon/dist/domain/watchdog-delivery.js.map +1 -1
  663. package/daemon/dist/domain/watchdog-history-log.d.ts +12 -0
  664. package/daemon/dist/domain/watchdog-history-log.d.ts.map +1 -1
  665. package/daemon/dist/domain/watchdog-history-log.js +19 -1
  666. package/daemon/dist/domain/watchdog-history-log.js.map +1 -1
  667. package/daemon/dist/domain/watchdog-jobs-repository.d.ts +32 -0
  668. package/daemon/dist/domain/watchdog-jobs-repository.d.ts.map +1 -1
  669. package/daemon/dist/domain/watchdog-jobs-repository.js +79 -0
  670. package/daemon/dist/domain/watchdog-jobs-repository.js.map +1 -1
  671. package/daemon/dist/domain/watchdog-policy-engine.d.ts +22 -3
  672. package/daemon/dist/domain/watchdog-policy-engine.d.ts.map +1 -1
  673. package/daemon/dist/domain/watchdog-policy-engine.js +33 -9
  674. package/daemon/dist/domain/watchdog-policy-engine.js.map +1 -1
  675. package/daemon/dist/domain/workflow-projector.js +1 -1
  676. package/daemon/dist/domain/workflow-projector.js.map +1 -1
  677. package/daemon/dist/domain/workflow-runtime.d.ts +13 -1
  678. package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
  679. package/daemon/dist/domain/workflow-runtime.js +68 -9
  680. package/daemon/dist/domain/workflow-runtime.js.map +1 -1
  681. package/daemon/dist/domain/workflow-step-trail-log.d.ts +2 -2
  682. package/daemon/dist/domain/workflow-step-trail-log.d.ts.map +1 -1
  683. package/daemon/dist/domain/workflow-step-trail-log.js.map +1 -1
  684. package/daemon/dist/domain/workflow-types.d.ts +3 -1
  685. package/daemon/dist/domain/workflow-types.d.ts.map +1 -1
  686. package/daemon/dist/domain/workflow-types.js.map +1 -1
  687. package/daemon/dist/domain/workspace/default-workspace-scaffold.d.ts +7 -1
  688. package/daemon/dist/domain/workspace/default-workspace-scaffold.d.ts.map +1 -1
  689. package/daemon/dist/domain/workspace/default-workspace-scaffold.js +35 -7
  690. package/daemon/dist/domain/workspace/default-workspace-scaffold.js.map +1 -1
  691. package/daemon/dist/gateway-slack-surface.d.ts +2 -2
  692. package/daemon/dist/gateway-slack-surface.d.ts.map +1 -1
  693. package/daemon/dist/gateway-slack-surface.js +1 -1
  694. package/daemon/dist/gateway-slack-surface.js.map +1 -1
  695. package/daemon/dist/index.d.ts.map +1 -1
  696. package/daemon/dist/index.js +17 -2
  697. package/daemon/dist/index.js.map +1 -1
  698. package/daemon/dist/lib/pane-envelope.d.ts +3 -0
  699. package/daemon/dist/lib/pane-envelope.d.ts.map +1 -1
  700. package/daemon/dist/lib/pane-envelope.js +3 -1
  701. package/daemon/dist/lib/pane-envelope.js.map +1 -1
  702. package/daemon/dist/mission-parent-surface.d.ts +2 -0
  703. package/daemon/dist/mission-parent-surface.d.ts.map +1 -0
  704. package/daemon/dist/mission-parent-surface.js +2 -0
  705. package/daemon/dist/mission-parent-surface.js.map +1 -0
  706. package/daemon/dist/routes/activity.d.ts +18 -1
  707. package/daemon/dist/routes/activity.d.ts.map +1 -1
  708. package/daemon/dist/routes/activity.js +150 -9
  709. package/daemon/dist/routes/activity.js.map +1 -1
  710. package/daemon/dist/routes/agent-images.d.ts.map +1 -1
  711. package/daemon/dist/routes/agent-images.js +6 -1
  712. package/daemon/dist/routes/agent-images.js.map +1 -1
  713. package/daemon/dist/routes/attention.d.ts.map +1 -1
  714. package/daemon/dist/routes/attention.js +194 -176
  715. package/daemon/dist/routes/attention.js.map +1 -1
  716. package/daemon/dist/routes/compaction.d.ts.map +1 -1
  717. package/daemon/dist/routes/compaction.js +46 -7
  718. package/daemon/dist/routes/compaction.js.map +1 -1
  719. package/daemon/dist/routes/core-app.d.ts +10 -0
  720. package/daemon/dist/routes/core-app.d.ts.map +1 -0
  721. package/daemon/dist/routes/core-app.js +175 -0
  722. package/daemon/dist/routes/core-app.js.map +1 -0
  723. package/daemon/dist/routes/hook-bridge.d.ts +3 -0
  724. package/daemon/dist/routes/hook-bridge.d.ts.map +1 -0
  725. package/daemon/dist/routes/hook-bridge.js +158 -0
  726. package/daemon/dist/routes/hook-bridge.js.map +1 -0
  727. package/daemon/dist/routes/missions.d.ts.map +1 -1
  728. package/daemon/dist/routes/missions.js +14 -2
  729. package/daemon/dist/routes/missions.js.map +1 -1
  730. package/daemon/dist/routes/queue.d.ts +4 -1
  731. package/daemon/dist/routes/queue.d.ts.map +1 -1
  732. package/daemon/dist/routes/queue.js +239 -38
  733. package/daemon/dist/routes/queue.js.map +1 -1
  734. package/daemon/dist/routes/require-sender-identity.d.ts +4 -3
  735. package/daemon/dist/routes/require-sender-identity.d.ts.map +1 -1
  736. package/daemon/dist/routes/require-sender-identity.js.map +1 -1
  737. package/daemon/dist/routes/restore-check.d.ts.map +1 -1
  738. package/daemon/dist/routes/restore-check.js +1 -0
  739. package/daemon/dist/routes/restore-check.js.map +1 -1
  740. package/daemon/dist/routes/rigspec.d.ts.map +1 -1
  741. package/daemon/dist/routes/rigspec.js +24 -4
  742. package/daemon/dist/routes/rigspec.js.map +1 -1
  743. package/daemon/dist/routes/scope-audit.d.ts.map +1 -1
  744. package/daemon/dist/routes/scope-audit.js +7 -1
  745. package/daemon/dist/routes/scope-audit.js.map +1 -1
  746. package/daemon/dist/routes/seat.d.ts.map +1 -1
  747. package/daemon/dist/routes/seat.js +133 -6
  748. package/daemon/dist/routes/seat.js.map +1 -1
  749. package/daemon/dist/routes/sessions.js +14 -3
  750. package/daemon/dist/routes/sessions.js.map +1 -1
  751. package/daemon/dist/routes/slices.d.ts.map +1 -1
  752. package/daemon/dist/routes/slices.js +21 -2
  753. package/daemon/dist/routes/slices.js.map +1 -1
  754. package/daemon/dist/routes/startup.js +9 -2
  755. package/daemon/dist/routes/startup.js.map +1 -1
  756. package/daemon/dist/routes/terminal.d.ts.map +1 -1
  757. package/daemon/dist/routes/terminal.js +47 -6
  758. package/daemon/dist/routes/terminal.js.map +1 -1
  759. package/daemon/dist/routes/transcripts.d.ts.map +1 -1
  760. package/daemon/dist/routes/transcripts.js +16 -1
  761. package/daemon/dist/routes/transcripts.js.map +1 -1
  762. package/daemon/dist/routes/up.d.ts.map +1 -1
  763. package/daemon/dist/routes/up.js +14 -4
  764. package/daemon/dist/routes/up.js.map +1 -1
  765. package/daemon/dist/routes/watchdog.d.ts.map +1 -1
  766. package/daemon/dist/routes/watchdog.js +21 -3
  767. package/daemon/dist/routes/watchdog.js.map +1 -1
  768. package/daemon/dist/routes/workflow.d.ts.map +1 -1
  769. package/daemon/dist/routes/workflow.js +5 -0
  770. package/daemon/dist/routes/workflow.js.map +1 -1
  771. package/daemon/dist/server.d.ts +5 -0
  772. package/daemon/dist/server.d.ts.map +1 -1
  773. package/daemon/dist/server.js +22 -0
  774. package/daemon/dist/server.js.map +1 -1
  775. package/daemon/dist/startup.d.ts.map +1 -1
  776. package/daemon/dist/startup.js +140 -48
  777. package/daemon/dist/startup.js.map +1 -1
  778. package/daemon/dist/terminal-viewer-guard-surface.d.ts +2 -0
  779. package/daemon/dist/terminal-viewer-guard-surface.d.ts.map +1 -0
  780. package/daemon/dist/terminal-viewer-guard-surface.js +2 -0
  781. package/daemon/dist/terminal-viewer-guard-surface.js.map +1 -0
  782. package/daemon/docs/reference/agent-startup-guide.md +5 -1
  783. package/daemon/docs/reference/claude-status-line.md +3 -2
  784. package/daemon/docs/reference/community-harness-examples/cursor/openrig-cursor-launch +6 -0
  785. package/daemon/docs/reference/community-harness-examples/dsh/README.md +8 -0
  786. package/daemon/docs/reference/community-harness-examples/dsh/openrig-dsh-runner.mjs +310 -20
  787. package/daemon/docs/reference/community-harness-examples/hermes/openrig-hermes-launch +6 -0
  788. package/daemon/docs/reference/community-harness-examples/openclaw/openrig-openclaw-launch +6 -0
  789. package/daemon/docs/reference/community-harness-examples/openshell/README.md +2 -0
  790. package/daemon/docs/reference/community-harness-examples/pi-tui/openrig-pi-tui-launch +6 -0
  791. package/daemon/docs/reference/community-harness-presets.md +7 -4
  792. package/daemon/docs/reference/core-app.md +212 -0
  793. package/daemon/docs/reference/daemon-http-clients.md +67 -12
  794. package/daemon/docs/reference/getting-started.md +9 -4
  795. package/daemon/docs/reference/harness-runner-contract.md +140 -4
  796. package/daemon/docs/reference/herdr-app.md +6 -0
  797. package/daemon/docs/reference/hosted-members.md +21 -1
  798. package/daemon/docs/reference/quickstart.md +4 -3
  799. package/daemon/docs/reference/rig-spec.md +197 -1
  800. package/daemon/docs/reference/rosters.md +17 -0
  801. package/daemon/docs/reference/sdlc-conventions.md +47 -6
  802. package/daemon/docs/reference/seat-delivery.md +87 -6
  803. package/daemon/docs/reference/slack-app-setup.md +39 -21
  804. package/daemon/docs/reference/terminal-sessions.md +99 -1
  805. package/daemon/docs/reference/whats-new.md +187 -15
  806. package/daemon/specs/agents/shared/skills/core/messaging-the-human/SKILL.md +23 -0
  807. package/daemon/specs/rigs/launch/factory/guidance/lead-first-move.md +27 -5
  808. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +32 -8
  809. package/daemon/specs/rigs/launch/kernel/agents/operator/agent/startup/context.md +1 -1
  810. package/daemon/specs/rigs/launch/kernel/culture/CULTURE.md +12 -0
  811. package/daemon/specs/rigs/launch/starter/guidance/lead-first-move.md +27 -5
  812. package/dist/acp/connector.js +1 -1
  813. package/dist/acp/connector.js.map +1 -1
  814. package/dist/ask-wake.d.ts.map +1 -1
  815. package/dist/ask-wake.js +8 -1
  816. package/dist/ask-wake.js.map +1 -1
  817. package/dist/build-info.js +3 -3
  818. package/dist/cli-error.d.ts.map +1 -1
  819. package/dist/cli-error.js +7 -1
  820. package/dist/cli-error.js.map +1 -1
  821. package/dist/client.d.ts +2 -1
  822. package/dist/client.d.ts.map +1 -1
  823. package/dist/client.js +3 -2
  824. package/dist/client.js.map +1 -1
  825. package/dist/commands/archive.js +1 -1
  826. package/dist/commands/archive.js.map +1 -1
  827. package/dist/commands/ask.d.ts.map +1 -1
  828. package/dist/commands/ask.js +92 -11
  829. package/dist/commands/ask.js.map +1 -1
  830. package/dist/commands/broadcast.js +9 -5
  831. package/dist/commands/broadcast.js.map +1 -1
  832. package/dist/commands/compact.d.ts +3 -4
  833. package/dist/commands/compact.d.ts.map +1 -1
  834. package/dist/commands/compact.js +76 -16
  835. package/dist/commands/compact.js.map +1 -1
  836. package/dist/commands/config-init-workspace.d.ts.map +1 -1
  837. package/dist/commands/config-init-workspace.js +3 -0
  838. package/dist/commands/config-init-workspace.js.map +1 -1
  839. package/dist/commands/daemon.d.ts.map +1 -1
  840. package/dist/commands/daemon.js +7 -0
  841. package/dist/commands/daemon.js.map +1 -1
  842. package/dist/commands/down.d.ts.map +1 -1
  843. package/dist/commands/down.js +8 -1
  844. package/dist/commands/down.js.map +1 -1
  845. package/dist/commands/export.d.ts.map +1 -1
  846. package/dist/commands/export.js +2 -1
  847. package/dist/commands/export.js.map +1 -1
  848. package/dist/commands/fork.d.ts.map +1 -1
  849. package/dist/commands/fork.js +2 -0
  850. package/dist/commands/fork.js.map +1 -1
  851. package/dist/commands/launch.d.ts.map +1 -1
  852. package/dist/commands/launch.js +11 -3
  853. package/dist/commands/launch.js.map +1 -1
  854. package/dist/commands/ps.d.ts +30 -1
  855. package/dist/commands/ps.d.ts.map +1 -1
  856. package/dist/commands/ps.js +85 -6
  857. package/dist/commands/ps.js.map +1 -1
  858. package/dist/commands/queue.d.ts.map +1 -1
  859. package/dist/commands/queue.js +309 -21
  860. package/dist/commands/queue.js.map +1 -1
  861. package/dist/commands/rig.d.ts +2 -0
  862. package/dist/commands/rig.d.ts.map +1 -1
  863. package/dist/commands/rig.js +36 -2
  864. package/dist/commands/rig.js.map +1 -1
  865. package/dist/commands/roster.d.ts +8 -0
  866. package/dist/commands/roster.d.ts.map +1 -1
  867. package/dist/commands/scope.d.ts.map +1 -1
  868. package/dist/commands/scope.js +346 -9
  869. package/dist/commands/scope.js.map +1 -1
  870. package/dist/commands/seat.d.ts.map +1 -1
  871. package/dist/commands/seat.js +213 -12
  872. package/dist/commands/seat.js.map +1 -1
  873. package/dist/commands/send.d.ts +2 -0
  874. package/dist/commands/send.d.ts.map +1 -1
  875. package/dist/commands/send.js +50 -7
  876. package/dist/commands/send.js.map +1 -1
  877. package/dist/commands/setup.js +2 -2
  878. package/dist/commands/setup.js.map +1 -1
  879. package/dist/commands/slack.d.ts +2 -1
  880. package/dist/commands/slack.d.ts.map +1 -1
  881. package/dist/commands/slack.js +38 -2
  882. package/dist/commands/slack.js.map +1 -1
  883. package/dist/commands/terminal.d.ts +56 -0
  884. package/dist/commands/terminal.d.ts.map +1 -1
  885. package/dist/commands/terminal.js +199 -9
  886. package/dist/commands/terminal.js.map +1 -1
  887. package/dist/commands/transcript.js +1 -1
  888. package/dist/commands/transcript.js.map +1 -1
  889. package/dist/commands/unarchive.js +1 -1
  890. package/dist/commands/unarchive.js.map +1 -1
  891. package/dist/commands/up.d.ts.map +1 -1
  892. package/dist/commands/up.js +3 -0
  893. package/dist/commands/up.js.map +1 -1
  894. package/dist/commands/workflow-follow.d.ts +3 -1
  895. package/dist/commands/workflow-follow.d.ts.map +1 -1
  896. package/dist/commands/workflow-follow.js +25 -6
  897. package/dist/commands/workflow-follow.js.map +1 -1
  898. package/dist/commands/workflow-render.d.ts.map +1 -1
  899. package/dist/commands/workflow-render.js +5 -1
  900. package/dist/commands/workflow-render.js.map +1 -1
  901. package/dist/commands/workflow.d.ts.map +1 -1
  902. package/dist/commands/workflow.js +18 -4
  903. package/dist/commands/workflow.js.map +1 -1
  904. package/dist/daemon-lifecycle.d.ts.map +1 -1
  905. package/dist/daemon-lifecycle.js +12 -0
  906. package/dist/daemon-lifecycle.js.map +1 -1
  907. package/dist/lib/model-observation.d.ts.map +1 -1
  908. package/dist/lib/model-observation.js +9 -3
  909. package/dist/lib/model-observation.js.map +1 -1
  910. package/dist/lib/scope/mission-composition.d.ts +1 -0
  911. package/dist/lib/scope/mission-composition.d.ts.map +1 -1
  912. package/dist/lib/scope/mission-composition.js +14 -0
  913. package/dist/lib/scope/mission-composition.js.map +1 -1
  914. package/dist/lib/scope/scope-audit.d.ts.map +1 -1
  915. package/dist/lib/scope/scope-audit.js +63 -3
  916. package/dist/lib/scope/scope-audit.js.map +1 -1
  917. package/dist/lib/scope/scope-fs.d.ts +10 -0
  918. package/dist/lib/scope/scope-fs.d.ts.map +1 -1
  919. package/dist/lib/scope/scope-fs.js +60 -0
  920. package/dist/lib/scope/scope-fs.js.map +1 -1
  921. package/dist/lib/scope/types.d.ts +3 -1
  922. package/dist/lib/scope/types.d.ts.map +1 -1
  923. package/dist/lib/scope/types.js +5 -1
  924. package/dist/lib/scope/types.js.map +1 -1
  925. package/dist/local-db.d.ts +5 -0
  926. package/dist/local-db.d.ts.map +1 -0
  927. package/dist/local-db.js +23 -0
  928. package/dist/local-db.js.map +1 -0
  929. package/dist/local-origin.d.ts.map +1 -1
  930. package/dist/local-origin.js +2 -17
  931. package/dist/local-origin.js.map +1 -1
  932. package/dist/mcp-server.d.ts.map +1 -1
  933. package/dist/mcp-server.js +138 -24
  934. package/dist/mcp-server.js.map +1 -1
  935. package/dist/restore-packet/packet-writer.d.ts.map +1 -1
  936. package/dist/restore-packet/packet-writer.js +8 -5
  937. package/dist/restore-packet/packet-writer.js.map +1 -1
  938. package/dist/sender-identity.d.ts +18 -6
  939. package/dist/sender-identity.d.ts.map +1 -1
  940. package/dist/sender-identity.js +67 -7
  941. package/dist/sender-identity.js.map +1 -1
  942. package/dist/terminal-window-rex.d.ts +1 -1
  943. package/dist/terminal-window-rex.d.ts.map +1 -1
  944. package/dist/terminal-window-rex.js +3 -2
  945. package/dist/terminal-window-rex.js.map +1 -1
  946. package/dist/terminal-window.d.ts +2 -1
  947. package/dist/terminal-window.d.ts.map +1 -1
  948. package/dist/terminal-window.js +570 -44
  949. package/dist/terminal-window.js.map +1 -1
  950. package/package.json +1 -1
  951. package/tui/dist/daemon-client.d.ts +4 -0
  952. package/tui/dist/daemon-client.d.ts.map +1 -1
  953. package/tui/dist/daemon-client.js +2 -1
  954. package/tui/dist/daemon-client.js.map +1 -1
  955. package/tui/dist/execution/execution-model.d.ts.map +1 -1
  956. package/tui/dist/execution/execution-model.js +22 -5
  957. package/tui/dist/execution/execution-model.js.map +1 -1
  958. package/tui/dist/hydrate.d.ts.map +1 -1
  959. package/tui/dist/hydrate.js +6 -3
  960. package/tui/dist/hydrate.js.map +1 -1
  961. package/tui/dist/navigator.d.ts +1 -1
  962. package/tui/dist/navigator.d.ts.map +1 -1
  963. package/tui/dist/navigator.js +4 -2
  964. package/tui/dist/navigator.js.map +1 -1
  965. package/tui/dist/pulse/render-pulse.d.ts.map +1 -1
  966. package/tui/dist/pulse/render-pulse.js +7 -14
  967. package/tui/dist/pulse/render-pulse.js.map +1 -1
  968. package/tui/dist/render.d.ts.map +1 -1
  969. package/tui/dist/render.js +29 -21
  970. package/tui/dist/render.js.map +1 -1
  971. package/tui/dist/stylize.d.ts.map +1 -1
  972. package/tui/dist/stylize.js +3 -3
  973. package/tui/dist/stylize.js.map +1 -1
  974. package/tui/dist/terminals/terminal-model.d.ts +1 -0
  975. package/tui/dist/terminals/terminal-model.d.ts.map +1 -1
  976. package/tui/dist/terminals/terminal-model.js +4 -2
  977. package/tui/dist/terminals/terminal-model.js.map +1 -1
  978. package/tui/dist/types.d.ts +1 -0
  979. package/tui/dist/types.d.ts.map +1 -1
  980. package/tui/dist/visual-layout.d.ts +3 -0
  981. package/tui/dist/visual-layout.d.ts.map +1 -1
  982. package/tui/dist/visual-layout.js +17 -0
  983. package/tui/dist/visual-layout.js.map +1 -1
  984. package/ui/dist/assets/{index-BvUEh33d.js → index-B-sMy02c.js} +116 -116
  985. package/ui/dist/assets/{index-BX8TUZ0E.css → index-DiN7RwWg.css} +1 -1
  986. package/ui/dist/index.html +2 -2
@@ -1,10 +1,12 @@
1
1
  import { DeliveryGuardError } from "../domain/seat-delivery-guard.js";
2
- import { writeFile as fsWriteFile, unlink as fsUnlink } from "node:fs/promises";
2
+ import { writeFile as fsWriteFile, unlink as fsUnlink, readFile as fsReadFile } from "node:fs/promises";
3
+ import { accessSync, statSync, constants as fsConstants } from "node:fs";
3
4
  import { tmpdir } from "node:os";
4
- import { join as pathJoin } from "node:path";
5
+ import { join as pathJoin, isAbsolute as pathIsAbsolute } from "node:path";
5
6
  import { randomUUID } from "node:crypto";
6
7
  import { inspectComposerInput } from "../domain/session-transport.js";
7
8
  import { parentSessionEnvKeys, removeParentSessionEnv } from "../domain/parent-session-env.js";
9
+ import { isTmuxCredentialEnvKey } from "./tmux-credential-env.js";
8
10
  import { addSeatRuntimeDir, seatRuntimeDir } from "../domain/seat-runtime-dir.js";
9
11
  import { tmuxOnDaemonServer } from "./tmux-server.js";
10
12
  import { TMUX_SERVER_LIMIT_PREFIX } from "../tmux-server-start.js";
@@ -33,6 +35,13 @@ export function defaultTmuxFileOps() {
33
35
  bufferName: () => `openrig_${process.pid}_${randomUUID().replace(/-/g, "")}`,
34
36
  };
35
37
  }
38
+ /** How a capped launch sees its seat's scope start: the pane's process is in the seat scope and its command started
39
+ * there (started), or the pane died first, before the command started (systemd-run could not make the scope, also
40
+ * late, after the check passed) or after it (the command ran inside the scope and ended). It looks for longer than
41
+ * systemd-run's own call to the user manager may take (D-Bus's default 25 s timeout), so a late answer either way is
42
+ * seen. */
43
+ const SEAT_SCOPE_START_CHECK_MS = 250;
44
+ const SEAT_SCOPE_START_CHECKS = 120;
36
45
  /** Positive server absence in this adapter's namespace; match the diagnostic line, never a path or command fragment. */
37
46
  export function probeShowsNoServer(probe) {
38
47
  return probe.state === "transport_unavailable" && /^no server running on /.test(tmuxDiagnosticStart(probe.cause ?? ""));
@@ -206,6 +215,11 @@ function execStderrText(error) {
206
215
  const NO_EXPAND_ENVIRONMENT = /(?:unrecognized|unknown) option[^\n]*--expand-environment/i;
207
216
  /** The user manager's refusal of OOMPolicy= for a scope (before 253), read from systemd-run's stderr only. */
208
217
  const NO_OOM_POLICY = /Cannot set property OOMPolicy|Unknown (?:property|assignment)[^\n]*OOMPolicy/i;
218
+ /** systemd-run's or the user manager's refusal of MemoryMax= for a scope, read from systemd-run's stderr only. */
219
+ const NO_MEMORY_MAX = /Unknown (?:property|assignment)[^\n]*MemoryMax|Failed to parse MemoryMax/i;
220
+ /** A systemd too old for a seat scope: systemctl without --value (before 230) or systemd-run without --collect (before
221
+ * 236), read from their stderr only. */
222
+ const SYSTEMD_TOO_OLD = /(?:unrecognized|unknown) option[^\n]*--(?:value|collect)\b/i;
209
223
  /** What a failed exec said, on one line: its stderr when it kept one apart, else its message past the command. */
210
224
  function execFailureReason(error) {
211
225
  const e = error;
@@ -292,24 +306,725 @@ function usableEnvLine(lines, name) {
292
306
  const prefix = `${name}=`;
293
307
  return lines.some((line) => line.startsWith(prefix) && line.slice(prefix.length).trim().length > 0);
294
308
  }
309
+ /** A fresh launch that asks for a limit it can't get: it is not started, and says why (#3253: never an unlimited start
310
+ * that claims success). */
311
+ export class SeatProcessLimitsNotApplied extends Error {
312
+ problem;
313
+ constructor(problem) {
314
+ super(`process_limits is set for this seat, but ${problemText(problem)}; the seat was not started` +
315
+ (problem.kind === "unverified" ? " (this may be temporary: retry the launch)" : "") + ".");
316
+ this.problem = problem;
317
+ }
318
+ }
319
+ /** One line for a problem, with the age of a cached observation. */
320
+ export function problemText(problem) {
321
+ const what = problem.kind === "invalid" ? "its stored value can't be read"
322
+ : problem.kind === "unsupported" ? "this host can't give the seat its own scope"
323
+ : problem.kind === "setup" ? "this setup can't give the seat its own scope"
324
+ : "whether this host can give the seat its own scope is unverified";
325
+ const age = problem.ageSeconds !== undefined ? `, observed ${problem.ageSeconds}s ago` : "";
326
+ return `${what} (${problem.reason}${age})`;
327
+ }
328
+ /** The structured warning of a recovery that went ahead without the limit. */
329
+ export function notAppliedNotice(problem) {
330
+ return { state: "not_applied", ...problem, retryable: problem.kind === "unverified" };
331
+ }
332
+ /** The structured warning of a recovery that can't tell whether the seat's process is under the limit. */
333
+ export function unknownNotice(problem) {
334
+ return { state: "unknown", ...problem, retryable: problem.kind === "unverified" };
335
+ }
336
+ /** The human line of that warning. */
337
+ export function noticeLine(notice) {
338
+ if (notice.state === "unknown") {
339
+ const age = notice.ageSeconds !== undefined ? `, observed ${notice.ageSeconds}s ago` : "";
340
+ return `process_limits requested; whether the seat runs under the limit is unknown (${notice.reason}${age}); the ` +
341
+ "request stays stored (a fresh launch applies it)";
342
+ }
343
+ return `process_limits requested, not applied: ${problemText(notice)}; the seat went on without the limit, and the ` +
344
+ "request stays stored (a fresh launch applies it)";
345
+ }
346
+ /** The slice a seat scope goes in: seats with process limits leave the terminal server's scope (and any limit an
347
+ * operator put on it) for this slice. No dash: systemd reads a dash in a slice name as nesting, which would put the
348
+ * seats under `openrig.slice` and any limit on it. */
349
+ export const SEAT_SCOPE_SLICE = "openrigseats.slice";
350
+ /** Why a seat with a limit can't start with the inherited tmux environment, with the way out. */
351
+ const INHERIT_TMUX_ENVIRONMENT_REASON = "terminal.inherit_tmux_environment is on: a seat with a limit needs the scoped " +
352
+ "launch environment (set terminal.inherit_tmux_environment to false)";
353
+ /** How long a launch skips asking again after a failed check (it reads as `unverified`, with the observation's age). */
354
+ const SEAT_SCOPE_RETRY_MS = 60_000;
355
+ /** systemd-run reaches the user manager through the runtime directory, not the seat's session bus (which the launch
356
+ * environment turns off on purpose). The command after `--` restores the seat's exact environment (env -i + export). */
357
+ function seatScopeBusEnv(runtimeDir) {
358
+ return ["/usr/bin/env", "-u", "DBUS_SESSION_BUS_ADDRESS", `XDG_RUNTIME_DIR=${runtimeDir}`];
359
+ }
360
+ /** `/usr/bin/env` that gives the command these values back: every `-u` (an unset value) before any assignment, since env
361
+ * reads the first word after an assignment as the command. */
362
+ export function restoreEnvArgv(values) {
363
+ const entries = Object.entries(values);
364
+ return ["/usr/bin/env", ...entries.filter(([, v]) => v === undefined).flatMap(([k]) => ["-u", k]),
365
+ ...entries.filter(([, v]) => v !== undefined).map(([k, v]) => `${k}=${v}`)];
366
+ }
367
+ /** The systemd-run options of a seat scope, up to (not including) the `--` before the command. `systemdRun` is the
368
+ * absolute path the check resolved, so the check and the launch run the same binary whatever PATH the seat has. */
369
+ function seatScopeArgv(opts, unit, description, limits, systemdRun) {
370
+ return [systemdRun, "--user", "--scope", "--quiet", "--collect", "--slice", SEAT_SCOPE_SLICE, "--unit", unit,
371
+ "--description", description,
372
+ // As for the server's scope: the command's arguments must reach /bin/sh exactly as written (254+).
373
+ ...(opts.literal ? ["--expand-environment=no"] : []),
374
+ // As for the server's scope: one OOM kill must not stop every process of the seat (253+).
375
+ ...(opts.oomPolicy ? ["-p", "OOMPolicy=continue"] : []),
376
+ ...(limits.tasksMax !== undefined ? ["-p", `TasksMax=${limits.tasksMax}`] : []),
377
+ // Bytes, as memory.max reads back: the probe and the status compare the two as written.
378
+ ...(limits.memoryMax !== undefined ? ["-p", `MemoryMax=${limits.memoryMax}`] : [])];
379
+ }
380
+ /** The command that runs first inside a seat scope: it empties the launch's marker file (a builtin and a redirection, no
381
+ * fork, so it works under TasksMax=1), then execs the seat's command. A pane that died with the marker still pending
382
+ * never started the seat's command; one that died with it empty did. */
383
+ function scopeMarkArgv(marker) {
384
+ return ["/bin/sh", "-c", ': > "$0" && exec "$@"', marker];
385
+ }
386
+ const SCOPE_MARKER_PENDING = "pending\n";
387
+ /** The launch result of a fresh seat launch whose limit can't be applied. */
388
+ function processLimitsNotAppliedResult(error, left) {
389
+ // What was observed about the command and what became of its terminal are said apart: a refusal whose command
390
+ // started (or may have) is not "not started", and one whose terminal may still be running has an unknown outcome.
391
+ // Either way a blind retry could repeat the command or start a second one beside it, so none is suggested.
392
+ const started = error.problem.commandStarted;
393
+ const problem = left ? { ...error.problem, possiblyRunning: true } : error.problem;
394
+ let message = error.message;
395
+ if (started || left) {
396
+ message = `process_limits is set for this seat, but ${problemText(error.problem)}; the launch was refused`;
397
+ if (started)
398
+ message += `, after its command ${started === true ? "started" : "may have started"} in the seat's scope`;
399
+ message += left
400
+ ? `, and whether its terminal is running is unknown. ${left} Stop it before launching this seat again.`
401
+ : "; its terminal was removed. Check what the command did before launching this seat again.";
402
+ }
403
+ console.warn(`[seat launch] ${message}`);
404
+ return { ok: false, code: `process_limits_${error.problem.kind}`, message,
405
+ retryable: !left && !started && error.problem.kind === "unverified", processLimits: problem };
406
+ }
407
+ /** What a capped launch's new-session prints: its pane, its session's immutable id and its server (pid, start time). */
408
+ const CREATED_IDENTITY_FORMAT = "#{pane_id} #{session_id} #{pid} #{start_time}";
409
+ /** The identity a capped new-session printed, or null when it printed something else (or nothing). */
410
+ function createdIdentity(printed) {
411
+ const m = /^(%\d+) (\$\d+) (\d+) (\d+)$/.exec(printed);
412
+ return m ? { pane: m[1], session: m[2], server: { pid: m[3], start: m[4] } } : null;
413
+ }
414
+ /** A command that ended by SIGKILL: the signal itself (the shell replaced by the command) or 137 (128 + 9, from a shell
415
+ * that ran it, or from timeout, which exits that way when the command it ran was killed). */
416
+ function killedBySigkill(error) {
417
+ const e = error;
418
+ return e.signal === "SIGKILL" || e.code === 137;
419
+ }
420
+ /** A check's failure, classified (#3253): `unsupported` only on a positive answer that the facility is not there. */
421
+ function classifyScopeFailure(error, what) {
422
+ const reason = execFailureReason(error);
423
+ const code = error.code;
424
+ if (code === 124)
425
+ return { kind: "unverified", reason: `${what} timed out` };
426
+ // systemd's own refusal of an option it predates, read from its stderr only.
427
+ if (SYSTEMD_TOO_OLD.test(execStderrText(error))) {
428
+ return { kind: "unsupported", reason: `${what}: systemd is too old for seat scopes (it needs 236+ for --collect, 230+ for --value): ${reason}` };
429
+ }
430
+ if (NO_MEMORY_MAX.test(execStderrText(error))) {
431
+ return { kind: "unsupported", limit: "memory_max", reason: `${what}: systemd refused MemoryMax= for the seat's scope: ${reason}` };
432
+ }
433
+ // Only a message that names the tool: an exit status of 127 alone does not say which program was missing.
434
+ if (/(?:systemd-run|systemctl)\S{0,2}: (?:(?:command )?not found|No such file or directory)|No such file or directory[^\n]*(?:systemd-run|systemctl)/i.test(reason)) {
435
+ return { kind: "unsupported", reason: `${what}: systemd-run or systemctl is not installed (${reason})` };
436
+ }
437
+ // No socket at all: no user manager runs for this user (no session and no lingering), a positive answer.
438
+ if (/Failed to connect to (?:user scope )?bus(?: via local transport)?: (?:No such file or directory|No medium found)/i.test(reason)) {
439
+ return { kind: "unsupported", reason: `${what}: no systemd user manager is running for this user (${reason})` };
440
+ }
441
+ // A socket that refuses: a user manager starting or restarting, not known either way.
442
+ if (/Failed to connect to [^:\n]*bus[^:\n]*: Connection refused/i.test(reason)) {
443
+ return { kind: "unverified", reason: `${what}: the user manager's bus refused the connection (starting or restarting?): ${reason}` };
444
+ }
445
+ return { kind: "unverified", reason: `${what} failed: ${reason}` };
446
+ }
447
+ /** What a throwaway scope with memory_max printed (proveSeatScope), checked limit by limit against the request: null
448
+ * when each requested limit reads back as its value, else the first that doesn't, named. */
449
+ /** A host with no cgroup v2 for the user manager's scopes: no limit can be made, whatever is asked. */
450
+ const NO_CGROUP2 = "the user manager's scopes have no cgroup v2 path (a cgroup v1 host)";
451
+ /** The limits a positive inability is about: the one a probe's answer names; from the tasks-only probe, whose answers
452
+ * name none, the task limit when it is about the pids controller; any other (no cgroup v2, no systemd tools or user
453
+ * manager, a systemd too old) is about the host, so about every limit. */
454
+ function inabilityLimits(problem, probed) {
455
+ if (problem.limit)
456
+ return [problem.limit];
457
+ if (probed.memoryMax === undefined && problem.reason !== NO_CGROUP2 && /\bpids\b/.test(problem.reason)) {
458
+ return ["tasks_max"];
459
+ }
460
+ return ["tasks_max", "memory_max"];
461
+ }
462
+ function scopeProbeProblem(got, limits) {
463
+ if (got === "nocgroup2")
464
+ return { kind: "unsupported", reason: NO_CGROUP2 };
465
+ const read = new Map();
466
+ for (const line of got.split("\n")) {
467
+ const m = /^(memory|pids) (.*)$/.exec(line.trim());
468
+ if (m)
469
+ read.set(m[1], m[2]);
470
+ }
471
+ const asked = [
472
+ ["memory_max", "memory", "MemoryMax", limits.memoryMax], ["tasks_max", "pids", "TasksMax", limits.tasksMax]
473
+ ];
474
+ for (const [limit, controller, property, value] of asked) {
475
+ if (value === undefined)
476
+ continue;
477
+ const file = `${controller}.max`;
478
+ const seen = read.get(controller);
479
+ if (seen === undefined)
480
+ return { kind: "unverified", limit, reason: `a throwaway seat scope read no ${file}` };
481
+ if (seen === `no${controller}`) {
482
+ return { kind: "unsupported", limit, reason: `a throwaway seat scope has no ${file}: the ${controller} controller is not delegated to the user manager` };
483
+ }
484
+ // Only a readable limit that isn't the one asked for is a positive answer; anything else can't be read.
485
+ if (!/^(\d+|max)$/.test(seen)) {
486
+ return { kind: "unverified", limit, reason: `a throwaway seat scope's ${file} read could not be understood ("${seen.slice(0, 80)}")` };
487
+ }
488
+ if (seen !== String(value)) {
489
+ return { kind: "unsupported", limit,
490
+ reason: `a throwaway seat scope got ${file} "${seen}" for ${property}=${value}: the ${controller} limit is not enforced here (is the ${controller} controller delegated to the user manager?)` };
491
+ }
492
+ }
493
+ return null;
494
+ }
495
+ /** The cgroup v2 path of a process, from the `0::` line of /proc/<pid>/cgroup; null on cgroup v1 or no such line. */
496
+ export function cgroupV2Path(procCgroup) {
497
+ const line = procCgroup.split(/\r?\n/).find((l) => l.startsWith("0::"));
498
+ return line ? line.slice(3).trim() || null : null;
499
+ }
295
500
  export class TmuxAdapter {
296
501
  exec;
297
502
  fileOps;
298
503
  argvExec;
299
- /** Read for each new agent/successor. Unconfigured adapters retain legacy behavior. */
504
+ /** Read for each new agent/successor, once per launch. Unconfigured adapters retain legacy behavior. */
300
505
  launchEnvironment;
506
+ /** A seat's process limits by node id (rig spec `process_limits`, #3253), read at each launch. Absent, or undefined
507
+ * for a node: that seat launches exactly as before. It may throw for a malformed stored value: that seat's launch
508
+ * reads it as `invalid`, and no other seat is affected. */
509
+ seatProcessLimits;
510
+ /** Whether a seat runs in an environment guest (its harness is a local viewer of a guest's agent): a scope on this
511
+ * host would hold only the viewer, so a limit can't be applied (#3253). `session` is the seat's session name, for a
512
+ * placement not yet claimed by its node (before the seat's first launch). */
513
+ seatInEnvironmentGuest;
514
+ /** Reads /proc and /sys for the limit's readback, and a launch's scope marker; replaceable in tests. */
515
+ procRead = (path) => fsReadFile(path, "utf8");
516
+ /** An executable's absolute path from the daemon's PATH (absolute entries only), or null; replaceable in tests. */
517
+ resolveExecutable = (name) => {
518
+ for (const dir of (process.env.PATH ?? "").split(":")) {
519
+ if (!pathIsAbsolute(dir))
520
+ continue;
521
+ const candidate = pathJoin(dir, name);
522
+ try {
523
+ accessSync(candidate, fsConstants.X_OK);
524
+ return candidate;
525
+ }
526
+ catch { /* not here */ }
527
+ }
528
+ return null;
529
+ };
530
+ /** Whether a directory exists; replaceable in tests. */
531
+ dirExists = (path) => {
532
+ try {
533
+ return statSync(path).isDirectory();
534
+ }
535
+ catch {
536
+ return false;
537
+ }
538
+ };
539
+ /** systemd-run's options proven by a throwaway scope, per systemd-run binary and pair of limits (memoized on success
540
+ * only). */
541
+ seatScopeProven = new Map();
542
+ /** The last check that failed without a positive answer (a timeout, an empty probe, an error not recognized), and when,
543
+ * per step ("bus", or the probe of one tasks_max and memory_max pair): a launch within SEAT_SCOPE_RETRY_MS reads it
544
+ * as `unverified`, with its age, never as a fresh result; the first launch after that asks again. A positive answer is
545
+ * not cached: every launch asks again, so a setup fixed since is seen at once. */
546
+ seatScopeFailedAt = new Map();
547
+ /** The last positive inability, for the status only (as `unsupported`, with its age, for SEAT_SCOPE_RETRY_MS). */
548
+ seatScopeLastPositive;
549
+ /** A seat's limits, or the reason its stored value can't be read (kept local to this seat). */
550
+ seatLimitsLookup(nodeId) {
551
+ try {
552
+ const limits = this.seatProcessLimits?.(nodeId);
553
+ // A value with neither limit is no request (the stored value's parse refuses it anyway).
554
+ return limits && (limits.tasksMax !== undefined || limits.memoryMax !== undefined) ? { limits } : undefined;
555
+ }
556
+ catch (error) {
557
+ return { invalid: error.message };
558
+ }
559
+ }
560
+ /** Whether a seat has a process limits request (a malformed stored one included). */
561
+ seatProcessLimitsSet(nodeId) {
562
+ return this.seatLimitsLookup(nodeId) !== undefined;
563
+ }
564
+ /** The launch policy, read once by each launch or check: undefined when the daemon gives seats none, or what reading it
565
+ * threw. */
566
+ readLaunchPolicy() {
567
+ if (!this.launchEnvironment)
568
+ return undefined;
569
+ try {
570
+ return this.launchEnvironment();
571
+ }
572
+ catch (error) {
573
+ return error instanceof Error ? error : new Error(String(error));
574
+ }
575
+ }
576
+ /** For a seat with a limit, the structured warning of a recovery that keeps a running process whose readback is not
577
+ * `applied` (a restart in place that types into its shell), or null (no limit, or applied). Read only. */
578
+ async seatProcessLimitsNotApplied(nodeId, paneTarget) {
579
+ const lookup = this.seatLimitsLookup(nodeId);
580
+ if (!lookup)
581
+ return null;
582
+ if ("invalid" in lookup)
583
+ return notAppliedNotice({ kind: "invalid", reason: lookup.invalid });
584
+ const report = await this.readSeatProcessLimits(paneTarget, lookup.limits, nodeId);
585
+ if (report.state === "applied")
586
+ return null;
587
+ const requested = { ...lookup.limits };
588
+ // The restart keeps this process: a readback that failed can't say whether it is under the limit.
589
+ if (report.state === "unknown") {
590
+ return unknownNotice({ kind: "unverified", requested,
591
+ reason: `a restart in place keeps the running process, and whether it is under the limit can't be read back` +
592
+ `${report.reason ? `: ${report.reason}` : ""}` });
593
+ }
594
+ // Known not under the limit is the path's (a fresh launch applies it), and a host that can't make the scope is that.
595
+ return notAppliedNotice({ kind: report.state === "unsupported" ? "unsupported" : "setup",
596
+ reason: `a restart in place keeps the running process, and it is ${report.state === "not_applied" ? "not under the limit" : report.state}` +
597
+ `${report.reason ? `: ${report.reason}` : ""}; a fresh launch applies the limit`,
598
+ requested });
599
+ }
600
+ /** The path a recovery of this seat takes, chosen before anything is stopped (#3253): null when it gets its limit,
601
+ * or the warning it will go ahead with. A recovery never stops for a limit; the respawn it then runs in "recovery"
602
+ * mode never refuses for one either (a scope failure late in the path also ends in this warning). */
603
+ async seatProcessLimitsRecoveryPlan(nodeId) {
604
+ const lookup = this.seatLimitsLookup(nodeId);
605
+ if (!lookup)
606
+ return null;
607
+ if ("invalid" in lookup)
608
+ return notAppliedNotice({ kind: "invalid", reason: lookup.invalid });
609
+ const outcome = await this.seatScope(lookup.limits, { OPENRIG_NODE_ID: nodeId }, this.readLaunchPolicy());
610
+ return outcome.ok ? null : notAppliedNotice(outcome.problem);
611
+ }
612
+ /** For a restart in place that respawns a bare pane (no seat environment), chosen before anything is stopped (#3253):
613
+ * null when the seat has no limit; `keep` when its running process reads back as under the limit and a new scope can
614
+ * be made now (respawnPane with `keepLimitOf` then starts the command in one); otherwise the warning the restart goes
615
+ * ahead with. Read only, apart from the scope check. */
616
+ async seatProcessLimitsKeepPlan(nodeId, paneTarget) {
617
+ const lookup = this.seatLimitsLookup(nodeId);
618
+ if (!lookup)
619
+ return null;
620
+ if ("invalid" in lookup)
621
+ return { keep: false, notice: notAppliedNotice({ kind: "invalid", reason: lookup.invalid }) };
622
+ const requested = { ...lookup.limits };
623
+ const report = await this.readSeatProcessLimits(paneTarget, lookup.limits, nodeId);
624
+ if (report.state === "applied") {
625
+ const outcome = await this.seatScope(lookup.limits, { OPENRIG_NODE_ID: nodeId }, this.readLaunchPolicy());
626
+ if (outcome.ok)
627
+ return { keep: true };
628
+ return { keep: false, notice: notAppliedNotice({ ...outcome.problem,
629
+ reason: `the seat runs under its limit, but a restart in place respawns it in a new scope, and ${outcome.problem.reason}` }) };
630
+ }
631
+ // The respawned process is known not to be under the limit: only a limit read back as applied is kept.
632
+ const why = report.state === "unknown" ? "its limit can't be read back"
633
+ : report.state === "unsupported" ? "this host can't make the scope" : "it is not under the limit";
634
+ return { keep: false, notice: notAppliedNotice({
635
+ kind: report.state === "unsupported" ? "unsupported" : report.state === "unknown" ? "unverified" : "setup",
636
+ reason: `a restart in place respawns a bare pane and keeps only a limit that reads back as applied; ${why}` +
637
+ `${report.reason ? ` (${report.reason})` : ""}; a fresh launch applies it`,
638
+ requested
639
+ }) };
640
+ }
641
+ /** The user manager's runtime directory: XDG_RUNTIME_DIR when absolute, else /run/user/<uid> when it exists. */
642
+ scopeRuntimeDir() {
643
+ const own = seatRuntimeDir(process.env);
644
+ if (own !== undefined)
645
+ return own;
646
+ const uid = process.getuid?.();
647
+ if (uid === undefined)
648
+ return undefined;
649
+ const fallback = `/run/user/${uid}`;
650
+ return this.dirExists(fallback) ? fallback : undefined;
651
+ }
652
+ /** Why this host (`unsupported`) or this setup (`setup`) positively can't give a seat its own scope, read from the
653
+ * environment only, or null. Unlike the server's scope (userScopeUnavailable), a daemon that is not a systemd user
654
+ * service can still ask the user manager for a seat scope: MANAGERPID unset is no proof, the probe decides. */
655
+ seatScopeStaticProblem(policy, nodeId, session) {
656
+ if (nodeId && this.seatInEnvironmentGuest?.(nodeId, session)) {
657
+ return { kind: "setup", reason: "the seat runs in an environment guest; its processes are outside this host's scope" };
658
+ }
659
+ if (process.platform !== "linux")
660
+ return { kind: "unsupported", reason: "not Linux" };
661
+ if (this.scopeRuntimeDir() === undefined) {
662
+ return { kind: "setup", reason: `XDG_RUNTIME_DIR is unset and /run/user/${process.getuid?.() ?? "<uid>"} does not exist: ` +
663
+ "start the daemon with XDG_RUNTIME_DIR set, or as a systemd user service" };
664
+ }
665
+ if (policy instanceof Error)
666
+ return { kind: "unverified", reason: `the launch environment can't be read: ${policy.message}` };
667
+ if (!policy)
668
+ return { kind: "setup", reason: "this daemon gives seats no launch environment" };
669
+ if (policy.inheritTmuxEnvironment) {
670
+ // A seat scope is set up by systemd-run, which needs the user bus settings in its own environment; the scoped
671
+ // launch environment then rebuilds the seat's exact environment around it. With the inherited tmux environment
672
+ // there is no such rebuild, and the seat would start with systemd-run's bus settings instead of its own.
673
+ return { kind: "setup", reason: INHERIT_TMUX_ENVIRONMENT_REASON };
674
+ }
675
+ return null;
676
+ }
677
+ /** systemd-run, systemctl and timeout, resolved once from the daemon's PATH, or why they can't be. */
678
+ seatScopeTools() {
679
+ const systemdRun = this.resolveExecutable("systemd-run");
680
+ const systemctl = this.resolveExecutable("systemctl");
681
+ if (!systemdRun || !systemctl) {
682
+ return { problem: { kind: "unsupported",
683
+ reason: `${!systemdRun ? "systemd-run" : "systemctl"} is not in the daemon's PATH (${process.env.PATH ?? ""})` } };
684
+ }
685
+ const timeout = this.resolveExecutable("timeout");
686
+ if (!timeout) {
687
+ return { problem: { kind: "setup", reason: "coreutils' timeout is not in the daemon's PATH: install it, or start the " +
688
+ "daemon with a PATH that has it" } };
689
+ }
690
+ return { systemdRun, systemctl, timeout };
691
+ }
692
+ /** The prefix that starts a seat's pane command in a systemd user scope of its own with TasksMax and/or MemoryMax:
693
+ * the tmux server stays where it is, and only this seat's processes are under the limits (#3253). systemd-run
694
+ * registers itself in the new scope and then execs the command, so the pane's process is the seat's. Or why it
695
+ * can't, classified: never a silent start without the limit. */
696
+ async seatScope(limits, seatEnv, policy) {
697
+ const requested = { ...limits };
698
+ const fail = (problem) => ({ ok: false, problem: { ...problem, requested } });
699
+ const positive = (problem) => {
700
+ if (problem.kind === "unsupported")
701
+ this.seatScopeLastPositive = { at: Date.now(), problem, probed: limits };
702
+ return fail(problem);
703
+ };
704
+ const fixed = this.seatScopeStaticProblem(policy, seatEnv.OPENRIG_NODE_ID, seatEnv.OPENRIG_SESSION_NAME);
705
+ if (fixed)
706
+ return positive(fixed);
707
+ const tools = this.seatScopeTools();
708
+ if ("problem" in tools)
709
+ return positive(tools.problem);
710
+ const runtimeDir = this.scopeRuntimeDir();
711
+ // A systemd-run that changed since (another PATH, an upgrade) is proven again, and so is each pair of limits: a
712
+ // memory limit is never taken as proven by a scope that had only the task limit.
713
+ const provenKey = `${tools.systemdRun}\0${limits.tasksMax ?? "-"}\0${limits.memoryMax ?? "-"}`;
714
+ const probeKey = `probe:${provenKey}`;
715
+ for (const key of ["bus", probeKey]) {
716
+ const failed = this.seatScopeFailedAt.get(key);
717
+ if (failed && Date.now() - failed.at < SEAT_SCOPE_RETRY_MS && (key === "bus" || !this.seatScopeProven.has(provenKey))) {
718
+ return fail({ kind: "unverified", reason: `the last check failed: ${failed.problem.reason}`,
719
+ ageSeconds: Math.floor((Date.now() - failed.at) / 1000) });
720
+ }
721
+ }
722
+ // Only a failure that says nothing either way is cached; a positive one is asked again at the next launch.
723
+ const remember = (key, problem) => {
724
+ if (problem.kind === "unverified")
725
+ this.seatScopeFailedAt.set(key, { at: Date.now(), problem });
726
+ return positive(problem);
727
+ };
728
+ // The bus at this launch, not at the first one: a manager that went away since must not start the seat unlimited.
729
+ try {
730
+ await this.exec(posixJoinArgv([...seatScopeBusEnv(runtimeDir), tools.timeout, "5",
731
+ tools.systemctl, "--user", "show", "--property=Version", "--value"]));
732
+ }
733
+ catch (error) {
734
+ return remember("bus", classifyScopeFailure(error, "asking the systemd user manager"));
735
+ }
736
+ this.seatScopeFailedAt.delete("bus");
737
+ let opts = this.seatScopeProven.get(provenKey);
738
+ if (!opts) {
739
+ const proven = await this.proveSeatScope(runtimeDir, limits, tools);
740
+ if (!proven.ok)
741
+ return remember(probeKey, proven.problem);
742
+ opts = proven.opts;
743
+ this.seatScopeProven.set(provenKey, opts);
744
+ }
745
+ this.seatScopeFailedAt.delete(probeKey);
746
+ this.seatScopeLastPositive = undefined;
747
+ const name = seatEnv.OPENRIG_SESSION_NAME || seatEnv.OPENRIG_NODE_ID || "seat";
748
+ // Unit names take ASCII letters, digits and ":-_.\\"; an "@" would read as a template instance.
749
+ const unit = `openrig-seat-${name.replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 120)}-${randomUUID().slice(0, 8)}`;
750
+ return { ok: true, prefix: [...seatScopeBusEnv(runtimeDir),
751
+ ...seatScopeArgv(opts, unit, `OpenRig seat ${name}`, limits, tools.systemdRun), "--"] };
752
+ }
753
+ /** One throwaway scope with the seat's own options, whose command prints the pids.max of its own cgroup (and, with
754
+ * memory_max, its memory.max: one line per limit): the limits count as supported only when each one requested is the
755
+ * requested value. Options this systemd lacks are dropped from its stderr, as for the server's scope. A pids.max or
756
+ * memory.max that is another value (e.g. "max": TasksMax or MemoryMax= accepted but the controller not delegated) is a
757
+ * positive inability; an empty result or an error not recognized is unverified. */
758
+ async proveSeatScope(runtimeDir, limits, tools) {
759
+ const opts = { literal: true, oomPolicy: true };
760
+ const tasksMax = limits.tasksMax;
761
+ // Shell builtins only: no fork inside the scope, so even TasksMax=1 can be proven (the probe is the scope's one task).
762
+ const readOwnPidsMax = 'p=; while IFS= read -r l; do case $l in 0::*) p=${l#0::};; esac; done < /proc/self/cgroup; ' +
763
+ 'if [ -z "$p" ]; then printf "nocgroup2\\n"; elif [ ! -e "/sys/fs/cgroup$p/pids.max" ]; then printf "nopids\\n"; ' +
764
+ 'else IFS= read -r m < "/sys/fs/cgroup$p/pids.max" && printf "%s\\n" "$m"; fi';
765
+ // With memory_max, the same builtins print one line per requested limit: `memory <memory.max|nomemory>`, then
766
+ // `pids <pids.max|nopids>` when tasks_max is requested too (a seat without tasks_max has its user manager's own
767
+ // pids.max, which is not judged).
768
+ const readOwnLimits = 'p=; while IFS= read -r l; do case $l in 0::*) p=${l#0::};; esac; done < /proc/self/cgroup; ' +
769
+ 'if [ -z "$p" ]; then printf "nocgroup2\\n"; else ' +
770
+ 'if [ ! -e "/sys/fs/cgroup$p/memory.max" ]; then printf "memory nomemory\\n"; ' +
771
+ 'else IFS= read -r m < "/sys/fs/cgroup$p/memory.max" && printf "memory %s\\n" "$m"; fi; ' +
772
+ (tasksMax !== undefined ? 'if [ ! -e "/sys/fs/cgroup$p/pids.max" ]; then printf "pids nopids\\n"; ' +
773
+ 'else IFS= read -r t < "/sys/fs/cgroup$p/pids.max" && printf "pids %s\\n" "$t"; fi; ' : '') +
774
+ 'fi';
775
+ for (;;) {
776
+ let out;
777
+ try {
778
+ out = await this.exec(posixJoinArgv([...seatScopeBusEnv(runtimeDir), tools.timeout, "10",
779
+ ...seatScopeArgv(opts, `openrig-seat-probe-${randomUUID().slice(0, 8)}`, "OpenRig seat scope probe", limits, tools.systemdRun),
780
+ "--", "/bin/sh", "-c", limits.memoryMax === undefined ? readOwnPidsMax : readOwnLimits]));
781
+ }
782
+ catch (error) {
783
+ const stderr = execStderrText(error);
784
+ if (opts.literal && NO_EXPAND_ENVIRONMENT.test(stderr)) {
785
+ opts.literal = false;
786
+ continue;
787
+ }
788
+ if (opts.oomPolicy && NO_OOM_POLICY.test(stderr)) {
789
+ opts.oomPolicy = false;
790
+ continue;
791
+ }
792
+ // The probe command ended with SIGKILL (the signal, or exit 137 from timeout or a shell) under a memory limit.
793
+ // That does not say which process died nor why (the OOM killer at that MemoryMax=, the host's OOM killer,
794
+ // systemd-oomd, a manual kill, or before the scope was entered), and the scope that could tell (its memory.events
795
+ // `oom`) is collected with it. So it says only what was seen, names the limit and stays retryable (unverified).
796
+ if (limits.memoryMax !== undefined && killedBySigkill(error)) {
797
+ return { ok: false, problem: { kind: "unverified", limit: "memory_max",
798
+ reason: `the probe command ended with SIGKILL (exit 137) under the requested MemoryMax=${limits.memoryMax}; ` +
799
+ "the process and the cause aren't confirmed; a larger memory_max may help" } };
800
+ }
801
+ return { ok: false, problem: classifyScopeFailure(error, "a throwaway seat scope") };
802
+ }
803
+ const got = out.trim();
804
+ if (limits.memoryMax !== undefined) {
805
+ const problem = scopeProbeProblem(got, limits);
806
+ return problem ? { ok: false, problem } : { ok: true, opts };
807
+ }
808
+ if (!got)
809
+ return { ok: false, problem: { kind: "unverified", reason: "a throwaway seat scope read no pids.max" } };
810
+ if (got === "nocgroup2")
811
+ return { ok: false, problem: { kind: "unsupported", reason: NO_CGROUP2 } };
812
+ if (got === "nopids") {
813
+ return { ok: false, problem: { kind: "unsupported", reason: "a throwaway seat scope has no pids.max: the pids controller is not delegated to the user manager" } };
814
+ }
815
+ // Only a readable limit that isn't the one asked for is a positive answer; anything else can't be read.
816
+ if (!/^(\d+|max)$/.test(got)) {
817
+ return { ok: false, problem: { kind: "unverified", reason: `a throwaway seat scope's pids.max read could not be understood ("${got.slice(0, 80)}")` } };
818
+ }
819
+ if (got !== String(tasksMax)) {
820
+ return { ok: false, problem: { kind: "unsupported",
821
+ reason: `a throwaway seat scope got pids.max "${got}" for TasksMax=${tasksMax}: the pids limit is not enforced here (is the pids controller delegated to the user manager?)` } };
822
+ }
823
+ return { ok: true, opts };
824
+ }
825
+ }
826
+ /** Sleep used by the start check; replaceable in tests. */
827
+ scopeStartSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
828
+ /** A new marker file for a capped launch, written "pending" (only this daemon creates it, exclusively): the command
829
+ * that runs first inside the scope empties it (scopeMarkArgv). */
830
+ async scopeMarker() {
831
+ const marker = this.fileOps.tmpName();
832
+ await this.fileOps.writeFile(marker, SCOPE_MARKER_PENDING, { mode: 0o600, flag: "wx" });
833
+ return marker;
834
+ }
835
+ /** Whether a capped launch's command has started inside its scope, from its marker: `ran` (emptied), `pending`, or
836
+ * `unreadable`. */
837
+ async scopeMarkerState(marker) {
838
+ if (!marker)
839
+ return "unreadable";
840
+ try {
841
+ const text = await this.procRead(marker);
842
+ return text === "" ? "ran" : text === SCOPE_MARKER_PENDING ? "pending" : "unreadable";
843
+ }
844
+ catch {
845
+ return "unreadable";
846
+ }
847
+ }
848
+ /** Whether a capped launch's seat scope started: `started` once its command started inside the scope (the marker is
849
+ * emptied) and the pane's process is in a seat scope; `failed_before_command` when the pane died with the marker still
850
+ * pending (systemd-run could not make the scope, also late, after the check passed); `ran_and_ended` when it died
851
+ * after the command started inside the scope; `ran_unconfirmed` when the command started (the marker was emptied)
852
+ * but its process wasn't seen in the scope in time; `unknown` when the time ran out with the pane alive (its wrapper
853
+ * can still enter the scope and start the command after the last look) or the pane or the marker can't be read.
854
+ * The marker is removed at the end. */
855
+ async seatScopeStart(pane, marker) {
856
+ let sawRan = false;
857
+ try {
858
+ for (let i = 0; i < SEAT_SCOPE_START_CHECKS; i++) {
859
+ let dead;
860
+ try {
861
+ dead = await this.isPaneDead(pane);
862
+ }
863
+ catch {
864
+ return sawRan ? "ran_unconfirmed" : "unknown";
865
+ }
866
+ const mark = await this.scopeMarkerState(marker);
867
+ if (mark === "ran")
868
+ sawRan = true;
869
+ if (dead)
870
+ return mark === "ran" ? "ran_and_ended" : mark === "pending" ? "failed_before_command" : sawRan ? "ran_unconfirmed" : "unknown";
871
+ if (mark === "ran") {
872
+ try {
873
+ const pid = await this.getPanePid(pane);
874
+ const path = pid === null ? null : cgroupV2Path(await this.procRead(`/proc/${pid}/cgroup`));
875
+ if (path && /\/openrig-seat-[^/]+\.scope$/.test(path))
876
+ return "started";
877
+ }
878
+ catch { /* not readable at this moment: look again */ }
879
+ }
880
+ await this.scopeStartSleep(SEAT_SCOPE_START_CHECK_MS);
881
+ }
882
+ // Out of time with the pane alive: the wrapper may enter its scope and start the command after the last look.
883
+ return sawRan ? "ran_unconfirmed" : "unknown";
884
+ }
885
+ finally {
886
+ if (marker)
887
+ await this.fileOps.unlink(marker).catch(() => { });
888
+ }
889
+ }
890
+ /** The seat scope a pane's process runs in, read from the kernel: unknown when it can't be read, outside a seat scope,
891
+ * or in one, with the files of the limits requested only: for tasks_max, its pids.max, pids.current and how many
892
+ * times a fork hit the limit (pids.events `max`); for memory_max, its memory.max, memory.current, how many times its
893
+ * usage was about to go over the limit (memory.events `max`) and how many of its processes an OOM killer killed (memory.events `oom_kill`). */
894
+ async readPaneScope(paneTarget, requested) {
895
+ const pid = await this.getPanePid(paneTarget);
896
+ if (pid === null)
897
+ return { at: "unknown", reason: "the seat's pane process is not readable (not running?)" };
898
+ let path;
899
+ try {
900
+ path = cgroupV2Path(await this.procRead(`/proc/${pid}/cgroup`));
901
+ }
902
+ catch (error) {
903
+ return { at: "unknown", reason: `cgroup unreadable: ${error.message}` };
904
+ }
905
+ if (!path)
906
+ return { at: "unknown", reason: "no cgroup v2 path for the seat's process" };
907
+ const scope = path.split("/").pop() ?? "";
908
+ if (!/^openrig-seat-.+\.scope$/.test(scope))
909
+ return { at: "outside", scope };
910
+ try {
911
+ const dir = `/sys/fs/cgroup${path}`;
912
+ let pids = {};
913
+ if (requested.tasksMax !== undefined) {
914
+ const pidsMax = (await this.procRead(`${dir}/pids.max`)).trim();
915
+ const pidsCurrent = Number((await this.procRead(`${dir}/pids.current`)).trim());
916
+ const hits = /^max (\d+)$/m.exec(await this.procRead(`${dir}/pids.events`));
917
+ pids = { pidsMax, pidsCurrent, limitHits: hits ? Number(hits[1]) : 0 };
918
+ }
919
+ let memory = {};
920
+ if (requested.memoryMax !== undefined) {
921
+ const memoryMax = (await this.procRead(`${dir}/memory.max`)).trim();
922
+ const memoryCurrent = Number((await this.procRead(`${dir}/memory.current`)).trim());
923
+ const events = await this.procRead(`${dir}/memory.events`);
924
+ const hits = /^max (\d+)$/m.exec(events);
925
+ const kills = /^oom_kill (\d+)$/m.exec(events);
926
+ memory = { memoryMax, memoryCurrent, memoryLimitHits: hits ? Number(hits[1]) : 0, oomKills: kills ? Number(kills[1]) : 0 };
927
+ }
928
+ return { at: "seat", scope, ...pids, ...memory };
929
+ }
930
+ catch (error) {
931
+ return { at: "unknown", scope, reason: `scope files unreadable: ${error.message}` };
932
+ }
933
+ }
934
+ /** Where a seat's limits stand, read back from its pane's process (#3253): its cgroup must be a seat scope whose
935
+ * pids.max and memory.max are the requested values (each one requested). pids.events `max` counts the forks the
936
+ * limit refused; memory.events `max` the times usage was about to go over the memory limit, and `oom_kill` the processes in the scope any OOM killer killed.
937
+ * `paneTarget` is the seat's pane id (`%N`) when known, else its session (whose active pane is read). With `nodeId`, a
938
+ * seat in an environment guest reads `not_applied` (its pane holds only a local viewer). Read only. */
939
+ async readSeatProcessLimits(paneTarget, requested, nodeId) {
940
+ const base = { requested: { ...requested } };
941
+ const policy = this.readLaunchPolicy();
942
+ // The running process is read first: a seat already under its limit reads `applied` whatever this daemon could
943
+ // create now. A seat not under it reads `unsupported` only on a positive inability (from the environment, or the
944
+ // last check's own positive answer, with its age); else `not_applied` ("requested, not applied").
945
+ const fixed = this.seatScopeStaticProblem(policy, nodeId);
946
+ // A guest seat's pane holds only a local viewer: its readback says nothing of the agent's processes.
947
+ if (nodeId && this.seatInEnvironmentGuest?.(nodeId))
948
+ return { ...base, state: "not_applied", reason: fixed.reason };
949
+ // The last positive answer counts only for a request that asks a limit it was about: a failed memory probe says
950
+ // nothing of a tasks-only seat (nor a pids answer of a memory-only one); no cgroup v2 is about every limit.
951
+ const recent = this.seatScopeLastPositive && Date.now() - this.seatScopeLastPositive.at < SEAT_SCOPE_RETRY_MS
952
+ ? this.seatScopeLastPositive : undefined;
953
+ const last = recent && inabilityLimits(recent.problem, recent.probed)
954
+ .some((k) => (k === "tasks_max" ? requested.tasksMax : requested.memoryMax) !== undefined) ? recent : undefined;
955
+ const unsupported = fixed?.kind === "unsupported" ? fixed.reason
956
+ : last ? `${last.problem.reason}, observed ${Math.floor((Date.now() - last.at) / 1000)}s ago` : null;
957
+ const notUnder = (reason) => unsupported ? { ...base, state: "unsupported", reason: `${reason}; and this host can't make the scope: ${unsupported}` }
958
+ : fixed ? { ...base, state: "not_applied", reason: `${reason}; and this setup can't make the scope: ${fixed.reason}` }
959
+ : { ...base, state: "not_applied", reason };
960
+ const read = await this.readPaneScope(paneTarget, requested);
961
+ if (read.at === "unknown")
962
+ return { ...base, state: "unknown", ...(read.scope ? { scope: read.scope } : {}), reason: read.reason };
963
+ if (read.at === "outside") {
964
+ return notUnder(`the seat's process is not in a seat scope (${read.scope}); the limit applies at its next fresh launch`);
965
+ }
966
+ const { at: _at, ...scopeRead } = read;
967
+ // Applied only when every requested limit reads back as its value; the reason names each one that doesn't.
968
+ const off = [
969
+ ...(requested.tasksMax !== undefined && read.pidsMax !== String(requested.tasksMax)
970
+ ? [`pids.max is ${read.pidsMax}, not ${requested.tasksMax}`] : []),
971
+ ...(requested.memoryMax !== undefined && read.memoryMax !== String(requested.memoryMax)
972
+ ? [`memory.max is ${read.memoryMax}, not ${requested.memoryMax}`] : []),
973
+ ];
974
+ return off.length === 0
975
+ ? { ...base, state: "applied", ...scopeRead }
976
+ : { ...base, state: "not_applied", ...scopeRead, reason: `${off.join("; ")}; the limit applies at its next fresh launch` };
977
+ }
301
978
  /** Reset before the selected user shell runs, without changing the server or other sessions.
302
979
  * Multiple tmux command arguments execute directly; only this fixed non-interactive sh runs
303
980
  * before env -i. Generated pane metadata must come from this spawn, never daemon TMUX values.
304
981
  * Keep the configured default-command and default-shell lookup, including rc functions.
305
982
  */
306
- async scopedLaunchCommand(seatEnv, command, warnings = []) {
307
- if (!this.launchEnvironment || !seatEnv.OPENRIG_NODE_ID)
983
+ async scopedLaunchCommand(seatEnv, command, warnings = [], limitsMode = "fresh", notices) {
984
+ // #3253: a seat with a limit gets its scope. Where it can't: a fresh launch is not started and says why; a recovery
985
+ // goes ahead without it, with a structured warning, and the request stays stored.
986
+ const lookup = seatEnv.OPENRIG_NODE_ID ? this.seatLimitsLookup(seatEnv.OPENRIG_NODE_ID) : undefined;
987
+ // Read once: the scope check and the launch below must see the same setting.
988
+ const policy = seatEnv.OPENRIG_NODE_ID ? this.readLaunchPolicy() : undefined;
989
+ let seatScope = [];
990
+ let limited = false;
991
+ const notApplied = (problem) => {
992
+ if (limitsMode === "fresh")
993
+ throw new SeatProcessLimitsNotApplied(problem);
994
+ const notice = notAppliedNotice(problem);
995
+ if (notices) {
996
+ notices.processLimits = notice;
997
+ notices.capped = false;
998
+ }
999
+ // Logged by the launch once it has gone on without the limit.
1000
+ warnings.push(noticeLine(notice));
1001
+ limited = false;
1002
+ };
1003
+ if (lookup) {
1004
+ if ("invalid" in lookup)
1005
+ notApplied({ kind: "invalid", reason: lookup.invalid });
1006
+ else if (notices?.failedStart)
1007
+ notApplied({ ...notices.failedStart, requested: { ...lookup.limits } });
1008
+ else {
1009
+ const outcome = await this.seatScope(lookup.limits, seatEnv, policy);
1010
+ if (outcome.ok) {
1011
+ seatScope = outcome.prefix;
1012
+ limited = true;
1013
+ }
1014
+ else
1015
+ notApplied(outcome.problem);
1016
+ }
1017
+ }
1018
+ if (!policy || !seatEnv.OPENRIG_NODE_ID)
1019
+ return null;
1020
+ if (!(policy instanceof Error) && policy.inheritTmuxEnvironment) {
1021
+ if (limited)
1022
+ notApplied({ kind: "setup", reason: INHERIT_TMUX_ENVIRONMENT_REASON, requested: { ...lookup.limits } });
308
1023
  return null;
1024
+ }
309
1025
  try {
310
- const policy = this.launchEnvironment();
311
- if (policy.inheritTmuxEnvironment)
312
- return null;
1026
+ if (policy instanceof Error)
1027
+ throw policy;
313
1028
  if (process.platform === "win32")
314
1029
  throw new Error("POSIX launch boundary unavailable");
315
1030
  let shell = await this.getDefaultShell();
@@ -350,9 +1065,27 @@ export class TmuxAdapter {
350
1065
  await this.fileOps.writeFile(file, `/bin/rm -f -- ${shellQuote(file)}\n${values.join("\n")}\nexec "$@"\n`, { mode: 0o600, flag: "wx" });
351
1066
  // tmux supplies its terminal identity per pane; the daemon's terminal may be different.
352
1067
  const reset = 'exec /usr/bin/env -i -- TMUX="$TMUX" TMUX_PANE="$TMUX_PANE" TERM="$TERM" TERM_PROGRAM="${TERM_PROGRAM-}" TERM_PROGRAM_VERSION="${TERM_PROGRAM_VERSION-}" SHELL="$SHELL" /bin/sh "$@"';
353
- return ["/bin/sh", "-c", reset, "sh", file, shell, ...(command ? ["-c", command] : ["-l"])];
1068
+ // #3253: a seat with a limit enters its scope only after this file has run (its /bin/rm forks, outside the scope),
1069
+ // marks that its command started there, and gets back its own bus and runtime directory, which systemd-run's call
1070
+ // needed set otherwise.
1071
+ const marker = seatScope.length ? await this.scopeMarker() : undefined;
1072
+ const restore = seatScope.length ? [...scopeMarkArgv(marker), ...restoreEnvArgv({
1073
+ DBUS_SESSION_BUS_ADDRESS: selected.DBUS_SESSION_BUS_ADDRESS, XDG_RUNTIME_DIR: selected.XDG_RUNTIME_DIR
1074
+ })] : [];
1075
+ if (notices) {
1076
+ notices.capped = seatScope.length > 0;
1077
+ if (marker) {
1078
+ notices.marker = marker;
1079
+ notices.requested = { ...lookup.limits };
1080
+ }
1081
+ }
1082
+ return ["/bin/sh", "-c", reset, "sh", file, ...seatScope, ...restore, shell, ...(command ? ["-c", command] : ["-l"])];
354
1083
  }
355
- catch {
1084
+ catch (error) {
1085
+ if (limited) {
1086
+ notApplied({ kind: "unverified", reason: `the scoped launch environment failed: ${error.message}`,
1087
+ requested: { ...lookup.limits } });
1088
+ }
356
1089
  // Keep the working launch, with a diagnostic; this option is not a new admission gate.
357
1090
  const warning = "Scoped tmux environment unavailable; retaining the previous environment for this launch.";
358
1091
  warnings.push(warning);
@@ -360,6 +1093,108 @@ export class TmuxAdapter {
360
1093
  return null;
361
1094
  }
362
1095
  }
1096
+ /** A bare-pane respawn that keeps the seat's limit (a restart in place whose process reads back under it, #3253): the
1097
+ * command runs as the pane's default shell would run it, inside a new seat scope, with the bus and runtime directory
1098
+ * the pane would get from tmux. Recovery only: where the scope can't be made, the respawn goes on without it. */
1099
+ async keptScopeCommand(nodeId, pane, command, warnings, notices) {
1100
+ const lookup = this.seatLimitsLookup(nodeId);
1101
+ if (!lookup)
1102
+ return null;
1103
+ const notApplied = (problem) => {
1104
+ const notice = notAppliedNotice(problem);
1105
+ notices.processLimits = notice;
1106
+ notices.capped = false;
1107
+ warnings.push(noticeLine(notice));
1108
+ return null;
1109
+ };
1110
+ if ("invalid" in lookup)
1111
+ return notApplied({ kind: "invalid", reason: lookup.invalid });
1112
+ const requested = { ...lookup.limits };
1113
+ if (notices.failedStart)
1114
+ return notApplied({ ...notices.failedStart, requested });
1115
+ const outcome = await this.seatScope(lookup.limits, { OPENRIG_NODE_ID: nodeId }, this.readLaunchPolicy());
1116
+ if (!outcome.ok)
1117
+ return notApplied(outcome.problem);
1118
+ try {
1119
+ if (!command)
1120
+ throw new Error("a kept scope needs the respawn's command");
1121
+ const shell = await this.getDefaultShell();
1122
+ if (!shell)
1123
+ throw new Error("Default shell unavailable");
1124
+ const restore = restoreEnvArgv({
1125
+ DBUS_SESSION_BUS_ADDRESS: await this.paneStartEnv(pane, "DBUS_SESSION_BUS_ADDRESS"),
1126
+ XDG_RUNTIME_DIR: await this.paneStartEnv(pane, "XDG_RUNTIME_DIR"),
1127
+ });
1128
+ const marker = await this.scopeMarker();
1129
+ notices.capped = true;
1130
+ notices.marker = marker;
1131
+ notices.requested = requested;
1132
+ return [...outcome.prefix, ...scopeMarkArgv(marker), ...restore, shell, "-c", command];
1133
+ }
1134
+ catch (error) {
1135
+ return notApplied({ kind: "unverified", reason: `the kept scope's launch could not be prepared: ${error.message}`, requested });
1136
+ }
1137
+ }
1138
+ /** The value a new process in this pane's session gets for `key` from tmux: the session's own (undefined when it is
1139
+ * marked removed), else the server's global one. Throws when the environment can't be read. */
1140
+ async paneStartEnv(pane, key) {
1141
+ const lines = await this.sessionEnvLines(pane);
1142
+ if (lines === null)
1143
+ throw new Error("Cannot read the session's launch environment.");
1144
+ if (lines.includes(`-${key}`))
1145
+ return undefined;
1146
+ const own = lines.find((line) => line.startsWith(`${key}=`));
1147
+ if (own !== undefined)
1148
+ return own.slice(key.length + 1);
1149
+ return (await this.globalEnvironment())[key];
1150
+ }
1151
+ /** A launch's success result. A recovery that went on without the limit, or can't tell where it stands, is logged here,
1152
+ * only once the launch has gone on. */
1153
+ launched(warnings, notices) {
1154
+ if (notices.processLimits)
1155
+ console.warn(`[seat launch] ${noticeLine(notices.processLimits)}`);
1156
+ return { ok: true, ...(warnings.length ? { warnings } : {}), ...(notices.processLimits ? { processLimits: notices.processLimits } : {}) };
1157
+ }
1158
+ /** After a capped launch made its pane: whether its scope started. A fresh launch counts only once it has (a command
1159
+ * that started in the scope and ended counts too); otherwise it is refused as `unverified`, never retried without the
1160
+ * limit. A recovery runs the command again without the limit only when it failed before the command started; when
1161
+ * the start can't be told, it goes on with an `unknown` notice and runs nothing again. Null: the launch stands. */
1162
+ async scopeStartOutcome(pane, mode, notices, warnings) {
1163
+ // No pane to watch: whether its command started can't be told.
1164
+ const start = pane ? await this.seatScopeStart(pane, notices.marker) : "unknown";
1165
+ if (!pane && notices.marker)
1166
+ await this.fileOps.unlink(notices.marker).catch(() => { });
1167
+ if (start === "started")
1168
+ return null;
1169
+ const requested = notices.requested ? { requested: { ...notices.requested } } : {};
1170
+ const failedBefore = "the seat's scope did not start: its pane's command exited before entering it";
1171
+ if (mode !== "recovery") {
1172
+ if (start === "ran_and_ended")
1173
+ return null;
1174
+ if (start === "ran_unconfirmed") {
1175
+ return { refuse: { kind: "unverified", ...requested, commandStarted: true,
1176
+ reason: "the seat's command started, but its process was not seen in the seat's scope in time" } };
1177
+ }
1178
+ if (start === "unknown") {
1179
+ return { refuse: { kind: "unverified", ...requested, commandStarted: "unknown",
1180
+ reason: "the seat's scope start was not confirmed in time, so whether its command started is unknown" } };
1181
+ }
1182
+ // Only a pane that died with the marker still pending failed before the command.
1183
+ return { refuse: { kind: "unverified", ...requested, reason: failedBefore } };
1184
+ }
1185
+ if (start === "failed_before_command")
1186
+ return { retryUncapped: { kind: "unverified", reason: failedBefore } };
1187
+ // As in the fresh refusal: what was seen of the command, apart from the limit (nothing here is run again).
1188
+ const notice = unknownNotice({ kind: "unverified", ...requested, commandStarted: start === "unknown" ? "unknown" : true,
1189
+ reason: start === "ran_and_ended"
1190
+ ? "the seat's command started in its scope and ended before it was seen running; it was not run again"
1191
+ : start === "ran_unconfirmed"
1192
+ ? "the seat's command started, but its process was not seen in the seat's scope in time; it was not run again"
1193
+ : "the seat's scope start was not confirmed in time; the seat was not started again" });
1194
+ notices.processLimits = notice;
1195
+ warnings.push(noticeLine(notice));
1196
+ return null;
1197
+ }
363
1198
  inputGuard;
364
1199
  get deliveryGuard() { return this.inputGuard; }
365
1200
  set deliveryGuard(guard) {
@@ -810,11 +1645,11 @@ export class TmuxAdapter {
810
1645
  const probe = await this.probeSession(name);
811
1646
  return probe.state === "present";
812
1647
  }
813
- async createSession(name, cwd, env) {
1648
+ async createSession(name, cwd, env, launchOpts) {
814
1649
  if (this.deliveryGuard && (!env?.OPENRIG_NODE_ID || !this.deliveryGuard.ownsLifecycle(env.OPENRIG_NODE_ID))) {
815
1650
  return { ok: false, code: "guard_lease_required", message: "Managed launch requires a lifecycle lease before terminal creation." };
816
1651
  }
817
- const result = await this.createSessionUnchecked(name, cwd, env);
1652
+ const result = await this.createSessionUnchecked(name, cwd, env, launchOpts);
818
1653
  if (result.ok && this.deliveryGuard && env?.OPENRIG_NODE_ID) {
819
1654
  try {
820
1655
  const panes = await this.listPanes(name);
@@ -912,7 +1747,7 @@ export class TmuxAdapter {
912
1747
  }
913
1748
  });
914
1749
  }
915
- async createSessionUnchecked(name, cwd, env) {
1750
+ async createSessionUnchecked(name, cwd, env, launchOpts) {
916
1751
  // These are the daemon's resolved capture settings, not seat overrides.
917
1752
  // An empty per-session value prevents the tmux server's inherited values
918
1753
  // from pinning an old policy over config.json inside a newly launched seat.
@@ -927,34 +1762,85 @@ export class TmuxAdapter {
927
1762
  argv.push("-c", cwd);
928
1763
  for (const [k, v] of Object.entries(seatEnv))
929
1764
  argv.push("-e", `${k}=${v}`);
930
- // The pane new-session itself made: an after-new-session hook may select another window.
931
- argv.push("-P", "-F", "#{pane_id}");
932
1765
  const legacyParts = ["tmux", "new-session", "-d", "-s", tmuxConfigQuote(name)];
933
1766
  if (cwd != null)
934
1767
  legacyParts.push("-c", tmuxConfigQuote(cwd));
935
1768
  for (const [k, v] of Object.entries(seatEnv))
936
1769
  legacyParts.push("-e", tmuxConfigQuote(`${k}=${v}`));
937
- legacyParts.push("-P", "-F", tmuxConfigQuote("#{pane_id}"));
938
1770
  const warnings = [];
939
- const scopedCommand = await this.scopedLaunchCommand(seatEnv, undefined, warnings);
1771
+ let scopedCommand;
1772
+ const notices = launchOpts?.failedStart ? { failedStart: launchOpts.failedStart } : {};
1773
+ try {
1774
+ scopedCommand = await this.scopedLaunchCommand(seatEnv, undefined, warnings, launchOpts?.processLimitsMode, notices);
1775
+ }
1776
+ catch (error) {
1777
+ if (error instanceof SeatProcessLimitsNotApplied)
1778
+ return processLimitsNotAppliedResult(error);
1779
+ throw error;
1780
+ }
1781
+ // The pane new-session itself made: an after-new-session hook may select another window. A capped launch also
1782
+ // prints, from the same command, the session it made and its server (pid and start time), so a refusal below
1783
+ // removes that session and no other: a server that exits and comes back reuses pane and session ids.
1784
+ const printFormat = notices.capped ? CREATED_IDENTITY_FORMAT : "#{pane_id}";
1785
+ argv.push("-P", "-F", printFormat);
1786
+ legacyParts.push("-P", "-F", tmuxConfigQuote(printFormat));
940
1787
  if (scopedCommand) {
941
1788
  argv.push(...scopedCommand);
942
1789
  legacyParts.push(...scopedCommand.map(tmuxConfigQuote));
943
1790
  }
944
- let created;
1791
+ let printed;
945
1792
  try {
946
- created = (await this.runEnvironmentCommand(argv, legacyParts.join(" "), true)).trim();
1793
+ printed = (await this.runEnvironmentCommand(argv, legacyParts.join(" "), true)).trim();
947
1794
  }
948
1795
  catch (err) {
1796
+ if (notices.marker)
1797
+ await this.fileOps.unlink(notices.marker).catch(() => { });
949
1798
  return classifyWriteError(err);
950
1799
  }
1800
+ // A capped launch reads its pane and identity from the same, first, printed line (a hook may print more after it).
1801
+ const firstLine = notices.capped ? (printed.split("\n")[0] ?? "").trim() : printed;
1802
+ const made = notices.capped ? createdIdentity(firstLine) : null;
1803
+ const created = notices.capped ? (firstLine.split(" ")[0] ?? "") : printed;
951
1804
  // tmux can exit 0 having made nothing: a server that can't create its socket prints its error and quits, and the
952
1805
  // client still exits 0. new-session prints the pane it made; with none, the session must be read back before the
953
1806
  // launch counts as created.
954
1807
  if (!/^%\d+$/.test(created)) {
955
1808
  const unconfirmed = await this.sessionUnconfirmedAfterCreate(name);
956
- if (unconfirmed)
1809
+ // #3253: a capped launch whose session can't be read back may be running uncapped: the possibly-running refusal
1810
+ // (no retry, how to look and stop it). A session positively absent stays session_not_created.
1811
+ // Only a fresh launch: a recovery never stops for the limit, and keeps the plain session_unconfirmed.
1812
+ if (unconfirmed?.code === "session_unconfirmed" && notices.capped && launchOpts?.processLimitsMode !== "recovery") {
1813
+ if (notices.marker)
1814
+ await this.fileOps.unlink(notices.marker).catch(() => { });
1815
+ return processLimitsNotAppliedResult(new SeatProcessLimitsNotApplied({ kind: "unverified", commandStarted: "unknown",
1816
+ ...(notices.requested ? { requested: { ...notices.requested } } : {}),
1817
+ reason: `tmux printed no pane for the launch and its session couldn't be read back (${unconfirmed.message})` }), await this.removeRefusedSession(name, null));
1818
+ }
1819
+ if (unconfirmed) {
1820
+ // the scope start is never checked on this way out: its marker would be left pending in the temp dir
1821
+ if (notices.marker)
1822
+ await this.fileOps.unlink(notices.marker).catch(() => { });
957
1823
  return { ok: false, ...unconfirmed };
1824
+ }
1825
+ }
1826
+ // #3253: a capped launch counts only once its scope is seen to start. A fresh one that isn't is refused and the
1827
+ // session it made is removed (never a retry without the limit). A recovery (a provider switch's staged successor)
1828
+ // never stops for the limit: when systemd-run fails after the check passed, the pane's command exits before
1829
+ // entering the scope, and the seat starts again without the limit, with the warning (in the same pane when tmux
1830
+ // kept it, else in a new session of the same name); when the start can't be told, nothing is run again.
1831
+ if (notices.capped) {
1832
+ const outcome = await this.scopeStartOutcome(/^%\d+$/.test(created) ? created : null, launchOpts?.processLimitsMode, notices, warnings);
1833
+ if (outcome && "refuse" in outcome) {
1834
+ return processLimitsNotAppliedResult(new SeatProcessLimitsNotApplied(outcome.refuse), await this.removeRefusedSession(name, made));
1835
+ }
1836
+ if (outcome) {
1837
+ const failedStart = outcome.retryUncapped;
1838
+ const kept = await this.probeSession(name).catch(() => ({ state: "unknown" }));
1839
+ return kept.state === "present"
1840
+ ? this.respawnPaneUnchecked(created, undefined, { ...(cwd != null ? { cwd } : {}), env: seatEnv,
1841
+ processLimitsMode: "recovery", failedStart })
1842
+ : this.createSessionUnchecked(name, cwd, env, { processLimitsMode: "recovery", failedStart });
1843
+ }
958
1844
  }
959
1845
  // A tmux server started from a Claude Code session or Herdr pane hands
960
1846
  // their identity to every new pane. Mark it removed for this session only
@@ -969,10 +1855,10 @@ export class TmuxAdapter {
969
1855
  respawn.push("-c", cwd);
970
1856
  await this.run(respawn, posixJoinArgv(respawn));
971
1857
  }
972
- return warnings.length ? { ok: true, warnings } : { ok: true };
1858
+ return this.launched(warnings, notices);
973
1859
  }
974
1860
  catch (err) {
975
- return { ok: true, warnings: [...warnings, parentSessionEnvWarning(name, err)] };
1861
+ return this.launched([...warnings, parentSessionEnvWarning(name, err)], notices);
976
1862
  }
977
1863
  }
978
1864
  /** When new-session printed no pane: why the launch can't count as created, or null when the session is there. Only a
@@ -1285,9 +2171,31 @@ export class TmuxAdapter {
1285
2171
  return classifyWriteError(err);
1286
2172
  }
1287
2173
  }
2174
+ /** #3253: removes the session a refused fresh launch made, by the identity its new-session printed, and only while
2175
+ * that id is that session on that server. Null when it is gone (removed now, or already gone with its pane or its
2176
+ * server); otherwise the sentence the refusal adds: the session may still be running, and how to look and stop it.
2177
+ * Without a printed identity nothing is removed, never by name (a same-named session may not be this launch's). */
2178
+ async removeRefusedSession(name, made) {
2179
+ const look = ` Look with \`${tmuxOnDaemonServer()} attach -t ${shellQuote(`=${name}`)}\` and stop it with `
2180
+ + `\`${tmuxOnDaemonServer()} kill-session -t ${shellQuote(`=${name}`)}\` if it is this launch's.`;
2181
+ if (!made)
2182
+ return `Its session "${name}" may still be running: tmux didn't print the session it made, so it was not removed.${look}`;
2183
+ const removed = await this.killSessionUnchecked(made.session, undefined, undefined, made.server)
2184
+ .catch((err) => classifyWriteError(err));
2185
+ // Gone either way: removed now, no longer there (session_not_found), or its server was replaced (guard_target_changed:
2186
+ // the id names another terminal now, and the server that held this session is gone with it).
2187
+ if (removed.ok || removed.code === "session_not_found" || removed.code === "guard_target_changed")
2188
+ return null;
2189
+ // tmux's own words, without an exec wrapper's "Command failed: <command>" line.
2190
+ const said = removed.message.split("\n").map(line => line.trim()).filter(line => line && !line.startsWith("Command failed:")).join(" ")
2191
+ || removed.message.trim();
2192
+ return `Its session "${name}" (${made.session}) may still be running: it could not be removed (${said}).${look}`;
2193
+ }
1288
2194
  /** With a delivery guard, terminate by immutable tmux session ID; checked callers validate before detach and kill.
1289
2195
  * A seat's session is stopped only when it carries that seat's OpenRig marker, and each effect runs only while that
1290
- * id still names a session on the server it was read from: a replaced server reuses ids for other terminals. */
2196
+ * id still names a session on the server it was read from: a replaced server reuses ids for other terminals.
2197
+ * A checked caller's validation may be asynchronous (a fresh process observation); it's awaited right before each
2198
+ * effect, after this method's own reads, and the guard's synchronous check runs after it. */
1291
2199
  async killSession(name, beforeEffect) {
1292
2200
  let stopPhase = "none";
1293
2201
  if (this.deliveryGuard) {
@@ -1304,7 +2212,7 @@ export class TmuxAdapter {
1304
2212
  return unproven;
1305
2213
  }
1306
2214
  const kill = async () => {
1307
- const result = await this.killSessionUnchecked(sessionId, beforeEffect && (() => { beforeWrite(); beforeEffect(); }), phase => { stopPhase = phase; }, { pid, start });
2215
+ const result = await this.killSessionUnchecked(sessionId, beforeEffect && (async () => { await beforeEffect(); beforeWrite(); }), phase => { stopPhase = phase; }, { pid, start });
1308
2216
  if (result.ok) {
1309
2217
  this.freshProbes.delete(name);
1310
2218
  this.freshProbes.delete(pane);
@@ -1360,7 +2268,7 @@ export class TmuxAdapter {
1360
2268
  `${verb} ${flag} '${session}'`, `display-message -p ${changed}`]
1361
2269
  : ["tmux", verb, flag, session];
1362
2270
  // Detach first so `detach-on-destroy off` cannot switch views onto another session.
1363
- beforeEffect?.();
2271
+ await beforeEffect?.();
1364
2272
  phase?.("detach_attempted");
1365
2273
  try {
1366
2274
  const out = await this.run(effect("detach-client", "-s"), server ? undefined : `tmux detach-client -s ${shellQuote(session)}`);
@@ -1374,7 +2282,7 @@ export class TmuxAdapter {
1374
2282
  return classifyWriteError(err);
1375
2283
  }
1376
2284
  phase?.("detached");
1377
- beforeEffect?.();
2285
+ await beforeEffect?.();
1378
2286
  phase?.("kill_attempted");
1379
2287
  try {
1380
2288
  const out = await this.run(effect("kill-session", "-t"), server ? undefined : `tmux kill-session -t ${shellQuote(session)}`);
@@ -1428,7 +2336,18 @@ export class TmuxAdapter {
1428
2336
  for (const [k, v] of Object.entries(opts.env))
1429
2337
  argv.push("-e", `${k}=${v}`);
1430
2338
  const warnings = [];
1431
- const scopedCommand = await this.scopedLaunchCommand(opts?.env ?? {}, command, warnings);
2339
+ let scopedCommand;
2340
+ const notices = opts?.failedStart ? { failedStart: opts.failedStart } : {};
2341
+ try {
2342
+ scopedCommand = opts?.keepLimitOf && !opts.env
2343
+ ? await this.keptScopeCommand(opts.keepLimitOf, exact, command, warnings, notices)
2344
+ : await this.scopedLaunchCommand(opts?.env ?? {}, command, warnings, opts?.processLimitsMode, notices);
2345
+ }
2346
+ catch (error) {
2347
+ if (error instanceof SeatProcessLimitsNotApplied)
2348
+ return processLimitsNotAppliedResult(error);
2349
+ throw error;
2350
+ }
1432
2351
  // Legacy commands remain one argument; the scoped wrapper executes directly before the user shell.
1433
2352
  if (scopedCommand)
1434
2353
  argv.push(...scopedCommand);
@@ -1459,9 +2378,23 @@ export class TmuxAdapter {
1459
2378
  await this.runEnvironmentCommand(argv, legacyRespawn.join(" "));
1460
2379
  else
1461
2380
  await this.run(argv, legacyRespawn.join(" "));
1462
- return warnings.length ? { ok: true, warnings } : { ok: true };
2381
+ // #3253: a capped respawn counts only once its scope is seen to start. A fresh one that isn't is refused (the pane
2382
+ // is not this launch's to remove). A recovery never stops for the limit, also when systemd-run fails at this
2383
+ // moment (after the check passed): its pane's command exits before the seat's command starts in the scope, and
2384
+ // the recovery starts it again without the limit, with the warning; when the start can't be told, it runs
2385
+ // nothing again.
2386
+ if (notices.capped) {
2387
+ const outcome = await this.scopeStartOutcome(exact, opts?.keepLimitOf ? "recovery" : opts?.processLimitsMode, notices, warnings);
2388
+ if (outcome && "refuse" in outcome)
2389
+ return processLimitsNotAppliedResult(new SeatProcessLimitsNotApplied(outcome.refuse));
2390
+ if (outcome)
2391
+ return this.respawnPaneUnchecked(paneTarget, command, { ...opts, failedStart: outcome.retryUncapped });
2392
+ }
2393
+ return this.launched(warnings, notices);
1463
2394
  }
1464
2395
  catch (err) {
2396
+ if (notices.marker)
2397
+ await this.fileOps.unlink(notices.marker).catch(() => { });
1465
2398
  return classifyWriteError(err);
1466
2399
  }
1467
2400
  }
@@ -1701,16 +2634,15 @@ export class TmuxAdapter {
1701
2634
  const target = exactTarget(session, "session");
1702
2635
  await this.runEnvironmentCommand(["tmux", "set-environment", "-t", target, key, value], `tmux set-environment -t ${tmuxConfigQuote(target)} ${tmuxConfigQuote(key)} ${tmuxConfigQuote(value)}`);
1703
2636
  }
1704
- /** Remove one variable from a session's environment, so a process spawned there afterwards
1705
- * inherits the server's value for it, or none. A name that is the launching session's own
1706
- * identity in the server's environment (see parent-session-env) is marked removed instead, as a
1707
- * launch does, so the server's value does not come back. */
2637
+ /** Remove one variable from a session's environment. Ordinary names inherit the server's value
2638
+ * afterwards, if any. Credentials and the launching session's own identity are marked removed
2639
+ * instead, so they cannot come back from the server's global environment. */
1708
2640
  async unsetSessionEnv(session, key) {
1709
2641
  if (!/^[A-Z_][A-Z0-9_]*$/.test(key))
1710
2642
  throw new Error("Invalid session environment key.");
1711
2643
  const target = exactTarget(session, "session");
1712
- const parentIdentity = parentSessionEnvKeys(await this.globalEnvironment()).includes(key);
1713
- const flag = parentIdentity ? "-r" : "-u";
2644
+ const mustNotInherit = isTmuxCredentialEnvKey(key) || parentSessionEnvKeys(await this.globalEnvironment()).includes(key);
2645
+ const flag = mustNotInherit ? "-r" : "-u";
1714
2646
  await this.run(["tmux", "set-environment", "-t", target, flag, key], `tmux set-environment -t ${shellQuote(target)} ${flag} ${shellQuote(key)}`);
1715
2647
  }
1716
2648
  async globalEnvironment() {