create-principles-disciple 1.154.5 → 1.155.2

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 (428) hide show
  1. package/_release/product-identity.json +2 -2
  2. package/codex-adapter/dist/codec/input-decoder.d.ts +17 -0
  3. package/codex-adapter/dist/codec/input-decoder.js +39 -0
  4. package/codex-adapter/dist/ingestion/explicit-owner-statement.js +125 -1
  5. package/codex-adapter/dist/ingestion/pain-receipt-fallback.d.ts +46 -0
  6. package/codex-adapter/dist/ingestion/pain-receipt-fallback.js +193 -0
  7. package/codex-adapter/dist/ingestion/turn-context.d.ts +10 -15
  8. package/codex-adapter/dist/ingestion/turn-context.js +35 -9
  9. package/codex-adapter/dist/pd-hook.js +57 -1
  10. package/codex-adapter/dist/worker/workspace-worker.d.ts +15 -0
  11. package/codex-adapter/dist/worker/workspace-worker.js +91 -12
  12. package/codex-adapter/package.json +1 -1
  13. package/console/dist/server/index.js +11 -0
  14. package/console/dist/server/models/EvidenceChainConsoleModel.js +31 -0
  15. package/console/dist/server/routes/health.d.ts +1 -0
  16. package/console/dist/server/routes/health.js +12 -0
  17. package/console/dist/server/routes/service-host.d.ts +19 -0
  18. package/console/dist/server/routes/service-host.js +129 -0
  19. package/console/dist/web/assets/app.js +39 -39
  20. package/console/package.json +1 -1
  21. package/core/dist/runtime/adapter/pi-ai-http-transport.d.ts.map +1 -1
  22. package/core/dist/runtime/adapter/pi-ai-http-transport.js.map +1 -1
  23. package/core/dist/runtime/context-payload.d.ts +48 -0
  24. package/core/dist/runtime/context-payload.d.ts.map +1 -1
  25. package/core/dist/runtime/context-payload.js +12 -0
  26. package/core/dist/runtime/context-payload.js.map +1 -1
  27. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
  28. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js +18 -0
  29. package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js.map +1 -1
  30. package/core/dist/runtime/diagnostician-candidate.d.ts.map +1 -1
  31. package/core/dist/runtime/diagnostician-candidate.js +18 -2
  32. package/core/dist/runtime/diagnostician-candidate.js.map +1 -1
  33. package/core/dist/runtime/evidence-guards.d.ts +7 -3
  34. package/core/dist/runtime/evidence-guards.d.ts.map +1 -1
  35. package/core/dist/runtime/evidence-guards.js +9 -7
  36. package/core/dist/runtime/evidence-guards.js.map +1 -1
  37. package/core/dist/runtime/feature-flags/feature-flag-contract.d.ts.map +1 -1
  38. package/core/dist/runtime/feature-flags/feature-flag-contract.js +14 -0
  39. package/core/dist/runtime/feature-flags/feature-flag-contract.js.map +1 -1
  40. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
  41. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +8 -0
  42. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
  43. package/core/dist/runtime/host-submission-context.d.ts +83 -0
  44. package/core/dist/runtime/host-submission-context.d.ts.map +1 -0
  45. package/core/dist/runtime/host-submission-context.js +183 -0
  46. package/core/dist/runtime/host-submission-context.js.map +1 -0
  47. package/core/dist/runtime/index.d.ts +9 -2
  48. package/core/dist/runtime/index.d.ts.map +1 -1
  49. package/core/dist/runtime/index.js +29 -2
  50. package/core/dist/runtime/index.js.map +1 -1
  51. package/core/dist/runtime/intent/intent-doc.d.ts.map +1 -1
  52. package/core/dist/runtime/intent/intent-doc.js +29 -5
  53. package/core/dist/runtime/intent/intent-doc.js.map +1 -1
  54. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +9 -0
  55. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
  56. package/core/dist/runtime/internalization/diag-distiller-runner.js +13 -0
  57. package/core/dist/runtime/internalization/diag-distiller-runner.js.map +1 -1
  58. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +11 -0
  59. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
  60. package/core/dist/runtime/internalization/diag-rootcause-runner.js +10 -0
  61. package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
  62. package/core/dist/runtime/internalization/diag-router-runner.d.ts +9 -0
  63. package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
  64. package/core/dist/runtime/internalization/diag-router-runner.js +13 -0
  65. package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
  66. package/core/dist/runtime/internalization/index.d.ts +1 -1
  67. package/core/dist/runtime/internalization/index.d.ts.map +1 -1
  68. package/core/dist/runtime/internalization/index.js +1 -1
  69. package/core/dist/runtime/internalization/index.js.map +1 -1
  70. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts +19 -0
  71. package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts.map +1 -1
  72. package/core/dist/runtime/internalization/intake-to-internalization-bridge.js +24 -0
  73. package/core/dist/runtime/internalization/intake-to-internalization-bridge.js.map +1 -1
  74. package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +8 -0
  75. package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
  76. package/core/dist/runtime/internalization/internalization-orchestrator.js +36 -4
  77. package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
  78. package/core/dist/runtime/internalization/source-authorization-boundary.d.ts +39 -0
  79. package/core/dist/runtime/internalization/source-authorization-boundary.d.ts.map +1 -0
  80. package/core/dist/runtime/internalization/source-authorization-boundary.js +57 -0
  81. package/core/dist/runtime/internalization/source-authorization-boundary.js.map +1 -0
  82. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
  83. package/core/dist/runtime/internalization/split-diagnostician-runner.js +72 -5
  84. package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
  85. package/core/dist/runtime/pain-admission-disposition.d.ts +60 -0
  86. package/core/dist/runtime/pain-admission-disposition.d.ts.map +1 -0
  87. package/core/dist/runtime/pain-admission-disposition.js +37 -0
  88. package/core/dist/runtime/pain-admission-disposition.js.map +1 -0
  89. package/core/dist/runtime/pain-ingress-payload.d.ts +36 -2
  90. package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
  91. package/core/dist/runtime/pain-ingress-payload.js +63 -6
  92. package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
  93. package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
  94. package/core/dist/runtime/pain-ingress.js +28 -0
  95. package/core/dist/runtime/pain-ingress.js.map +1 -1
  96. package/core/dist/runtime/pain-recall-read-model.d.ts +13 -1
  97. package/core/dist/runtime/pain-recall-read-model.d.ts.map +1 -1
  98. package/core/dist/runtime/pain-recall-read-model.js +50 -7
  99. package/core/dist/runtime/pain-recall-read-model.js.map +1 -1
  100. package/core/dist/runtime/pain-receipt-recovery.d.ts +147 -0
  101. package/core/dist/runtime/pain-receipt-recovery.d.ts.map +1 -0
  102. package/core/dist/runtime/pain-receipt-recovery.js +475 -0
  103. package/core/dist/runtime/pain-receipt-recovery.js.map +1 -0
  104. package/core/dist/runtime/pain-signal-bridge.d.ts +13 -1
  105. package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
  106. package/core/dist/runtime/pain-signal-bridge.js +174 -0
  107. package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
  108. package/core/dist/runtime/pain-signal-runtime-factory.d.ts +9 -0
  109. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  110. package/core/dist/runtime/pain-signal-runtime-factory.js +8 -3
  111. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  112. package/core/dist/runtime/pain-submit-capability.d.ts +11 -0
  113. package/core/dist/runtime/pain-submit-capability.d.ts.map +1 -1
  114. package/core/dist/runtime/pain-submit-capability.js +77 -3
  115. package/core/dist/runtime/pain-submit-capability.js.map +1 -1
  116. package/core/dist/runtime/pain-target-evidence-reconcile.d.ts +55 -0
  117. package/core/dist/runtime/pain-target-evidence-reconcile.d.ts.map +1 -0
  118. package/core/dist/runtime/pain-target-evidence-reconcile.js +164 -0
  119. package/core/dist/runtime/pain-target-evidence-reconcile.js.map +1 -0
  120. package/core/dist/runtime/pain-to-principle-service.d.ts +8 -0
  121. package/core/dist/runtime/pain-to-principle-service.d.ts.map +1 -1
  122. package/core/dist/runtime/pain-to-principle-service.js +1 -0
  123. package/core/dist/runtime/pain-to-principle-service.js.map +1 -1
  124. package/core/dist/runtime/source-material-authorization.d.ts +166 -0
  125. package/core/dist/runtime/source-material-authorization.d.ts.map +1 -0
  126. package/core/dist/runtime/source-material-authorization.js +250 -0
  127. package/core/dist/runtime/source-material-authorization.js.map +1 -0
  128. package/core/dist/runtime/store/context/index.d.ts +1 -0
  129. package/core/dist/runtime/store/context/index.d.ts.map +1 -1
  130. package/core/dist/runtime/store/context/index.js +1 -0
  131. package/core/dist/runtime/store/context/index.js.map +1 -1
  132. package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts +8 -0
  133. package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts.map +1 -1
  134. package/core/dist/runtime/store/context/promoted-evidence-reader.js +15 -1
  135. package/core/dist/runtime/store/context/promoted-evidence-reader.js.map +1 -1
  136. package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts +22 -0
  137. package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
  138. package/core/dist/runtime/store/context/sqlite-context-assembler.js +153 -3
  139. package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
  140. package/core/dist/runtime/store/context/trajectory-turn-reader.d.ts +13 -0
  141. package/core/dist/runtime/store/context/trajectory-turn-reader.d.ts.map +1 -1
  142. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +15 -0
  143. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
  144. package/core/dist/runtime/store/lifecycle/lease-manager.js +16 -1
  145. package/core/dist/runtime/store/lifecycle/lease-manager.js.map +1 -1
  146. package/core/dist/runtime/store/runtime-state-manager.d.ts +2 -0
  147. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  148. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  149. package/core/dist/runtime/store/task/memory-task-store.d.ts +1 -0
  150. package/core/dist/runtime/store/task/memory-task-store.d.ts.map +1 -1
  151. package/core/dist/runtime/store/task/memory-task-store.js +37 -0
  152. package/core/dist/runtime/store/task/memory-task-store.js.map +1 -1
  153. package/core/dist/runtime/store/task/sqlite-task-store.d.ts +10 -0
  154. package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
  155. package/core/dist/runtime/store/task/sqlite-task-store.js +20 -0
  156. package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
  157. package/core/dist/runtime/store/task/task-store.d.ts +16 -0
  158. package/core/dist/runtime/store/task/task-store.d.ts.map +1 -1
  159. package/core/dist/runtime/task-status.d.ts +13 -0
  160. package/core/dist/runtime/task-status.d.ts.map +1 -1
  161. package/core/dist/runtime/task-status.js +9 -0
  162. package/core/dist/runtime/task-status.js.map +1 -1
  163. package/core/dist/runtime/types/evidence-chain-contract.d.ts +10 -0
  164. package/core/dist/runtime/types/evidence-chain-contract.d.ts.map +1 -1
  165. package/core/dist/runtime/types/evidence-chain-contract.js +7 -0
  166. package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
  167. package/core/package.json +2 -2
  168. package/dist/index.d.ts.map +1 -1
  169. package/dist/index.js +11 -0
  170. package/dist/index.js.map +1 -1
  171. package/dist/installer.d.ts.map +1 -1
  172. package/dist/installer.js +77 -30
  173. package/dist/installer.js.map +1 -1
  174. package/dist/installers/mcp-registration-conflict.d.ts +8 -0
  175. package/dist/installers/mcp-registration-conflict.d.ts.map +1 -1
  176. package/dist/installers/mcp-registration-conflict.js +34 -1
  177. package/dist/installers/mcp-registration-conflict.js.map +1 -1
  178. package/dist/installers/workbuddy-host-installer.d.ts +45 -13
  179. package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
  180. package/dist/installers/workbuddy-host-installer.js +284 -21
  181. package/dist/installers/workbuddy-host-installer.js.map +1 -1
  182. package/dist/prompts.d.ts +11 -0
  183. package/dist/prompts.d.ts.map +1 -1
  184. package/dist/prompts.js +4 -0
  185. package/dist/prompts.js.map +1 -1
  186. package/dist/service-host-bridge.d.ts +67 -0
  187. package/dist/service-host-bridge.d.ts.map +1 -0
  188. package/dist/service-host-bridge.js +292 -0
  189. package/dist/service-host-bridge.js.map +1 -0
  190. package/dist/uninstaller.d.ts.map +1 -1
  191. package/dist/uninstaller.js +26 -0
  192. package/dist/uninstaller.js.map +1 -1
  193. package/dist/update/install-layout.d.ts +0 -12
  194. package/dist/update/install-layout.d.ts.map +1 -1
  195. package/dist/update/install-layout.js +42 -15
  196. package/dist/update/install-layout.js.map +1 -1
  197. package/host-runtime/dist/diagnostician-auto-run.js +4 -1
  198. package/host-runtime/dist/governance-observation-store.d.ts +7 -0
  199. package/host-runtime/dist/governance-observation-store.js +15 -4
  200. package/host-runtime/dist/governance-signal-admission.d.ts +49 -0
  201. package/host-runtime/dist/governance-signal-admission.js +355 -94
  202. package/host-runtime/dist/governance-trajectory-turn-reader.d.ts +20 -4
  203. package/host-runtime/dist/governance-trajectory-turn-reader.js +77 -5
  204. package/host-runtime/dist/index.d.ts +2 -0
  205. package/host-runtime/dist/index.js +5 -0
  206. package/host-runtime/dist/internalization-consumer-cycle.js +4 -1
  207. package/host-runtime/dist/pd-config.d.ts +10 -0
  208. package/host-runtime/dist/pd-config.js +37 -0
  209. package/host-runtime/dist/signal-stage2-cycle.js +28 -1
  210. package/host-runtime/dist/source-material-authorization.d.ts +53 -0
  211. package/host-runtime/dist/source-material-authorization.js +67 -0
  212. package/host-runtime/dist/source-revocation-sweep.d.ts +172 -0
  213. package/host-runtime/dist/source-revocation-sweep.js +928 -0
  214. package/host-runtime/package.json +5 -1
  215. package/install-layout/dist/background-execution-transition.d.ts +258 -0
  216. package/install-layout/dist/background-execution-transition.js +836 -0
  217. package/install-layout/dist/index.d.ts +8 -0
  218. package/install-layout/dist/index.js +8 -0
  219. package/install-layout/package.json +6 -2
  220. package/package.json +7 -6
  221. package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
  222. package/pd-cli/dist/commands/candidate.js +16 -5
  223. package/pd-cli/dist/commands/candidate.js.map +1 -1
  224. package/pd-cli/dist/commands/codex-setup.d.ts.map +1 -1
  225. package/pd-cli/dist/commands/codex-setup.js +17 -1
  226. package/pd-cli/dist/commands/codex-setup.js.map +1 -1
  227. package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
  228. package/pd-cli/dist/commands/codex-worker.js +8 -4
  229. package/pd-cli/dist/commands/codex-worker.js.map +1 -1
  230. package/pd-cli/dist/commands/consent-sweep-revoked.d.ts +20 -0
  231. package/pd-cli/dist/commands/consent-sweep-revoked.d.ts.map +1 -0
  232. package/pd-cli/dist/commands/consent-sweep-revoked.js +85 -0
  233. package/pd-cli/dist/commands/consent-sweep-revoked.js.map +1 -0
  234. package/pd-cli/dist/commands/console.d.ts.map +1 -1
  235. package/pd-cli/dist/commands/console.js +9 -0
  236. package/pd-cli/dist/commands/console.js.map +1 -1
  237. package/pd-cli/dist/commands/context.d.ts.map +1 -1
  238. package/pd-cli/dist/commands/context.js +9 -1
  239. package/pd-cli/dist/commands/context.js.map +1 -1
  240. package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
  241. package/pd-cli/dist/commands/diagnose.js +12 -6
  242. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  243. package/pd-cli/dist/commands/health-console.d.ts +1 -1
  244. package/pd-cli/dist/commands/health-console.d.ts.map +1 -1
  245. package/pd-cli/dist/commands/health-console.js +15 -1
  246. package/pd-cli/dist/commands/health-console.js.map +1 -1
  247. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  248. package/pd-cli/dist/commands/health.js +7 -1
  249. package/pd-cli/dist/commands/health.js.map +1 -1
  250. package/pd-cli/dist/commands/openclaw-worker.d.ts +11 -0
  251. package/pd-cli/dist/commands/openclaw-worker.d.ts.map +1 -0
  252. package/pd-cli/dist/commands/openclaw-worker.js +199 -0
  253. package/pd-cli/dist/commands/openclaw-worker.js.map +1 -0
  254. package/pd-cli/dist/commands/pain-explicit.d.ts.map +1 -1
  255. package/pd-cli/dist/commands/pain-explicit.js +1 -0
  256. package/pd-cli/dist/commands/pain-explicit.js.map +1 -1
  257. package/pd-cli/dist/commands/pain-recall.d.ts +2 -2
  258. package/pd-cli/dist/commands/pain-recall.d.ts.map +1 -1
  259. package/pd-cli/dist/commands/pain-recall.js +7 -1
  260. package/pd-cli/dist/commands/pain-recall.js.map +1 -1
  261. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  262. package/pd-cli/dist/commands/pain-retry.js +12 -6
  263. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  264. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
  265. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +2 -1
  266. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
  267. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts +1 -0
  268. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  269. package/pd-cli/dist/commands/runtime-internalization-run-once.js +32 -8
  270. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  271. package/pd-cli/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -1
  272. package/pd-cli/dist/commands/runtime-internalization-wake-once.js +2 -1
  273. package/pd-cli/dist/commands/runtime-internalization-wake-once.js.map +1 -1
  274. package/pd-cli/dist/commands/service-handover.d.ts +12 -0
  275. package/pd-cli/dist/commands/service-handover.d.ts.map +1 -0
  276. package/pd-cli/dist/commands/service-handover.js +117 -0
  277. package/pd-cli/dist/commands/service-handover.js.map +1 -0
  278. package/pd-cli/dist/commands/service-lifecycle.d.ts +31 -0
  279. package/pd-cli/dist/commands/service-lifecycle.d.ts.map +1 -0
  280. package/pd-cli/dist/commands/service-lifecycle.js +207 -0
  281. package/pd-cli/dist/commands/service-lifecycle.js.map +1 -0
  282. package/pd-cli/dist/commands/service-run-once.d.ts +96 -0
  283. package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -1
  284. package/pd-cli/dist/commands/service-run-once.js +432 -13
  285. package/pd-cli/dist/commands/service-run-once.js.map +1 -1
  286. package/pd-cli/dist/commands/workbuddy-setup.d.ts.map +1 -1
  287. package/pd-cli/dist/commands/workbuddy-setup.js +22 -2
  288. package/pd-cli/dist/commands/workbuddy-setup.js.map +1 -1
  289. package/pd-cli/dist/program.d.ts.map +1 -1
  290. package/pd-cli/dist/program.js +167 -9
  291. package/pd-cli/dist/program.js.map +1 -1
  292. package/pd-cli/dist/services/admission-write-gate.d.ts +3 -1
  293. package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -1
  294. package/pd-cli/dist/services/admission-write-gate.js +1 -0
  295. package/pd-cli/dist/services/admission-write-gate.js.map +1 -1
  296. package/pd-cli/dist/services/console-launcher.d.ts +93 -1
  297. package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
  298. package/pd-cli/dist/services/console-launcher.js +375 -10
  299. package/pd-cli/dist/services/console-launcher.js.map +1 -1
  300. package/pd-cli/dist/services/service-host/coordinator-common.d.ts +49 -0
  301. package/pd-cli/dist/services/service-host/coordinator-common.d.ts.map +1 -0
  302. package/pd-cli/dist/services/service-host/coordinator-common.js +158 -0
  303. package/pd-cli/dist/services/service-host/coordinator-common.js.map +1 -0
  304. package/pd-cli/dist/services/service-host/handover-claims.d.ts +14 -0
  305. package/pd-cli/dist/services/service-host/handover-claims.d.ts.map +1 -0
  306. package/pd-cli/dist/services/service-host/handover-claims.js +50 -0
  307. package/pd-cli/dist/services/service-host/handover-claims.js.map +1 -0
  308. package/pd-cli/dist/services/service-host/index.d.ts +19 -3
  309. package/pd-cli/dist/services/service-host/index.d.ts.map +1 -1
  310. package/pd-cli/dist/services/service-host/index.js +21 -3
  311. package/pd-cli/dist/services/service-host/index.js.map +1 -1
  312. package/pd-cli/dist/services/service-host/install-identity.d.ts +23 -3
  313. package/pd-cli/dist/services/service-host/install-identity.d.ts.map +1 -1
  314. package/pd-cli/dist/services/service-host/install-identity.js +15 -5
  315. package/pd-cli/dist/services/service-host/install-identity.js.map +1 -1
  316. package/pd-cli/dist/services/service-host/locking/service-run-lock.d.ts +130 -9
  317. package/pd-cli/dist/services/service-host/locking/service-run-lock.d.ts.map +1 -1
  318. package/pd-cli/dist/services/service-host/locking/service-run-lock.js +99 -19
  319. package/pd-cli/dist/services/service-host/locking/service-run-lock.js.map +1 -1
  320. package/pd-cli/dist/services/service-host/managed-run.d.ts +75 -0
  321. package/pd-cli/dist/services/service-host/managed-run.d.ts.map +1 -0
  322. package/pd-cli/dist/services/service-host/managed-run.js +550 -0
  323. package/pd-cli/dist/services/service-host/managed-run.js.map +1 -0
  324. package/pd-cli/dist/services/service-host/progress-evidence.d.ts +38 -0
  325. package/pd-cli/dist/services/service-host/progress-evidence.d.ts.map +1 -0
  326. package/pd-cli/dist/services/service-host/progress-evidence.js +155 -0
  327. package/pd-cli/dist/services/service-host/progress-evidence.js.map +1 -0
  328. package/pd-cli/dist/services/service-host/run-once.d.ts.map +1 -1
  329. package/pd-cli/dist/services/service-host/run-once.js +4 -136
  330. package/pd-cli/dist/services/service-host/run-once.js.map +1 -1
  331. package/pd-cli/dist/services/service-host/scheduler/contract.d.ts +184 -0
  332. package/pd-cli/dist/services/service-host/scheduler/contract.d.ts.map +1 -0
  333. package/pd-cli/dist/services/service-host/scheduler/contract.js +86 -0
  334. package/pd-cli/dist/services/service-host/scheduler/contract.js.map +1 -0
  335. package/pd-cli/dist/services/service-host/scheduler/index.d.ts +76 -0
  336. package/pd-cli/dist/services/service-host/scheduler/index.d.ts.map +1 -0
  337. package/pd-cli/dist/services/service-host/scheduler/index.js +128 -0
  338. package/pd-cli/dist/services/service-host/scheduler/index.js.map +1 -0
  339. package/pd-cli/dist/services/service-host/scheduler/linux.d.ts +27 -0
  340. package/pd-cli/dist/services/service-host/scheduler/linux.d.ts.map +1 -0
  341. package/pd-cli/dist/services/service-host/scheduler/linux.js +1010 -0
  342. package/pd-cli/dist/services/service-host/scheduler/linux.js.map +1 -0
  343. package/pd-cli/dist/services/service-host/scheduler/macos.d.ts +13 -0
  344. package/pd-cli/dist/services/service-host/scheduler/macos.d.ts.map +1 -0
  345. package/pd-cli/dist/services/service-host/scheduler/macos.js +819 -0
  346. package/pd-cli/dist/services/service-host/scheduler/macos.js.map +1 -0
  347. package/pd-cli/dist/services/service-host/scheduler/runtime-io.d.ts +13 -0
  348. package/pd-cli/dist/services/service-host/scheduler/runtime-io.d.ts.map +1 -0
  349. package/pd-cli/dist/services/service-host/scheduler/runtime-io.js +141 -0
  350. package/pd-cli/dist/services/service-host/scheduler/runtime-io.js.map +1 -0
  351. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts +99 -0
  352. package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts.map +1 -0
  353. package/pd-cli/dist/services/service-host/scheduler/service-status.js +202 -0
  354. package/pd-cli/dist/services/service-host/scheduler/service-status.js.map +1 -0
  355. package/pd-cli/dist/services/service-host/scheduler/windows.d.ts +40 -0
  356. package/pd-cli/dist/services/service-host/scheduler/windows.d.ts.map +1 -0
  357. package/pd-cli/dist/services/service-host/scheduler/windows.js +688 -0
  358. package/pd-cli/dist/services/service-host/scheduler/windows.js.map +1 -0
  359. package/pd-cli/dist/services/service-host/shadow-progress-store.d.ts +43 -0
  360. package/pd-cli/dist/services/service-host/shadow-progress-store.d.ts.map +1 -0
  361. package/pd-cli/dist/services/service-host/shadow-progress-store.js +156 -0
  362. package/pd-cli/dist/services/service-host/shadow-progress-store.js.map +1 -0
  363. package/pd-cli/dist/services/service-host/shadow-run.d.ts +87 -0
  364. package/pd-cli/dist/services/service-host/shadow-run.d.ts.map +1 -0
  365. package/pd-cli/dist/services/service-host/shadow-run.js +549 -0
  366. package/pd-cli/dist/services/service-host/shadow-run.js.map +1 -0
  367. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +114 -4
  368. package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -1
  369. package/pd-cli/dist/services/service-host/status/service-run-status.js +37 -0
  370. package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -1
  371. package/pd-cli/dist/services/service-host/worker-adapter-codex.d.ts +2 -0
  372. package/pd-cli/dist/services/service-host/worker-adapter-codex.d.ts.map +1 -0
  373. package/pd-cli/dist/services/service-host/worker-adapter-codex.js +76 -0
  374. package/pd-cli/dist/services/service-host/worker-adapter-codex.js.map +1 -0
  375. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.d.ts +2 -0
  376. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.d.ts.map +1 -0
  377. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js +49 -0
  378. package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js.map +1 -0
  379. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.d.ts +2 -0
  380. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.d.ts.map +1 -0
  381. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.js +36 -0
  382. package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.js.map +1 -0
  383. package/pd-cli/dist/services/service-host/worker-adapter.d.ts +187 -0
  384. package/pd-cli/dist/services/service-host/worker-adapter.d.ts.map +1 -0
  385. package/pd-cli/dist/services/service-host/worker-adapter.js +609 -0
  386. package/pd-cli/dist/services/service-host/worker-adapter.js.map +1 -0
  387. package/pd-cli/dist/services/service-host/worker-env.d.ts +84 -0
  388. package/pd-cli/dist/services/service-host/worker-env.d.ts.map +1 -0
  389. package/pd-cli/dist/services/service-host/worker-env.js +195 -0
  390. package/pd-cli/dist/services/service-host/worker-env.js.map +1 -0
  391. package/pd-cli/dist/services/service-host/worker-process.d.ts +75 -0
  392. package/pd-cli/dist/services/service-host/worker-process.d.ts.map +1 -0
  393. package/pd-cli/dist/services/service-host/worker-process.js +225 -0
  394. package/pd-cli/dist/services/service-host/worker-process.js.map +1 -0
  395. package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts +61 -0
  396. package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts.map +1 -0
  397. package/pd-cli/dist/services/service-host/workspace-dispatch.js +105 -0
  398. package/pd-cli/dist/services/service-host/workspace-dispatch.js.map +1 -0
  399. package/pd-cli/dist/services/service-host/workspace-handover.d.ts +190 -0
  400. package/pd-cli/dist/services/service-host/workspace-handover.d.ts.map +1 -0
  401. package/pd-cli/dist/services/service-host/workspace-handover.js +1393 -0
  402. package/pd-cli/dist/services/service-host/workspace-handover.js.map +1 -0
  403. package/pd-cli/package.json +6 -5
  404. package/pd-mcp-server/dist/submit-assembly.js +159 -42
  405. package/pd-mcp-server/dist/version.d.ts +1 -1
  406. package/pd-mcp-server/dist/version.js +1 -1
  407. package/pd-mcp-server/package.json +1 -1
  408. package/plugin/dist/bundle.js +662 -637
  409. package/plugin/dist/openclaw-worker.d.ts +92 -0
  410. package/plugin/dist/openclaw-worker.js +2446 -0
  411. package/plugin/dist/openclaw.plugin.json +1 -1
  412. package/plugin/dist/service/gateway-consumer-lease.d.ts +142 -0
  413. package/plugin/dist/service/gateway-quiesce-ack.d.ts +40 -0
  414. package/plugin/dist/service/internalization-auto-consumer-service.d.ts +68 -1
  415. package/plugin/openclaw.plugin.json +1 -1
  416. package/plugin/package.json +5 -1
  417. package/release-manager/dist/installer.js +77 -30
  418. package/release-manager/dist/installers/mcp-registration-conflict.js +34 -1
  419. package/release-manager/dist/installers/workbuddy-host-installer.js +284 -21
  420. package/release-manager/dist/service-host-bridge.js +292 -0
  421. package/release-manager/dist/update/install-layout.js +42 -15
  422. package/release-manager/package.json +5 -4
  423. package/workbuddy-adapter/dist/index.d.ts +1 -1
  424. package/workbuddy-adapter/dist/index.js +1 -1
  425. package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +7 -0
  426. package/workbuddy-adapter/dist/worker/workspace-worker.js +179 -10
  427. package/workbuddy-adapter/package.json +1 -1
  428. package/workbuddy-adapter/plugin/.codebuddy-plugin/plugin.json +2 -2
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Worker-subprocess environment construction (TD §5.2, SPEC §10.4).
3
+ *
4
+ * The Service Host NEVER inherits-then-patches the parent environment for a
5
+ * Worker child: the child env is BUILT from an explicit allowlist, with
6
+ * identity-bearing variables pinned from the trusted `InstallIdentity` and
7
+ * every workspace/host pointer explicitly dropped. A polluted parent
8
+ * environment therefore cannot redirect the production Workspace, the PD
9
+ * home, or the host roots (AC-11 / task §7 pollution matrix).
10
+ *
11
+ * Three variable classes:
12
+ *
13
+ * 1. NEVER PASSED (dropped even when set): `PD_EXPERIMENT_ROOT`,
14
+ * `PD_WORKSPACE_DIR`, `OPENCLAW_STATE_DIR` / `OPENCLAW_HOME`,
15
+ * `PD_COMPANION_WORKER_IPC` (Companion-private IPC), `PD_INVOCATION_SOURCE`
16
+ * (pinned to `service_host` below), and `HOME` / `USERPROFILE` /
17
+ * `CODEX_HOME` / `WORKBUDDY_CONFIG_DIR` (pinned from trusted identity).
18
+ * 2. ALLOWLISTED passthrough: OS basics the Node runtime itself needs
19
+ * (`PATH`, `SYSTEMROOT`, …) and credential variables. Credentials ride
20
+ * the Worker's existing `getEnvVar` resolution chain — they are secrets
21
+ * for providers, never workspace pointers — so they match a name PATTERN
22
+ * (`*_API_KEY`, `*_TOKEN`, `*_SECRET`, …), not a hand-maintained list of
23
+ * provider names. Values are passed through, never logged.
24
+ * 3. PINNED from trusted identity: `HOME`/`USERPROFILE` (the OS account
25
+ * home the coordinator resolved), `CODEX_HOME` (codex worker) or
26
+ * `WORKBUDDY_CONFIG_DIR` (workbuddy worker) — the canonical trusted host
27
+ * roots — and `PD_INVOCATION_SOURCE=service_host` (the Phase 2 driver
28
+ * identity; without it `pd <host> worker --status` stall attribution
29
+ * would misreport service-driven cycles).
30
+ */
31
+ import type { InstallIdentity } from './install-identity.js';
32
+ import type { WorkerHostKind } from './worker-adapter.js';
33
+ /**
34
+ * Runtime-launch steering variables (R1 review fix): these are read by the
35
+ * Node runtime / its loaders BEFORE the Worker entry executes, so a name in
36
+ * this set can never be re-admitted — not by the system allowlist, not by
37
+ * the generic credential pattern, and NOT by a workspace-config-declared
38
+ * `apiKeyEnv`. An admitted-workspace config can name its own credential
39
+ * variables; it cannot use that channel to inject launch settings the
40
+ * isolation boundary exists to keep out (`NODE_OPTIONS --require`, TLS
41
+ * trust weakening, OpenSSL engine configs, native-library preload).
42
+ * Exported so the config-name collector (worker-adapter.ts) refuses the
43
+ * same names at collection time — one deny-list, two checkpoints.
44
+ */
45
+ export declare const LAUNCH_CONTROL_ENV_VARS: readonly ['NODE_OPTIONS', 'NODE_PATH', 'NODE_EXTRA_CA_CERTS', 'NODE_REPL_HISTORY', 'NODE_REPL_EXTERNAL_MODULE', 'NODE_TLS_REJECT_UNAUTHORIZED', 'NODE_NO_WARNINGS', 'NODE_PENDING_DEPRECATION', 'NODE_DEBUG', 'NODE_DEBUG_NATIVE', 'NODE_DISABLE_COLORS', 'NODE_REDIRECT_WARNINGS', 'NODE_PRESERVE_SYMLINKS', 'NODE_PRESERVE_SYMLINKS_MAIN', 'NODE_COMPILE_CACHE', 'NODE_COMPILE_CACHE_DIR', 'NODE_USE_ENV_PROXY', 'NODE_USE_LARGE_PAGES', 'NODE_SNAPSHOT_SAVE', 'NODE_SNAPSHOT_BLOB', 'NODE_V8_COVERAGE', 'UV_THREADPOOL_SIZE', 'UV_USE_IO_URING', 'OPENSSL_CONF', 'OPENSSL_MODULES', 'SSL_CERT_FILE', 'SSL_CERT_DIR', 'LD_PRELOAD', 'LD_LIBRARY_PATH', 'DYLD_INSERT_LIBRARIES', 'DYLD_LIBRARY_PATH'];
46
+ export interface WorkerEnvironmentReport {
47
+ /** Pointer/identity variables that WERE set in the inherited env and were dropped. */
48
+ readonly stripped: readonly string[];
49
+ /** Variables pinned from the trusted install identity (names only). */
50
+ readonly pinnedFromTrustedIdentity: readonly string[];
51
+ /** Allowlist names actually passed through (names only, never values). */
52
+ readonly passedThrough: readonly string[];
53
+ /** Always 'service_host' — the Phase 2 driver identity. */
54
+ readonly invocationSource: 'service_host';
55
+ /** The coordinator-scoped invocation id passed as PD_INVOCATION_ID (F13). */
56
+ readonly invocationId?: string;
57
+ }
58
+ export interface WorkerEnvironment {
59
+ readonly env: Record<string, string | undefined>;
60
+ readonly report: WorkerEnvironmentReport;
61
+ }
62
+ /**
63
+ * Build the Worker child environment from the allowlist. Pure: same inputs →
64
+ * same outputs; the only trusted inputs are `identity` (resolved by the
65
+ * coordinator's own identity authority) and the explicit `hostKind`.
66
+ */
67
+ export declare function buildWorkerEnvironment(args: {
68
+ identity: InstallIdentity;
69
+ hostKind: WorkerHostKind;
70
+ inheritedEnv: Readonly<Record<string, string | undefined>>;
71
+ platform?: string;
72
+ /**
73
+ * Credential variable NAMES the target workspace's effective runtime
74
+ * config actually uses (`apiKeyEnv` values, F4 review fix). A name that
75
+ * does not match the generic credential PATTERN still passes through so
76
+ * custom-named env credentials keep working (the worker's
77
+ * `resolveProviderApiKey` chain reads them by that exact name). Pointer
78
+ * variables are rejected FIRST — the allowlist can never re-admit one.
79
+ */
80
+ credentialEnvAllowlist?: readonly string[];
81
+ /** Coordinator-scoped invocation id, passed to the child (F13, TD §5.2). */
82
+ invocationId?: string;
83
+ }): WorkerEnvironment;
84
+ //# sourceMappingURL=worker-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-env.d.ts","sourceRoot":"","sources":["../../../src/services/service-host/worker-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAiB1D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,YAClC,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,2BAA2B,EAC3B,8BAA8B,EAC9B,kBAAkB,EAClB,0BA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E,MAAM,CAAC;CACvB,GAAG,iBAAiB,CA6EpB"}
@@ -0,0 +1,195 @@
1
+ /** Every variable that can steer identity/workspace/host-root resolution. */
2
+ const POINTER_ENV_VARS = [
3
+ 'PD_EXPERIMENT_ROOT',
4
+ 'PD_WORKSPACE_DIR',
5
+ 'OPENCLAW_STATE_DIR',
6
+ 'OPENCLAW_HOME',
7
+ 'PD_COMPANION_WORKER_IPC',
8
+ 'PD_INVOCATION_SOURCE',
9
+ 'PD_SERVICE_PD_HOME',
10
+ 'HOME',
11
+ 'USERPROFILE',
12
+ 'CODEX_HOME',
13
+ 'WORKBUDDY_CONFIG_DIR',
14
+ ];
15
+ /**
16
+ * Runtime-launch steering variables (R1 review fix): these are read by the
17
+ * Node runtime / its loaders BEFORE the Worker entry executes, so a name in
18
+ * this set can never be re-admitted — not by the system allowlist, not by
19
+ * the generic credential pattern, and NOT by a workspace-config-declared
20
+ * `apiKeyEnv`. An admitted-workspace config can name its own credential
21
+ * variables; it cannot use that channel to inject launch settings the
22
+ * isolation boundary exists to keep out (`NODE_OPTIONS --require`, TLS
23
+ * trust weakening, OpenSSL engine configs, native-library preload).
24
+ * Exported so the config-name collector (worker-adapter.ts) refuses the
25
+ * same names at collection time — one deny-list, two checkpoints.
26
+ */
27
+ export const LAUNCH_CONTROL_ENV_VARS = [
28
+ 'NODE_OPTIONS',
29
+ 'NODE_PATH',
30
+ 'NODE_EXTRA_CA_CERTS',
31
+ 'NODE_REPL_HISTORY',
32
+ 'NODE_REPL_EXTERNAL_MODULE',
33
+ 'NODE_TLS_REJECT_UNAUTHORIZED',
34
+ 'NODE_NO_WARNINGS',
35
+ 'NODE_PENDING_DEPRECATION',
36
+ 'NODE_DEBUG',
37
+ 'NODE_DEBUG_NATIVE',
38
+ 'NODE_DISABLE_COLORS',
39
+ 'NODE_REDIRECT_WARNINGS',
40
+ 'NODE_PRESERVE_SYMLINKS',
41
+ 'NODE_PRESERVE_SYMLINKS_MAIN',
42
+ 'NODE_COMPILE_CACHE',
43
+ 'NODE_COMPILE_CACHE_DIR',
44
+ 'NODE_USE_ENV_PROXY',
45
+ 'NODE_USE_LARGE_PAGES',
46
+ 'NODE_SNAPSHOT_SAVE',
47
+ 'NODE_SNAPSHOT_BLOB',
48
+ 'NODE_V8_COVERAGE',
49
+ 'UV_THREADPOOL_SIZE',
50
+ 'UV_USE_IO_URING',
51
+ 'OPENSSL_CONF',
52
+ 'OPENSSL_MODULES',
53
+ 'SSL_CERT_FILE',
54
+ 'SSL_CERT_DIR',
55
+ 'LD_PRELOAD',
56
+ 'LD_LIBRARY_PATH',
57
+ 'DYLD_INSERT_LIBRARIES',
58
+ 'DYLD_LIBRARY_PATH',
59
+ ];
60
+ /** OS basics allowed through verbatim (values are not secrets). */
61
+ const SYSTEM_ALLOWLIST_COMMON = ['PATH'];
62
+ const SYSTEM_ALLOWLIST_WIN32 = [
63
+ 'SYSTEMROOT',
64
+ 'SYSTEMDRIVE',
65
+ 'COMSPEC',
66
+ 'PATHEXT',
67
+ 'WINDIR',
68
+ 'TEMP',
69
+ 'TMP',
70
+ 'PROGRAMDATA',
71
+ 'OS',
72
+ 'NUMBER_OF_PROCESSORS',
73
+ 'PROCESSOR_ARCHITECTURE',
74
+ 'PROCESSOR_IDENTIFIER',
75
+ 'PROCESSOR_LEVEL',
76
+ 'PROCESSOR_REVISION',
77
+ ];
78
+ const SYSTEM_ALLOWLIST_POSIX = [
79
+ 'LANG',
80
+ 'LC_ALL',
81
+ 'LC_CTYPE',
82
+ 'LC_NUMERIC',
83
+ 'LC_TIME',
84
+ 'LC_COLLATE',
85
+ 'LC_MONETARY',
86
+ 'LC_MESSAGES',
87
+ 'TZ',
88
+ 'TMPDIR',
89
+ ];
90
+ /** Proxy variables (outbound provider calls may require them). */
91
+ const PROXY_ALLOWLIST = ['HTTP_PROXY', 'HTTPS_PROXY', 'ALL_PROXY', 'NO_PROXY'];
92
+ /**
93
+ * Credential-name pattern (case-insensitive on the UPPER-cased name):
94
+ * `<prefix>_API_KEY`, `<prefix>_TOKEN`, `*_SECRET`, `*_PASSWORD`,
95
+ * `*_PASSPHRASE`, `*_CREDENTIAL(S)`, `*_KEY(_…)`, e.g. OPENAI_API_KEY,
96
+ * ANTHROPIC_API_KEY, GITHUB_TOKEN, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN.
97
+ * Matched names pass through; matching is on the NAME only — no value is
98
+ * inspected, recorded or logged.
99
+ */
100
+ const CREDENTIAL_NAME_RE = /^(?:[A-Z0-9][A-Z0-9_]*_)?(?:API_?KEY|KEY|TOKEN|SECRET|PASSWORD|PASSPHRASE|CREDENTIALS?)(?:_[A-Z0-9_]+)?$/;
101
+ function isSet(value) {
102
+ return value !== undefined && value.trim().length > 0;
103
+ }
104
+ /**
105
+ * A credential variable name from the workspace's OWN effective runtime
106
+ * config (`apiKeyEnv`, F4 review fix). Names are validated defensively:
107
+ * env-var-shaped, bounded — and never mistaken for a pointer variable.
108
+ */
109
+ function isCredentialName(name) {
110
+ return /^[A-Za-z_][A-Za-z0-9_]{0,63}$/.test(name);
111
+ }
112
+ /**
113
+ * Build the Worker child environment from the allowlist. Pure: same inputs →
114
+ * same outputs; the only trusted inputs are `identity` (resolved by the
115
+ * coordinator's own identity authority) and the explicit `hostKind`.
116
+ */
117
+ export function buildWorkerEnvironment(args) {
118
+ const platform = args.platform ?? process.platform;
119
+ const caseInsensitive = platform === 'win32';
120
+ const pointerSet = new Set(POINTER_ENV_VARS.map((name) => (caseInsensitive ? name.toUpperCase() : name)));
121
+ const launchControlSet = new Set(LAUNCH_CONTROL_ENV_VARS.map((name) => (caseInsensitive ? name.toUpperCase() : name)));
122
+ const systemNames = [
123
+ ...SYSTEM_ALLOWLIST_COMMON,
124
+ ...(platform === 'win32' ? SYSTEM_ALLOWLIST_WIN32 : SYSTEM_ALLOWLIST_POSIX),
125
+ ...PROXY_ALLOWLIST,
126
+ ];
127
+ const allowSet = new Set(systemNames.map((name) => (caseInsensitive ? name.toUpperCase() : name)));
128
+ const configCredentialSet = new Set((args.credentialEnvAllowlist ?? []).filter((name) => {
129
+ const key = caseInsensitive ? name.toUpperCase() : name;
130
+ return isCredentialName(name) && !pointerSet.has(key) && !launchControlSet.has(key);
131
+ }).map((name) => (caseInsensitive ? name.toUpperCase() : name)));
132
+ const isAllowed = (name) => {
133
+ const key = caseInsensitive ? name.toUpperCase() : name;
134
+ if (pointerSet.has(key))
135
+ return false;
136
+ // Launch-control denial outranks every admission channel — a declared
137
+ // `apiKeyEnv` name can never steer the runtime launch (R1 review fix).
138
+ if (launchControlSet.has(key))
139
+ return false;
140
+ if (allowSet.has(key))
141
+ return true;
142
+ if (configCredentialSet.has(key))
143
+ return true;
144
+ return CREDENTIAL_NAME_RE.test(key);
145
+ };
146
+ const env = {};
147
+ const stripped = [];
148
+ const passedThrough = [];
149
+ for (const [rawName, value] of Object.entries(args.inheritedEnv)) {
150
+ if (!isSet(value))
151
+ continue;
152
+ const key = caseInsensitive ? rawName.toUpperCase() : rawName;
153
+ if (pointerSet.has(key)) {
154
+ stripped.push(key);
155
+ continue;
156
+ }
157
+ if (isAllowed(rawName)) {
158
+ env[rawName] = value;
159
+ passedThrough.push(key);
160
+ }
161
+ // Everything else is silently dropped by design: the child gets exactly
162
+ // what the allowlist admits, nothing inherited wholesale.
163
+ }
164
+ // Identity/host-root pins from the TRUSTED coordinator identity — never the
165
+ // inherited values (a forged CODEX_HOME / HOME cannot survive this boundary).
166
+ env.PD_INVOCATION_SOURCE = 'service_host';
167
+ // The consuming child keys its per-workspace run mutex off THIS pdHome —
168
+ // pinning it keeps the child's lock in the same install the coordinator
169
+ // verified, never an inherited/PD_EXPERIMENT_ROOT-shaped one (PRI-1282).
170
+ env.PD_SERVICE_PD_HOME = args.identity.pdHome;
171
+ env.HOME = args.identity.homeDir;
172
+ env.USERPROFILE = args.identity.homeDir;
173
+ if (args.hostKind === 'codex') {
174
+ env.CODEX_HOME = args.identity.hostRoots.codexHome;
175
+ }
176
+ else {
177
+ env.WORKBUDDY_CONFIG_DIR = args.identity.hostRoots.workbuddyConfigDir;
178
+ }
179
+ const pinned = ['PD_INVOCATION_SOURCE', 'PD_SERVICE_PD_HOME', 'HOME', 'USERPROFILE', args.hostKind === 'codex' ? 'CODEX_HOME' : 'WORKBUDDY_CONFIG_DIR'];
180
+ // F13: the invocation id is coordinator-scoped run metadata, not identity —
181
+ // pinned explicitly so the worker's liveness record can be correlated back
182
+ // to THIS invocation (TD §5.2 显式传入 invocationId).
183
+ let report = {
184
+ stripped: [...new Set(stripped)].sort(),
185
+ pinnedFromTrustedIdentity: pinned,
186
+ passedThrough: [...new Set(passedThrough)].sort(),
187
+ invocationSource: 'service_host',
188
+ };
189
+ if (args.invocationId !== undefined && args.invocationId.length > 0) {
190
+ env.PD_INVOCATION_ID = args.invocationId;
191
+ report = { ...report, invocationId: args.invocationId };
192
+ }
193
+ return { env, report };
194
+ }
195
+ //# sourceMappingURL=worker-env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-env.js","sourceRoot":"","sources":["../../../src/services/service-host/worker-env.ts"],"names":[],"mappings":"AAiCA,6EAA6E;AAC7E,MAAM,gBAAgB,GAAG;IACvB,oBAAoB;IACpB,kBAAkB;IAClB,oBAAoB;IACpB,eAAe;IACf,yBAAyB;IACzB,sBAAsB;IACtB,oBAAoB;IACpB,MAAM;IACN,aAAa;IACb,YAAY;IACZ,sBAAsB;CACd,CAAC;AAEX;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,cAAc;IACd,WAAW;IACX,qBAAqB;IACrB,mBAAmB;IACnB,2BAA2B;IAC3B,8BAA8B;IAC9B,kBAAkB;IAClB,0BAA0B;IAC1B,YAAY;IACZ,mBAAmB;IACnB,qBAAqB;IACrB,wBAAwB;IACxB,wBAAwB;IACxB,6BAA6B;IAC7B,oBAAoB;IACpB,wBAAwB;IACxB,oBAAoB;IACpB,sBAAsB;IACtB,oBAAoB;IACpB,oBAAoB;IACpB,kBAAkB;I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AC,gBAAgB,GAAG,IAAI,CAAC,YAAY,CAAC;QACzC,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACzB,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Bounded Worker-subprocess execution (TD §5.3, SPEC §8.2 step 5).
3
+ *
4
+ * One `pd <host> worker --once --json --workspace <dir>` child, executed with
5
+ * a hard per-workspace deadline and a caller-supplied AbortSignal:
6
+ *
7
+ * deadline / abort → SIGTERM → bounded grace → SIGKILL.
8
+ *
9
+ * The run-once Worker is bounded by construction (it exits after one cycle),
10
+ * so the terminate ladder only fires on hangs; a killed Worker leaves its
11
+ * task lease to the EXISTING Lease TTL / Recovery Sweep — this module never
12
+ * fabricates a success, releases a foreign lease, or writes task state
13
+ * (SPEC §9: at-least-once + existing recovery).
14
+ *
15
+ * Output is bounded: stdout is capped (the `--json --once` contract is one
16
+ * document; a runaway stream is truncated and the parse downstream fails
17
+ * closed), stderr is kept as a bounded tail for diagnostics.
18
+ */
19
+ import { spawn } from 'node:child_process';
20
+ export interface WorkerProcessOptions {
21
+ /** Node executable (default: this process's Node). */
22
+ readonly nodePath?: string;
23
+ /** Absolute CLI entry inside the active release install (never a worktree). */
24
+ readonly cliEntry: string;
25
+ /** CLI arguments after the entry (e.g. ['codex','worker','--once',...]). */
26
+ readonly args: readonly string[];
27
+ /** Pre-built allowlist environment (worker-env.ts). */
28
+ readonly env: Record<string, string | undefined>;
29
+ /** Hard deadline for the whole child, in ms. */
30
+ readonly timeoutMs: number;
31
+ /** Caller cancellation (e.g. CLI interrupt). */
32
+ readonly signal?: AbortSignal;
33
+ /** Grace between SIGTERM and SIGKILL (default 5s). */
34
+ readonly killGraceMs?: number;
35
+ /** stdout cap in bytes (default 8 MiB). */
36
+ readonly maxStdoutBytes?: number;
37
+ /** Test injection for the spawn boundary. */
38
+ readonly spawnFn?: typeof spawn;
39
+ }
40
+ export interface WorkerProcessResult {
41
+ readonly exitCode: number | null;
42
+ readonly termSignal: string | null;
43
+ readonly stdout: string;
44
+ readonly stdoutTruncated: boolean;
45
+ readonly stderrTail: string;
46
+ /** The deadline fired and the ladder ran. */
47
+ readonly timedOut: boolean;
48
+ /** The caller's AbortSignal fired. */
49
+ readonly cancelled: boolean;
50
+ /** Structured spawn failure (ENOENT/EACCES on node or entry) — never a fake exit. */
51
+ readonly spawnError?: string;
52
+ /**
53
+ * The run settled before the child's stdio fully closed: a descendant that
54
+ * inherited our pipes kept them open past the drain deadline. The exit
55
+ * facts above come from the 'exit' event, not 'close' — observability for a
56
+ * cleanup leak, never silently a clean finish (CodeRabbit review fix).
57
+ */
58
+ readonly closePending?: boolean;
59
+ /**
60
+ * P2-05 (final-remediation review): honest termination state. `exit` is
61
+ * the direct child leaving the run state; `close` is all stdio released;
62
+ * `terminationConfirmed` is only true when close was observed — when
63
+ * close is pending we cannot claim the process tree is fully gone.
64
+ */
65
+ readonly exitObserved?: boolean;
66
+ readonly closeObserved?: boolean;
67
+ readonly terminationConfirmed?: boolean;
68
+ readonly durationMs: number;
69
+ }
70
+ /**
71
+ * Execute one bounded Worker child. Never throws for process-level
72
+ * failures — every outcome is a structured result (rc-9).
73
+ */
74
+ export declare function runWorkerProcess(options: WorkerProcessOptions): Promise<WorkerProcessResult>;
75
+ //# sourceMappingURL=worker-process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-process.d.ts","sourceRoot":"","sources":["../../../src/services/service-host/worker-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACnC,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,MA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M,CAAC;CAC7B;AA6BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAuL5F"}
@@ -0,0 +1,225 @@
1
+ /**
2
+ * Bounded Worker-subprocess execution (TD §5.3, SPEC §8.2 step 5).
3
+ *
4
+ * One `pd <host> worker --once --json --workspace <dir>` child, executed with
5
+ * a hard per-workspace deadline and a caller-supplied AbortSignal:
6
+ *
7
+ * deadline / abort → SIGTERM → bounded grace → SIGKILL.
8
+ *
9
+ * The run-once Worker is bounded by construction (it exits after one cycle),
10
+ * so the terminate ladder only fires on hangs; a killed Worker leaves its
11
+ * task lease to the EXISTING Lease TTL / Recovery Sweep — this module never
12
+ * fabricates a success, releases a foreign lease, or writes task state
13
+ * (SPEC §9: at-least-once + existing recovery).
14
+ *
15
+ * Output is bounded: stdout is capped (the `--json --once` contract is one
16
+ * document; a runaway stream is truncated and the parse downstream fails
17
+ * closed), stderr is kept as a bounded tail for diagnostics.
18
+ */
19
+ import { spawn } from 'node:child_process';
20
+ const DEFAULT_KILL_GRACE_MS = 5_000;
21
+ /** Function indirection keeps the abort check un-narrowed across the two checkpoints. */
22
+ function signalAborted(signal) {
23
+ return signal?.aborted === true;
24
+ }
25
+ const DEFAULT_MAX_STDOUT_BYTES = 8 * 1024 * 1024;
26
+ const STDERR_TAIL_BYTES = 16 * 1024;
27
+ /**
28
+ * How long to keep draining stdio after the child 'exit's before settling.
29
+ * A Worker descendant that inherited our stdout/stderr pipes can otherwise
30
+ * keep 'close' pending FOREVER — after SIGKILL the direct child is dead but
31
+ * the coordinator would hang (and never release the install lock) waiting
32
+ * for a close event that never arrives (CodeRabbit review fix).
33
+ */
34
+ const STDIO_DRAIN_DEADLINE_MS = 2_000;
35
+ /**
36
+ * Execute one bounded Worker child. Never throws for process-level
37
+ * failures — every outcome is a structured result (rc-9).
38
+ */
39
+ export function runWorkerProcess(options) {
40
+ const startedAt = Date.now();
41
+ const killGraceMs = options.killGraceMs ?? DEFAULT_KILL_GRACE_MS;
42
+ const maxStdoutBytes = options.maxStdoutBytes ?? DEFAULT_MAX_STDOUT_BYTES;
43
+ const doSpawn = options.spawnFn ?? spawn;
44
+ return new Promise((resolve) => {
45
+ const state = { settled: false, exitCode: null, termSignal: null, timedOut: false, cancelled: false, sawExit: false, sawClose: false };
46
+ // R2 review fix: an already-cancelled signal returns the cancelled
47
+ // outcome BEFORE spawn — otherwise an interrupt delivered between two
48
+ // queued workspaces would still start the next Worker just to kill it.
49
+ if (signalAborted(options.signal)) {
50
+ state.settled = true;
51
+ state.cancelled = true;
52
+ resolve({
53
+ exitCode: null, termSignal: null, stdout: '', stdoutTruncated: false, stderrTail: '',
54
+ timedOut: false, cancelled: true,
55
+ exitObserved: false, closeObserved: false, terminationConfirmed: false,
56
+ durationMs: Date.now() - startedAt,
57
+ });
58
+ return;
59
+ }
60
+ let child;
61
+ try {
62
+ child = doSpawn(options.nodePath ?? process.execPath, [options.cliEntry, ...options.args], {
63
+ env: options.env,
64
+ stdio: ['ignore', 'pipe', 'pipe'],
65
+ windowsHide: true,
66
+ // P2-05: on POSIX the child becomes a process-group leader so the
67
+ // termination ladder can signal the whole group (same-group
68
+ // descendants are killed with their parent). Windows has no
69
+ // process-group signaling — `taskkill /T` equivalents belong to the
70
+ // platform path; there the direct-child SIGKILL plus the stdio drain
71
+ // deadline are what bound the coordinator, and a detached
72
+ // descendant can outlive the run (recorded via closePending).
73
+ detached: process.platform !== 'win32',
74
+ });
75
+ }
76
+ catch (error) {
77
+ const message = error instanceof Error ? error.message : String(error);
78
+ resolve({
79
+ exitCode: null, termSignal: null, stdout: '', stdoutTruncated: false, stderrTail: '',
80
+ timedOut: false, cancelled: false, spawnError: `spawn_threw:${message}`,
81
+ exitObserved: false, closeObserved: false, terminationConfirmed: false,
82
+ durationMs: Date.now() - startedAt,
83
+ });
84
+ return;
85
+ }
86
+ let stdoutBytes = 0;
87
+ let stdoutChunks = [];
88
+ let stdoutTruncated = false;
89
+ let stderrWindow = [];
90
+ let stderrBytes = 0;
91
+ let graceTimer;
92
+ let deadlineTimer;
93
+ let drainTimer;
94
+ let terminated = false;
95
+ // Forward-declared so the terminate ladder and the drain settle can reach
96
+ // each other's helpers without a use-before-define cycle.
97
+ let finish;
98
+ let scheduleDrainSettle;
99
+ /**
100
+ * Signal the child's process GROUP when we lead one (POSIX `detached`),
101
+ * falling back to the direct child — ESRCH/EACCES mean the group is
102
+ * already gone or non-signalable, not a kill failure to fabricate over.
103
+ */
104
+ const signalTree = (sig) => {
105
+ if (process.platform !== 'win32' && child.pid !== undefined) {
106
+ try {
107
+ process.kill(-child.pid, sig);
108
+ return;
109
+ }
110
+ catch {
111
+ // Group already gone — try the direct child anyway.
112
+ }
113
+ }
114
+ try {
115
+ child.kill(sig);
116
+ }
117
+ catch {
118
+ // Already gone — the close handler will settle.
119
+ }
120
+ };
121
+ const terminate = (timedOut, cancelled) => {
122
+ if (terminated || state.settled)
123
+ return;
124
+ terminated = true;
125
+ state.timedOut = timedOut;
126
+ state.cancelled = cancelled;
127
+ signalTree('SIGTERM');
128
+ // Bounded forced termination after the grace window (task §8.5), and
129
+ // then a bounded settle even if 'exit' never arrives at all.
130
+ graceTimer = setTimeout(() => {
131
+ signalTree('SIGKILL');
132
+ scheduleDrainSettle();
133
+ }, killGraceMs);
134
+ };
135
+ const onAbort = () => {
136
+ terminate(false, true);
137
+ };
138
+ scheduleDrainSettle = () => {
139
+ if (drainTimer !== undefined || state.settled)
140
+ return;
141
+ drainTimer = setTimeout(() => finish(), STDIO_DRAIN_DEADLINE_MS);
142
+ };
143
+ finish = () => {
144
+ if (state.settled)
145
+ return;
146
+ state.settled = true;
147
+ if (deadlineTimer !== undefined)
148
+ clearTimeout(deadlineTimer);
149
+ if (graceTimer !== undefined)
150
+ clearTimeout(graceTimer);
151
+ if (drainTimer !== undefined)
152
+ clearTimeout(drainTimer);
153
+ options.signal?.removeEventListener('abort', onAbort);
154
+ resolve({
155
+ exitCode: state.exitCode,
156
+ termSignal: state.termSignal,
157
+ stdout: Buffer.concat(stdoutChunks).toString('utf8'),
158
+ stdoutTruncated,
159
+ stderrTail: Buffer.concat(stderrWindow).toString('utf8'),
160
+ timedOut: state.timedOut,
161
+ cancelled: state.cancelled,
162
+ ...(state.spawnError !== undefined ? { spawnError: state.spawnError } : {}),
163
+ ...(state.sawClose === false ? { closePending: true } : {}),
164
+ // P2-05: report the observed facts, never an inferred "tree dead".
165
+ exitObserved: state.sawExit,
166
+ closeObserved: state.sawClose,
167
+ terminationConfirmed: state.sawClose,
168
+ durationMs: Date.now() - startedAt,
169
+ });
170
+ // Settled without 'close': release our pipe ends so a leaked
171
+ // descendant cannot keep fd handles (and this process) alive.
172
+ child.stdout?.destroy();
173
+ child.stderr?.destroy();
174
+ };
175
+ child.on('error', (error) => {
176
+ state.spawnError = `spawn_error:${error.code ?? error.message}`;
177
+ finish();
178
+ });
179
+ child.stdout?.on('data', (chunk) => {
180
+ if (stdoutBytes + chunk.length > maxStdoutBytes) {
181
+ const remaining = maxStdoutBytes - stdoutBytes;
182
+ if (remaining > 0)
183
+ stdoutChunks.push(chunk.subarray(0, remaining));
184
+ stdoutBytes = maxStdoutBytes;
185
+ stdoutTruncated = true;
186
+ return;
187
+ }
188
+ stdoutBytes += chunk.length;
189
+ stdoutChunks.push(chunk);
190
+ });
191
+ child.stderr?.on('data', (chunk) => {
192
+ stderrWindow.push(chunk);
193
+ stderrBytes += chunk.length;
194
+ while (stderrBytes > STDERR_TAIL_BYTES && stderrWindow.length > 1) {
195
+ stderrBytes -= stderrWindow[0]?.length ?? 0;
196
+ stderrWindow.shift();
197
+ }
198
+ });
199
+ // 'exit' fires on process termination; 'close' additionally waits for
200
+ // the piped stdio to close — which a leaked descendant can delay forever.
201
+ // Capture the exit facts immediately and bound the remaining drain.
202
+ child.on('exit', (code, signal) => {
203
+ state.exitCode = code;
204
+ state.termSignal = signal;
205
+ state.sawExit = true;
206
+ scheduleDrainSettle();
207
+ });
208
+ child.on('close', (code, signal) => {
209
+ state.exitCode = code;
210
+ state.termSignal = signal;
211
+ state.sawClose = true;
212
+ finish();
213
+ });
214
+ if (options.timeoutMs > 0) {
215
+ deadlineTimer = setTimeout(() => terminate(true, false), options.timeoutMs);
216
+ }
217
+ if (signalAborted(options.signal)) {
218
+ terminate(false, true);
219
+ }
220
+ else {
221
+ options.signal?.addEventListener('abort', onAbort, { once: true });
222
+ }
223
+ });
224
+ }
225
+ //# sourceMappingURL=worker-process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-process.js","sourceRoot":"","sources":["../../../src/services/service-host/worker-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAqD9D,MAAM,qBAAqB,GAAG,KAAK,CAAC;AACpC,yFAAyF;AACzF,SAAS,aAAa,CAAC,MAA+B;IACpD,OAAO,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;AAClC,CAAC;AAED,MAAM,wBAAwB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACjD,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,CAAC;AACpC;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAatC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA6B;IAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,qBAAqB,CAAC;IACjE,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,wBAAwB,CAAC;IAC1E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;IAEzC,OAAO,IAAI,OAAO,CAAsB,CAAC,OAAO,EAAE,EAAE;QAClD,MAAM,KAAK,GAAa,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,E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