create-principles-disciple 1.121.8 → 1.121.10

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 (462) hide show
  1. package/README.md +13 -1
  2. package/console/dist/server/config/pd-config-store.d.ts +1 -3
  3. package/console/dist/server/config/pd-config-store.js +4 -4
  4. package/console/dist/server/feedback/channels.d.ts +2 -8
  5. package/console/dist/server/feedback/channels.js +0 -11
  6. package/console/dist/server/index.js +34 -5
  7. package/console/dist/server/models/ActivationsConsoleModel.d.ts +28 -1
  8. package/console/dist/server/models/ActivationsConsoleModel.js +72 -30
  9. package/console/dist/server/models/GovernanceExperienceCollector.d.ts +28 -0
  10. package/console/dist/server/models/GovernanceExperienceCollector.js +305 -0
  11. package/console/dist/server/models/GovernanceProjectionCollector.d.ts +60 -2
  12. package/console/dist/server/models/GovernanceProjectionCollector.js +323 -285
  13. package/console/dist/server/models/PrincipleClassifier.d.ts +1 -1
  14. package/console/dist/server/models/PrincipleClassifier.js +7 -4
  15. package/console/dist/server/models/PrinciplesConsoleModel.d.ts +2 -1
  16. package/console/dist/server/models/ReceiptsConsoleModel.d.ts +5 -0
  17. package/console/dist/server/models/ReceiptsConsoleModel.js +140 -13
  18. package/console/dist/server/routes/activations.js +1 -1
  19. package/console/dist/server/routes/failed-tasks.js +28 -11
  20. package/console/dist/server/routes/governance.d.ts +26 -0
  21. package/console/dist/server/routes/governance.js +51 -0
  22. package/console/dist/server/routes/owner-identity.d.ts +31 -0
  23. package/console/dist/server/routes/owner-identity.js +76 -0
  24. package/console/dist/server/routes/update-history.d.ts +5 -0
  25. package/console/dist/server/routes/update-history.js +50 -4
  26. package/console/dist/server/routes/update.js +263 -41
  27. package/console/dist/server/utils/update-links.d.ts +38 -0
  28. package/console/dist/server/utils/update-links.js +71 -0
  29. package/console/dist/shared/feedback-channel-ids.d.ts +13 -0
  30. package/console/dist/shared/feedback-channel-ids.js +12 -0
  31. package/console/dist/shared/feedback-contract.d.ts +46 -0
  32. package/console/dist/shared/feedback-contract.js +45 -0
  33. package/console/dist/ui/App.js +1 -1
  34. package/console/dist/ui/api.d.ts +22 -3
  35. package/console/dist/ui/api.js +63 -3
  36. package/console/dist/ui/components/receipts/ReceiptCoverageDisclosure.d.ts +6 -0
  37. package/console/dist/ui/components/receipts/ReceiptCoverageDisclosure.js +66 -0
  38. package/console/dist/ui/i18n/en.json +198 -2
  39. package/console/dist/ui/i18n/zh-CN.json +196 -0
  40. package/console/dist/ui/pages/activation/ActivationPage.js +14 -2
  41. package/console/dist/ui/pages/failed-tasks/FailedTasksPage.js +25 -5
  42. package/console/dist/ui/pages/focus/FocusPage.d.ts +28 -1
  43. package/console/dist/ui/pages/focus/FocusPage.js +128 -15
  44. package/console/dist/ui/pages/principles/PrincipleDetailPage.d.ts +30 -0
  45. package/console/dist/ui/pages/principles/PrincipleDetailPage.js +49 -6
  46. package/console/dist/ui/pages/settings/SettingsPage.js +67 -2
  47. package/console/dist/ui/pages/settings/UpdatePage.js +7 -7
  48. package/console/dist/ui/utils/enum-labels.js +0 -1
  49. package/console/dist/ui/utils/validators.d.ts +53 -21
  50. package/console/dist/ui/utils/validators.js +248 -21
  51. package/console/dist/web/assets/app.css +6 -0
  52. package/console/dist/web/assets/app.js +2721 -1664
  53. package/console/package.json +3 -1
  54. package/core/dist/host/host-adapter.d.ts +1 -1
  55. package/core/dist/host/host-adapter.d.ts.map +1 -1
  56. package/core/dist/host/host-adapter.js +1 -0
  57. package/core/dist/host/host-adapter.js.map +1 -1
  58. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +12 -2
  59. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  60. package/core/dist/runtime-v2/__tests__/attack-e2e-pipeline-smoke.test.js +1 -1
  61. package/core/dist/runtime-v2/__tests__/attack-e2e-pipeline-smoke.test.js.map +1 -1
  62. package/core/dist/runtime-v2/__tests__/governance-experience.test.d.ts +2 -0
  63. package/core/dist/runtime-v2/__tests__/governance-experience.test.d.ts.map +1 -0
  64. package/core/dist/runtime-v2/__tests__/governance-experience.test.js +300 -0
  65. package/core/dist/runtime-v2/__tests__/governance-experience.test.js.map +1 -0
  66. package/core/dist/runtime-v2/__tests__/owner-identity.test.d.ts +2 -0
  67. package/core/dist/runtime-v2/__tests__/owner-identity.test.d.ts.map +1 -0
  68. package/core/dist/runtime-v2/__tests__/owner-identity.test.js +147 -0
  69. package/core/dist/runtime-v2/__tests__/owner-identity.test.js.map +1 -0
  70. package/core/dist/runtime-v2/__tests__/product-telemetry-contract.test.d.ts +18 -0
  71. package/core/dist/runtime-v2/__tests__/product-telemetry-contract.test.d.ts.map +1 -0
  72. package/core/dist/runtime-v2/__tests__/product-telemetry-contract.test.js +303 -0
  73. package/core/dist/runtime-v2/__tests__/product-telemetry-contract.test.js.map +1 -0
  74. package/core/dist/runtime-v2/__tests__/recovery-actions-log.test.js +40 -0
  75. package/core/dist/runtime-v2/__tests__/recovery-actions-log.test.js.map +1 -1
  76. package/core/dist/runtime-v2/__tests__/status-contract.test.d.ts +2 -0
  77. package/core/dist/runtime-v2/__tests__/status-contract.test.d.ts.map +1 -0
  78. package/core/dist/runtime-v2/__tests__/status-contract.test.js +107 -0
  79. package/core/dist/runtime-v2/__tests__/status-contract.test.js.map +1 -0
  80. package/core/dist/runtime-v2/activation/__tests__/promotion-evidence-snapshot.test.d.ts +2 -0
  81. package/core/dist/runtime-v2/activation/__tests__/promotion-evidence-snapshot.test.d.ts.map +1 -0
  82. package/core/dist/runtime-v2/activation/__tests__/promotion-evidence-snapshot.test.js +104 -0
  83. package/core/dist/runtime-v2/activation/__tests__/promotion-evidence-snapshot.test.js.map +1 -0
  84. package/core/dist/runtime-v2/activation/__tests__/promotion-readiness-evaluator.test.js +19 -0
  85. package/core/dist/runtime-v2/activation/__tests__/promotion-readiness-evaluator.test.js.map +1 -1
  86. package/core/dist/runtime-v2/activation/__tests__/rulecode-owner-decision-service.test.js +20 -0
  87. package/core/dist/runtime-v2/activation/__tests__/rulecode-owner-decision-service.test.js.map +1 -1
  88. package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-safety-store.test.js +40 -0
  89. package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-safety-store.test.js.map +1 -1
  90. package/core/dist/runtime-v2/activation/index.d.ts +2 -0
  91. package/core/dist/runtime-v2/activation/index.d.ts.map +1 -1
  92. package/core/dist/runtime-v2/activation/index.js +1 -0
  93. package/core/dist/runtime-v2/activation/index.js.map +1 -1
  94. package/core/dist/runtime-v2/activation/promotion-evidence-snapshot.d.ts +30 -0
  95. package/core/dist/runtime-v2/activation/promotion-evidence-snapshot.d.ts.map +1 -0
  96. package/core/dist/runtime-v2/activation/promotion-evidence-snapshot.js +87 -0
  97. package/core/dist/runtime-v2/activation/promotion-evidence-snapshot.js.map +1 -0
  98. package/core/dist/runtime-v2/activation/promotion-readiness-evaluator.d.ts.map +1 -1
  99. package/core/dist/runtime-v2/activation/promotion-readiness-evaluator.js +3 -0
  100. package/core/dist/runtime-v2/activation/promotion-readiness-evaluator.js.map +1 -1
  101. package/core/dist/runtime-v2/activation/promotion-readiness-reader.d.ts +1 -1
  102. package/core/dist/runtime-v2/activation/promotion-readiness-reader.d.ts.map +1 -1
  103. package/core/dist/runtime-v2/activation/promotion-readiness-reader.js +2 -2
  104. package/core/dist/runtime-v2/activation/promotion-readiness-reader.js.map +1 -1
  105. package/core/dist/runtime-v2/activation/rulecode-owner-decision-service.d.ts.map +1 -1
  106. package/core/dist/runtime-v2/activation/rulecode-owner-decision-service.js +18 -9
  107. package/core/dist/runtime-v2/activation/rulecode-owner-decision-service.js.map +1 -1
  108. package/core/dist/runtime-v2/adapter/__tests__/chaos-json-repair.test.js +1 -1
  109. package/core/dist/runtime-v2/adapter/__tests__/chaos-json-repair.test.js.map +1 -1
  110. package/core/dist/runtime-v2/adapter/__tests__/json-extractor.test.js +91 -1
  111. package/core/dist/runtime-v2/adapter/__tests__/json-extractor.test.js.map +1 -1
  112. package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js +59 -12
  113. package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js.map +1 -1
  114. package/core/dist/runtime-v2/adapter/__tests__/runtime-config-contract.test.js +10 -9
  115. package/core/dist/runtime-v2/adapter/__tests__/runtime-config-contract.test.js.map +1 -1
  116. package/core/dist/runtime-v2/adapter/__tests__/structured-output-repair.test.js +42 -1
  117. package/core/dist/runtime-v2/adapter/__tests__/structured-output-repair.test.js.map +1 -1
  118. package/core/dist/runtime-v2/adapter/json-extractor.d.ts +25 -0
  119. package/core/dist/runtime-v2/adapter/json-extractor.d.ts.map +1 -1
  120. package/core/dist/runtime-v2/adapter/json-extractor.js +126 -0
  121. package/core/dist/runtime-v2/adapter/json-extractor.js.map +1 -1
  122. package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.d.ts +9 -4
  123. package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.d.ts.map +1 -1
  124. package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.js +9 -4
  125. package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.js.map +1 -1
  126. package/core/dist/runtime-v2/adapter/output-repair-contract.d.ts +5 -1
  127. package/core/dist/runtime-v2/adapter/output-repair-contract.d.ts.map +1 -1
  128. package/core/dist/runtime-v2/adapter/output-repair-contract.js +4 -1
  129. package/core/dist/runtime-v2/adapter/output-repair-contract.js.map +1 -1
  130. package/core/dist/runtime-v2/adapter/pi-ai-catalog.d.ts +7 -0
  131. package/core/dist/runtime-v2/adapter/pi-ai-catalog.d.ts.map +1 -0
  132. package/core/dist/runtime-v2/adapter/pi-ai-catalog.js +19 -0
  133. package/core/dist/runtime-v2/adapter/pi-ai-catalog.js.map +1 -0
  134. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts +13 -15
  135. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  136. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +104 -37
  137. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
  138. package/core/dist/runtime-v2/adapter/structured-output-repair.d.ts +16 -1
  139. package/core/dist/runtime-v2/adapter/structured-output-repair.d.ts.map +1 -1
  140. package/core/dist/runtime-v2/adapter/structured-output-repair.js +38 -6
  141. package/core/dist/runtime-v2/adapter/structured-output-repair.js.map +1 -1
  142. package/core/dist/runtime-v2/adapter/tools/diagnostician-tool.d.ts +1 -1
  143. package/core/dist/runtime-v2/adapter/tools/diagnostician-tool.d.ts.map +1 -1
  144. package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js +8 -9
  145. package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js.map +1 -1
  146. package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +27 -3
  147. package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
  148. package/core/dist/runtime-v2/config/__tests__/pd-config-principles.test.d.ts +11 -0
  149. package/core/dist/runtime-v2/config/__tests__/pd-config-principles.test.d.ts.map +1 -0
  150. package/core/dist/runtime-v2/config/__tests__/pd-config-principles.test.js +93 -0
  151. package/core/dist/runtime-v2/config/__tests__/pd-config-principles.test.js.map +1 -0
  152. package/core/dist/runtime-v2/config/__tests__/pd-config-workspace.test.js +41 -0
  153. package/core/dist/runtime-v2/config/__tests__/pd-config-workspace.test.js.map +1 -1
  154. package/core/dist/runtime-v2/config/index.d.ts +2 -2
  155. package/core/dist/runtime-v2/config/index.d.ts.map +1 -1
  156. package/core/dist/runtime-v2/config/index.js +2 -0
  157. package/core/dist/runtime-v2/config/index.js.map +1 -1
  158. package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts.map +1 -1
  159. package/core/dist/runtime-v2/config/pd-config-agent-binding.js +4 -13
  160. package/core/dist/runtime-v2/config/pd-config-agent-binding.js.map +1 -1
  161. package/core/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
  162. package/core/dist/runtime-v2/config/pd-config-effective.js +14 -7
  163. package/core/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
  164. package/core/dist/runtime-v2/config/pd-config-feature-flags.d.ts.map +1 -1
  165. package/core/dist/runtime-v2/config/pd-config-feature-flags.js +5 -12
  166. package/core/dist/runtime-v2/config/pd-config-feature-flags.js.map +1 -1
  167. package/core/dist/runtime-v2/config/pd-config-types.d.ts +8 -0
  168. package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  169. package/core/dist/runtime-v2/config/pd-config-types.js +2 -0
  170. package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  171. package/core/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
  172. package/core/dist/runtime-v2/config/pd-config-validate.js +48 -3
  173. package/core/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
  174. package/core/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.js +36 -8
  175. package/core/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.js.map +1 -1
  176. package/core/dist/runtime-v2/core-principles/__tests__/core-principle-registry.test.js +36 -12
  177. package/core/dist/runtime-v2/core-principles/__tests__/core-principle-registry.test.js.map +1 -1
  178. package/core/dist/runtime-v2/core-principles/core-axiom-block.d.ts +22 -8
  179. package/core/dist/runtime-v2/core-principles/core-axiom-block.d.ts.map +1 -1
  180. package/core/dist/runtime-v2/core-principles/core-axiom-block.js +28 -13
  181. package/core/dist/runtime-v2/core-principles/core-axiom-block.js.map +1 -1
  182. package/core/dist/runtime-v2/core-principles/core-principle-registry.d.ts +29 -4
  183. package/core/dist/runtime-v2/core-principles/core-principle-registry.d.ts.map +1 -1
  184. package/core/dist/runtime-v2/core-principles/core-principle-registry.js +68 -33
  185. package/core/dist/runtime-v2/core-principles/core-principle-registry.js.map +1 -1
  186. package/core/dist/runtime-v2/core-principles/index.d.ts +3 -3
  187. package/core/dist/runtime-v2/core-principles/index.d.ts.map +1 -1
  188. package/core/dist/runtime-v2/core-principles/index.js +1 -1
  189. package/core/dist/runtime-v2/core-principles/index.js.map +1 -1
  190. package/core/dist/runtime-v2/evolution/evolution-types.d.ts +2 -1
  191. package/core/dist/runtime-v2/evolution/evolution-types.d.ts.map +1 -1
  192. package/core/dist/runtime-v2/evolution/evolution-types.js.map +1 -1
  193. package/core/dist/runtime-v2/feature-flags/__tests__/anonymous-product-telemetry-flag.test.d.ts +2 -0
  194. package/core/dist/runtime-v2/feature-flags/__tests__/anonymous-product-telemetry-flag.test.d.ts.map +1 -0
  195. package/core/dist/runtime-v2/feature-flags/__tests__/anonymous-product-telemetry-flag.test.js +48 -0
  196. package/core/dist/runtime-v2/feature-flags/__tests__/anonymous-product-telemetry-flag.test.js.map +1 -0
  197. package/core/dist/runtime-v2/feature-flags/__tests__/codex-conversation-ingestion-flag.test.d.ts +2 -0
  198. package/core/dist/runtime-v2/feature-flags/__tests__/codex-conversation-ingestion-flag.test.d.ts.map +1 -0
  199. package/core/dist/runtime-v2/feature-flags/__tests__/codex-conversation-ingestion-flag.test.js +46 -0
  200. package/core/dist/runtime-v2/feature-flags/__tests__/codex-conversation-ingestion-flag.test.js.map +1 -0
  201. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +86 -31
  202. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
  203. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-lifecycle.test.d.ts +2 -0
  204. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-lifecycle.test.d.ts.map +1 -0
  205. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-lifecycle.test.js +83 -0
  206. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-lifecycle.test.js.map +1 -0
  207. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts +19 -1
  208. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  209. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +128 -10
  210. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  211. package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.d.ts +37 -0
  212. package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.d.ts.map +1 -0
  213. package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.js +304 -0
  214. package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.js.map +1 -0
  215. package/core/dist/runtime-v2/feature-flags/index.d.ts +4 -2
  216. package/core/dist/runtime-v2/feature-flags/index.d.ts.map +1 -1
  217. package/core/dist/runtime-v2/feature-flags/index.js +3 -1
  218. package/core/dist/runtime-v2/feature-flags/index.js.map +1 -1
  219. package/core/dist/runtime-v2/governance-experience-contract.d.ts +468 -0
  220. package/core/dist/runtime-v2/governance-experience-contract.d.ts.map +1 -0
  221. package/core/dist/runtime-v2/governance-experience-contract.js +208 -0
  222. package/core/dist/runtime-v2/governance-experience-contract.js.map +1 -0
  223. package/core/dist/runtime-v2/governance-experience.d.ts +11 -0
  224. package/core/dist/runtime-v2/governance-experience.d.ts.map +1 -0
  225. package/core/dist/runtime-v2/governance-experience.js +276 -0
  226. package/core/dist/runtime-v2/governance-experience.js.map +1 -0
  227. package/core/dist/runtime-v2/index.d.ts +20 -8
  228. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  229. package/core/dist/runtime-v2/index.js +20 -6
  230. package/core/dist/runtime-v2/index.js.map +1 -1
  231. package/core/dist/runtime-v2/internalization/__tests__/artificer-output-retry-flag.test.js +29 -10
  232. package/core/dist/runtime-v2/internalization/__tests__/artificer-output-retry-flag.test.js.map +1 -1
  233. package/core/dist/runtime-v2/owner-identity.d.ts +69 -0
  234. package/core/dist/runtime-v2/owner-identity.d.ts.map +1 -0
  235. package/core/dist/runtime-v2/owner-identity.js +179 -0
  236. package/core/dist/runtime-v2/owner-identity.js.map +1 -0
  237. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
  238. package/core/dist/runtime-v2/pain-signal-runtime-factory.js +2 -3
  239. package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
  240. package/core/dist/runtime-v2/product-telemetry/daily-identity.d.ts +70 -0
  241. package/core/dist/runtime-v2/product-telemetry/daily-identity.d.ts.map +1 -0
  242. package/core/dist/runtime-v2/product-telemetry/daily-identity.js +89 -0
  243. package/core/dist/runtime-v2/product-telemetry/daily-identity.js.map +1 -0
  244. package/core/dist/runtime-v2/product-telemetry/snapshot-contract.d.ts +110 -0
  245. package/core/dist/runtime-v2/product-telemetry/snapshot-contract.d.ts.map +1 -0
  246. package/core/dist/runtime-v2/product-telemetry/snapshot-contract.js +250 -0
  247. package/core/dist/runtime-v2/product-telemetry/snapshot-contract.js.map +1 -0
  248. package/core/dist/runtime-v2/pruning-read-model.d.ts +2 -1
  249. package/core/dist/runtime-v2/pruning-read-model.d.ts.map +1 -1
  250. package/core/dist/runtime-v2/pruning-read-model.js.map +1 -1
  251. package/core/dist/runtime-v2/receipt-coverage.d.ts +63 -0
  252. package/core/dist/runtime-v2/receipt-coverage.d.ts.map +1 -0
  253. package/core/dist/runtime-v2/receipt-coverage.js +19 -0
  254. package/core/dist/runtime-v2/receipt-coverage.js.map +1 -0
  255. package/core/dist/runtime-v2/recovery-actions-log.d.ts +7 -0
  256. package/core/dist/runtime-v2/recovery-actions-log.d.ts.map +1 -1
  257. package/core/dist/runtime-v2/recovery-actions-log.js +6 -0
  258. package/core/dist/runtime-v2/recovery-actions-log.js.map +1 -1
  259. package/core/dist/runtime-v2/runtime-protocol.js +1 -1
  260. package/core/dist/runtime-v2/runtime-protocol.js.map +1 -1
  261. package/core/dist/runtime-v2/store/task/__tests__/sqlite-task-store.failed-tasks.test.js +17 -1
  262. package/core/dist/runtime-v2/store/task/__tests__/sqlite-task-store.failed-tasks.test.js.map +1 -1
  263. package/core/dist/runtime-v2/store/task/sqlite-task-store.d.ts.map +1 -1
  264. package/core/dist/runtime-v2/store/task/sqlite-task-store.js +10 -0
  265. package/core/dist/runtime-v2/store/task/sqlite-task-store.js.map +1 -1
  266. package/core/dist/runtime-v2/store/task/task-types.d.ts +2 -0
  267. package/core/dist/runtime-v2/store/task/task-types.d.ts.map +1 -1
  268. package/core/dist/runtime-v2/task-status.d.ts +9 -5
  269. package/core/dist/runtime-v2/task-status.d.ts.map +1 -1
  270. package/core/dist/runtime-v2/task-status.js +15 -7
  271. package/core/dist/runtime-v2/task-status.js.map +1 -1
  272. package/core/dist/runtime-v2/types/event-types.d.ts +4 -0
  273. package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
  274. package/core/dist/runtime-v2/types/event-types.js.map +1 -1
  275. package/core/dist/runtime-v2/types/index.d.ts +1 -1
  276. package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
  277. package/core/dist/runtime-v2/types/index.js +1 -1
  278. package/core/dist/runtime-v2/types/index.js.map +1 -1
  279. package/core/dist/runtime-v2/types/principle-enums.d.ts +3 -2
  280. package/core/dist/runtime-v2/types/principle-enums.d.ts.map +1 -1
  281. package/core/dist/runtime-v2/types/principle-enums.js +11 -5
  282. package/core/dist/runtime-v2/types/principle-enums.js.map +1 -1
  283. package/core/dist/runtime-v2/types/principle-schema.d.ts +1 -1
  284. package/core/dist/runtime-v2/types/principle-tree-store.d.ts +1 -1
  285. package/core/dist/runtime-v2/utils/cli-process-runner.d.ts.map +1 -1
  286. package/core/dist/runtime-v2/utils/cli-process-runner.js +3 -2
  287. package/core/dist/runtime-v2/utils/cli-process-runner.js.map +1 -1
  288. package/core/package.json +1 -2
  289. package/dist/i18n.d.ts.map +1 -1
  290. package/dist/i18n.js +4 -2
  291. package/dist/i18n.js.map +1 -1
  292. package/dist/index.d.ts +2 -0
  293. package/dist/index.d.ts.map +1 -1
  294. package/dist/index.js +47 -11
  295. package/dist/index.js.map +1 -1
  296. package/dist/installer.d.ts +31 -5
  297. package/dist/installer.d.ts.map +1 -1
  298. package/dist/installer.js +472 -161
  299. package/dist/installer.js.map +1 -1
  300. package/dist/installers/codex-host-installer.d.ts.map +1 -1
  301. package/dist/installers/codex-host-installer.js +4 -0
  302. package/dist/installers/codex-host-installer.js.map +1 -1
  303. package/dist/mvp-config.d.ts +10 -0
  304. package/dist/mvp-config.d.ts.map +1 -1
  305. package/dist/mvp-config.js +30 -3
  306. package/dist/mvp-config.js.map +1 -1
  307. package/dist/uninstaller.d.ts +9 -1
  308. package/dist/uninstaller.d.ts.map +1 -1
  309. package/dist/uninstaller.js +103 -23
  310. package/dist/uninstaller.js.map +1 -1
  311. package/dist/update/atomic-file.d.ts +35 -0
  312. package/dist/update/atomic-file.d.ts.map +1 -0
  313. package/dist/update/atomic-file.js +120 -0
  314. package/dist/update/atomic-file.js.map +1 -0
  315. package/dist/update/bootstrap-protocol.d.ts +55 -0
  316. package/dist/update/bootstrap-protocol.d.ts.map +1 -0
  317. package/dist/update/bootstrap-protocol.js +132 -0
  318. package/dist/update/bootstrap-protocol.js.map +1 -0
  319. package/dist/update/channel-metadata.d.ts +28 -0
  320. package/dist/update/channel-metadata.d.ts.map +1 -0
  321. package/dist/update/channel-metadata.js +90 -0
  322. package/dist/update/channel-metadata.js.map +1 -0
  323. package/dist/update/channel-promotion.d.ts +39 -0
  324. package/dist/update/channel-promotion.d.ts.map +1 -0
  325. package/dist/update/channel-promotion.js +55 -0
  326. package/dist/update/channel-promotion.js.map +1 -0
  327. package/dist/update/data-compatibility.d.ts +35 -0
  328. package/dist/update/data-compatibility.d.ts.map +1 -0
  329. package/dist/update/data-compatibility.js +45 -0
  330. package/dist/update/data-compatibility.js.map +1 -0
  331. package/dist/update/install-layout.d.ts +59 -0
  332. package/dist/update/install-layout.d.ts.map +1 -0
  333. package/dist/update/install-layout.js +127 -0
  334. package/dist/update/install-layout.js.map +1 -0
  335. package/dist/update/legacy-migration.d.ts +56 -0
  336. package/dist/update/legacy-migration.d.ts.map +1 -0
  337. package/dist/update/legacy-migration.js +254 -0
  338. package/dist/update/legacy-migration.js.map +1 -0
  339. package/dist/update/product-identity.d.ts +50 -0
  340. package/dist/update/product-identity.d.ts.map +1 -0
  341. package/dist/update/product-identity.js +63 -0
  342. package/dist/update/product-identity.js.map +1 -0
  343. package/dist/update/release-asset-manifest.d.ts +31 -0
  344. package/dist/update/release-asset-manifest.d.ts.map +1 -0
  345. package/dist/update/release-asset-manifest.js +161 -0
  346. package/dist/update/release-asset-manifest.js.map +1 -0
  347. package/dist/update/release-identity.d.ts +33 -0
  348. package/dist/update/release-identity.d.ts.map +1 -0
  349. package/dist/update/release-identity.js +108 -0
  350. package/dist/update/release-identity.js.map +1 -0
  351. package/dist/update/release-manager.d.ts +96 -0
  352. package/dist/update/release-manager.d.ts.map +1 -0
  353. package/dist/update/release-manager.js +253 -0
  354. package/dist/update/release-manager.js.map +1 -0
  355. package/dist/update/release-metadata.d.ts +57 -0
  356. package/dist/update/release-metadata.d.ts.map +1 -0
  357. package/dist/update/release-metadata.js +200 -0
  358. package/dist/update/release-metadata.js.map +1 -0
  359. package/dist/update/release-policy.d.ts +51 -0
  360. package/dist/update/release-policy.d.ts.map +1 -0
  361. package/dist/update/release-policy.js +103 -0
  362. package/dist/update/release-policy.js.map +1 -0
  363. package/dist/update/rollback-policy.d.ts +56 -0
  364. package/dist/update/rollback-policy.d.ts.map +1 -0
  365. package/dist/update/rollback-policy.js +61 -0
  366. package/dist/update/rollback-policy.js.map +1 -0
  367. package/dist/update/transaction-journal.d.ts +121 -0
  368. package/dist/update/transaction-journal.d.ts.map +1 -0
  369. package/dist/update/transaction-journal.js +333 -0
  370. package/dist/update/transaction-journal.js.map +1 -0
  371. package/dist/update/trust-metadata.d.ts +55 -0
  372. package/dist/update/trust-metadata.d.ts.map +1 -0
  373. package/dist/update/trust-metadata.js +170 -0
  374. package/dist/update/trust-metadata.js.map +1 -0
  375. package/dist/update/update-history.d.ts +46 -0
  376. package/dist/update/update-history.d.ts.map +1 -0
  377. package/dist/update/update-history.js +123 -0
  378. package/dist/update/update-history.js.map +1 -0
  379. package/dist/utils/env.d.ts +7 -0
  380. package/dist/utils/env.d.ts.map +1 -1
  381. package/dist/utils/env.js +134 -44
  382. package/dist/utils/env.js.map +1 -1
  383. package/host-runtime/dist/governance-observation-store.d.ts +172 -0
  384. package/host-runtime/dist/governance-observation-store.js +649 -0
  385. package/host-runtime/dist/index.d.ts +6 -0
  386. package/host-runtime/dist/index.js +8 -0
  387. package/host-runtime/dist/product-telemetry/consent-store.d.ts +107 -0
  388. package/host-runtime/dist/product-telemetry/consent-store.js +329 -0
  389. package/host-runtime/dist/product-telemetry/eligibility.d.ts +53 -0
  390. package/host-runtime/dist/product-telemetry/eligibility.js +69 -0
  391. package/host-runtime/dist/product-telemetry/exporter.d.ts +46 -0
  392. package/host-runtime/dist/product-telemetry/exporter.js +71 -0
  393. package/host-runtime/dist/product-telemetry/milestone-readers.d.ts +61 -0
  394. package/host-runtime/dist/product-telemetry/milestone-readers.js +234 -0
  395. package/host-runtime/dist/product-telemetry/service.d.ts +142 -0
  396. package/host-runtime/dist/product-telemetry/service.js +532 -0
  397. package/host-runtime/dist/product-telemetry/workspace-scope.d.ts +38 -0
  398. package/host-runtime/dist/product-telemetry/workspace-scope.js +64 -0
  399. package/host-runtime/package.json +5 -0
  400. package/install-layout/dist/index.d.ts +48 -0
  401. package/install-layout/dist/index.js +81 -0
  402. package/install-layout/dist/index.test.d.ts +1 -0
  403. package/install-layout/dist/index.test.js +34 -0
  404. package/install-layout/package.json +29 -0
  405. package/package.json +16 -6
  406. package/pd-cli/dist/commands/__tests__/telemetry-flag-wiring.test.d.ts +9 -0
  407. package/pd-cli/dist/commands/__tests__/telemetry-flag-wiring.test.d.ts.map +1 -0
  408. package/pd-cli/dist/commands/__tests__/telemetry-flag-wiring.test.js +76 -0
  409. package/pd-cli/dist/commands/__tests__/telemetry-flag-wiring.test.js.map +1 -0
  410. package/pd-cli/dist/commands/__tests__/version.test.d.ts +2 -0
  411. package/pd-cli/dist/commands/__tests__/version.test.d.ts.map +1 -0
  412. package/pd-cli/dist/commands/__tests__/version.test.js +134 -0
  413. package/pd-cli/dist/commands/__tests__/version.test.js.map +1 -0
  414. package/pd-cli/dist/commands/console.d.ts.map +1 -1
  415. package/pd-cli/dist/commands/console.js +29 -10
  416. package/pd-cli/dist/commands/console.js.map +1 -1
  417. package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
  418. package/pd-cli/dist/commands/pain-record.js +6 -15
  419. package/pd-cli/dist/commands/pain-record.js.map +1 -1
  420. package/pd-cli/dist/commands/runtime-activation.d.ts +29 -0
  421. package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
  422. package/pd-cli/dist/commands/runtime-activation.js +70 -31
  423. package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
  424. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
  425. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +2 -2
  426. package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
  427. package/pd-cli/dist/commands/telemetry.d.ts +82 -0
  428. package/pd-cli/dist/commands/telemetry.d.ts.map +1 -0
  429. package/pd-cli/dist/commands/telemetry.js +268 -0
  430. package/pd-cli/dist/commands/telemetry.js.map +1 -0
  431. package/pd-cli/dist/commands/version.d.ts +11 -0
  432. package/pd-cli/dist/commands/version.d.ts.map +1 -0
  433. package/pd-cli/dist/commands/version.js +48 -0
  434. package/pd-cli/dist/commands/version.js.map +1 -0
  435. package/pd-cli/dist/index.js +35 -2
  436. package/pd-cli/dist/index.js.map +1 -1
  437. package/pd-cli/dist/services/version-report.d.ts +44 -0
  438. package/pd-cli/dist/services/version-report.d.ts.map +1 -0
  439. package/pd-cli/dist/services/version-report.js +152 -0
  440. package/pd-cli/dist/services/version-report.js.map +1 -0
  441. package/pd-cli/package.json +1 -0
  442. package/plugin/dist/bundle.js +868 -936
  443. package/plugin/dist/core/init.d.ts +2 -1
  444. package/plugin/dist/core/principle-application-ledger.d.ts +10 -0
  445. package/plugin/dist/core/product-telemetry-trigger.d.ts +14 -0
  446. package/plugin/dist/core/thinking-os-parser.d.ts +5 -2
  447. package/plugin/dist/governance-audit.js +386 -0
  448. package/plugin/dist/hooks/gate-block-helper.d.ts +25 -1
  449. package/plugin/dist/hooks/gate.d.ts +22 -0
  450. package/plugin/dist/rulehost-evidence.js +832 -0
  451. package/plugin/dist/templates/langs/en/principles/THINKING_OS.md +53 -45
  452. package/plugin/dist/templates/langs/en/skills/pd-mentor/SKILL.md +1 -1
  453. package/plugin/dist/templates/langs/zh/principles/THINKING_OS.md +62 -46
  454. package/plugin/dist/templates/langs/zh/skills/pd-mentor/SKILL.md +1 -1
  455. package/plugin/dist/templates/workspace/.principles/THINKING_OS.md +66 -38
  456. package/plugin/openclaw.plugin.json +1 -1
  457. package/plugin/package.json +1 -1
  458. package/plugin/templates/langs/en/principles/THINKING_OS.md +53 -45
  459. package/plugin/templates/langs/en/skills/pd-mentor/SKILL.md +1 -1
  460. package/plugin/templates/langs/zh/principles/THINKING_OS.md +62 -46
  461. package/plugin/templates/langs/zh/skills/pd-mentor/SKILL.md +1 -1
  462. package/plugin/templates/workspace/.principles/THINKING_OS.md +66 -38
@@ -0,0 +1,76 @@
1
+ import { resolveOwnerIdentity, readOwnerIdentityFile, writeOwnerIdentityFile, deleteOwnerIdentityFile, } from '@principles/core/runtime-v2';
2
+ import { sendSuccess, sendError, sendBadRequest, sendMethodNotAllowed } from '../utils/response.js';
3
+ import { resolveOwnerConfigSnapshot } from './governance.js';
4
+ const MAX_BODY_SIZE = 16 * 1024;
5
+ async function readJson(req) {
6
+ const chunks = [];
7
+ let totalSize = 0;
8
+ for await (const chunk of req) {
9
+ const buf = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
10
+ totalSize += buf.length;
11
+ if (totalSize > MAX_BODY_SIZE)
12
+ throw new Error('payload_too_large');
13
+ chunks.push(buf);
14
+ }
15
+ return JSON.parse(Buffer.concat(chunks).toString('utf-8'));
16
+ }
17
+ /* eslint-disable @typescript-eslint/max-params */
18
+ export async function handleOwnerIdentityRoute(req, res, homeDir, subPath, authConfig) {
19
+ if (subPath !== '' && subPath !== '/') {
20
+ sendError(res, 404, 'not_found', 'Unknown owner identity endpoint.', { nextAction: 'Use GET / POST / DELETE /api/v1/owner-identity.' });
21
+ return;
22
+ }
23
+ const method = req.method ?? 'GET';
24
+ if (method === 'GET') {
25
+ const file = readOwnerIdentityFile(homeDir);
26
+ const resolved = resolveOwnerIdentity(process.env, homeDir);
27
+ const view = {
28
+ resolved,
29
+ fileRecord: file.record,
30
+ ...(file.error === undefined ? {} : { fileError: file.error }),
31
+ governance: resolveOwnerConfigSnapshot(authConfig, resolved),
32
+ };
33
+ sendSuccess(res, view);
34
+ return;
35
+ }
36
+ if (method === 'POST') {
37
+ let body;
38
+ try {
39
+ body = await readJson(req);
40
+ }
41
+ catch {
42
+ sendBadRequest(res, 'Invalid JSON body or payload too large.');
43
+ return;
44
+ }
45
+ const value = body;
46
+ const ownerId = typeof value?.ownerId === 'string' ? value.ownerId : '';
47
+ const credentialId = typeof value?.credentialId === 'string' ? value.credentialId : '';
48
+ const result = writeOwnerIdentityFile(homeDir, { ownerId, credentialId });
49
+ if (!result.ok) {
50
+ sendBadRequest(res, result.error);
51
+ return;
52
+ }
53
+ const resolved = resolveOwnerIdentity(process.env, homeDir);
54
+ sendSuccess(res, {
55
+ record: result.record,
56
+ source: 'file',
57
+ governance: resolveOwnerConfigSnapshot(authConfig, resolved),
58
+ });
59
+ return;
60
+ }
61
+ if (method === 'DELETE') {
62
+ const result = deleteOwnerIdentityFile(homeDir);
63
+ if (!result.ok) {
64
+ sendError(res, 500, 'owner_identity_delete_failed', result.error);
65
+ return;
66
+ }
67
+ const resolved = resolveOwnerIdentity(process.env, homeDir);
68
+ sendSuccess(res, {
69
+ ok: true,
70
+ source: 'none',
71
+ governance: resolveOwnerConfigSnapshot(authConfig, resolved),
72
+ });
73
+ return;
74
+ }
75
+ sendMethodNotAllowed(res);
76
+ }
@@ -1,11 +1,16 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ export declare const UPDATE_HISTORY_KINDS: readonly ['update', 'reinstall', 'legacy_migration', 'rollback', 'refusal', 'failure', 'recovery', 'unknown'];
3
+ export type UpdateHistoryKind = (typeof UPDATE_HISTORY_KINDS)[number];
2
4
  interface UpdateHistoryEntry {
3
5
  id: string;
4
6
  timestamp: string;
5
7
  fromVersion: string;
6
8
  toVersion: string;
7
9
  success: boolean;
10
+ kind: UpdateHistoryKind;
8
11
  backupPath?: string;
12
+ reason?: string;
13
+ nextAction?: string;
9
14
  }
10
15
  export declare function appendUpdateHistory(workspaceDir: string, entry: Omit<UpdateHistoryEntry, 'id' | 'timestamp'>): void;
11
16
  export declare function handleUpdateHistoryRoute(req: IncomingMessage, res: ServerResponse, workspaceDir: string, _subPath: string): Promise<void>;
@@ -1,6 +1,52 @@
1
1
  import * as fs from 'fs';
2
2
  import * as path from 'path';
3
3
  import { sendSuccess, sendMethodNotAllowed } from '../utils/response.js';
4
+ export const UPDATE_HISTORY_KINDS = [
5
+ 'update',
6
+ 'reinstall',
7
+ 'legacy_migration',
8
+ 'rollback',
9
+ 'refusal',
10
+ 'failure',
11
+ 'recovery',
12
+ 'unknown',
13
+ ];
14
+ function isHistoryKind(value) {
15
+ return typeof value === 'string' && UPDATE_HISTORY_KINDS.includes(value);
16
+ }
17
+ function parseHistoryEntry(value) {
18
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
19
+ return undefined;
20
+ const raw = value;
21
+ if (typeof raw.id !== 'string' ||
22
+ typeof raw.timestamp !== 'string' ||
23
+ typeof raw.fromVersion !== 'string' ||
24
+ typeof raw.toVersion !== 'string' ||
25
+ typeof raw.success !== 'boolean')
26
+ return undefined;
27
+ if (raw.kind !== undefined && !isHistoryKind(raw.kind))
28
+ return undefined;
29
+ if (raw.reason !== undefined && typeof raw.reason !== 'string')
30
+ return undefined;
31
+ if (raw.nextAction !== undefined && typeof raw.nextAction !== 'string')
32
+ return undefined;
33
+ if (raw.backupPath !== undefined && typeof raw.backupPath !== 'string')
34
+ return undefined;
35
+ return {
36
+ id: raw.id,
37
+ timestamp: raw.timestamp,
38
+ fromVersion: raw.fromVersion,
39
+ toVersion: raw.toVersion,
40
+ success: raw.success,
41
+ // Pre-Phase-0 records did not identify their operation. The operation is
42
+ // UNKNOWN — labeling them legacy_migration would claim a migration
43
+ // happened, which the record cannot prove (unknown ≠ legacy_migration).
44
+ kind: raw.kind === undefined ? 'unknown' : raw.kind,
45
+ ...(typeof raw.backupPath === 'string' ? { backupPath: raw.backupPath } : {}),
46
+ ...(typeof raw.reason === 'string' ? { reason: raw.reason } : {}),
47
+ ...(typeof raw.nextAction === 'string' ? { nextAction: raw.nextAction } : {}),
48
+ };
49
+ }
4
50
  function getHistoryPath(workspaceDir) {
5
51
  return path.join(workspaceDir, '.pd', 'update-history.json');
6
52
  }
@@ -10,10 +56,10 @@ function loadHistory(historyPath) {
10
56
  const raw = fs.readFileSync(historyPath, 'utf-8');
11
57
  const parsed = JSON.parse(raw);
12
58
  if (Array.isArray(parsed)) {
13
- return parsed.filter((e) => typeof e === 'object' && e !== null &&
14
- typeof e.fromVersion === 'string' &&
15
- typeof e.toVersion === 'string' &&
16
- typeof e.success === 'boolean');
59
+ return parsed.flatMap((entry) => {
60
+ const parsedEntry = parseHistoryEntry(entry);
61
+ return parsedEntry === undefined ? [] : [parsedEntry];
62
+ });
17
63
  }
18
64
  }
19
65
  catch (err) {
@@ -8,6 +8,8 @@ import { appendUpdateHistory } from './update-history.js';
8
8
  import { checkOpenClawGateway, stopOpenClawGateway, restartOpenClawGateway, } from '../utils/gateway.js';
9
9
  import { migrateLegacyExtensionBackups, reservePdBackupDestination, resolvePdBackupsRoot, } from '../utils/pd-backups.js';
10
10
  import { ActivationCompatibilityReadModel } from '@principles/core/runtime-v2';
11
+ import { getInstallLayoutPaths, resolveInstallLayout } from '@principles/install-layout';
12
+ import { collectFileDepLinkSpecs } from '../utils/update-links.js';
11
13
  /**
12
14
  * Legacy rule contract preflight (2026-08-19): refuse to swap the runtime
13
15
  * while an ACTIVE owner-approved rule still depends on a RuleHost contract
@@ -68,8 +70,48 @@ function resolveOpenclawHome() {
68
70
  function resolveExtensionsDir() {
69
71
  return path.join(resolveOpenclawHome(), 'extensions');
70
72
  }
73
+ function resolveUpdateLayout() {
74
+ const homeDir = os.homedir();
75
+ const paths = getInstallLayoutPaths(homeDir);
76
+ const legacyPluginDir = path.join(resolveExtensionsDir(), 'principles-disciple');
77
+ let manifest;
78
+ try {
79
+ manifest = JSON.parse(fs.readFileSync(paths.manifest, 'utf8'));
80
+ }
81
+ catch {
82
+ manifest = undefined;
83
+ }
84
+ const resolution = resolveInstallLayout({
85
+ homeDir,
86
+ manifest,
87
+ canonicalRuntimeExists: fs.existsSync(paths.runtimeDir),
88
+ legacyExtensionExists: fs.existsSync(legacyPluginDir),
89
+ });
90
+ if (resolution.mode === 'missing')
91
+ return undefined;
92
+ if (resolution.mode === 'canonical') {
93
+ return {
94
+ pluginDir: paths.pluginDir,
95
+ consoleDir: paths.consoleDir,
96
+ coreDir: paths.coreDir,
97
+ hostRuntimeDir: paths.hostRuntimeDir,
98
+ pdCliDir: paths.pdCliDir,
99
+ installLayoutDir: paths.installLayoutDir,
100
+ hosts: resolution.manifest?.hosts ?? [],
101
+ };
102
+ }
103
+ return {
104
+ pluginDir: legacyPluginDir,
105
+ consoleDir: path.join(legacyPluginDir, 'console'),
106
+ coreDir: path.join(legacyPluginDir, 'core'),
107
+ hostRuntimeDir: path.join(legacyPluginDir, 'host-runtime'),
108
+ pdCliDir: path.join(legacyPluginDir, 'pd-cli'),
109
+ installLayoutDir: path.join(legacyPluginDir, 'install-layout'),
110
+ hosts: ['openclaw'],
111
+ };
112
+ }
71
113
  function resolvePluginDir(_workspaceDir) {
72
- return path.join(resolveExtensionsDir(), 'principles-disciple');
114
+ return resolveUpdateLayout()?.pluginDir ?? path.join(resolveExtensionsDir(), 'principles-disciple');
73
115
  }
74
116
  function readCurrentVersion(pluginDir) {
75
117
  const pkgPath = path.join(pluginDir, 'package.json');
@@ -480,6 +522,26 @@ async function doApplyUpdate(options, workspaceDir) {
480
522
  const toVersion = typeof data.version === 'string' ? data.version : undefined;
481
523
  if (!toVersion)
482
524
  return { success: false, message: 'Missing version in registry response' };
525
+ const advancesInstalled = fromVersion !== 'unknown' &&
526
+ semver.valid(fromVersion) !== null &&
527
+ semver.valid(toVersion) !== null &&
528
+ semver.gt(toVersion, fromVersion);
529
+ if (!advancesInstalled) {
530
+ appendUpdateHistory(workspaceDir, {
531
+ fromVersion,
532
+ toVersion,
533
+ success: false,
534
+ kind: 'refusal',
535
+ reason: 'installer_bundle_stale',
536
+ nextAction: 'Wait for a newer installer release, then retry the update.',
537
+ });
538
+ return {
539
+ success: false,
540
+ message: 'Installed version would not advance — the update source is stale or malformed.',
541
+ reason: 'installer_bundle_stale',
542
+ nextAction: 'Wait for a newer installer release, then retry the update.',
543
+ };
544
+ }
483
545
  const dist = typeof data.dist === 'object' && data.dist !== null ? data.dist : null;
484
546
  const tarball = dist && typeof dist.tarball === 'string' ? dist.tarball : undefined;
485
547
  if (!tarball)
@@ -559,6 +621,7 @@ async function doApplyUpdate(options, workspaceDir) {
559
621
  fromVersion,
560
622
  toVersion,
561
623
  success: true,
624
+ kind: 'update',
562
625
  backupPath,
563
626
  });
564
627
  return {
@@ -620,6 +683,7 @@ async function doRollbackUpdate(options, workspaceDir) {
620
683
  fromVersion: 'rolled-back',
621
684
  toVersion: readCurrentVersion(targetDir) ?? 'unknown',
622
685
  success: true,
686
+ kind: 'rollback',
623
687
  backupPath: backupDir,
624
688
  });
625
689
  return { success: true, message: 'Rollback completed successfully' };
@@ -661,48 +725,131 @@ function depsMeaningfullyChanged(oldDeps, newDeps) {
661
725
  return aKeys.some((k, i) => bKeys[i] !== k || a[k] !== b[k]);
662
726
  }
663
727
  /**
664
- * Create the node_modules/@principles/host-runtime resolution links for the
665
- * installed console and pd-cli packages, if missing.
728
+ * Create the node_modules resolution links for the installed components, if
729
+ * missing.
666
730
  *
667
731
  * Mirrors installer.ts syncPdCli: junction on Windows (no elevation needed),
668
732
  * relative symlink elsewhere. Fresh installs get these links via npm install
669
- * (the bundled package.json rewrites the dep to file:../host-runtime); the
670
- * full update deliberately skips npm install, so it must create them itself.
671
- * Without the link, the updated console dist — which statically imports
672
- * @principles/host-runtime since 2026-08-21 (41cf97ee5) — crashes at startup
673
- * with ERR_MODULE_NOT_FOUND on installs created before the installer bundled
674
- * host-runtime (PRI-561).
733
+ * (the bundled package.json rewrites internal deps to file:../<component>);
734
+ * the full update deliberately skips npm install, so it must create them
735
+ * itself. Without a link, updated dists crash at startup with
736
+ * ERR_MODULE_NOT_FOUND (host-runtime: PRI-561, 2026-08-21).
737
+ *
738
+ * Two sources, both fail-closed on creation errors:
739
+ * 1. the explicit link list below (known-critical links: a missing one
740
+ * means the updated console cannot start);
741
+ * 2. a data-driven pass that derives links from the STAGED manifests —
742
+ * the freshly extracted release trees under tempDir. Their `file:`
743
+ * declarations are the authoritative list of links the updated tree
744
+ * needs. Reading the deployed (pre-update) manifests instead would
745
+ * miss every dependency this release newly introduced: the running
746
+ * console executes update logic from its own dist (one generation
747
+ * behind the components it installs) — observed 2026-08-29 when the
748
+ * 1.221.2 console updated hosts to 1.222.5 but could not know about
749
+ * the newly introduced install-layout component, leaving
750
+ * host-runtime/node_modules/@principles/install-layout missing and
751
+ * every pd-cli runtime command failing with ERR_MODULE_NOT_FOUND.
675
752
  *
676
753
  * Returns undefined on success, or an error message (rc-9: observable, never
677
754
  * silent — a missing link means the updated console cannot start).
678
755
  */
679
- function ensureHostRuntimeResolutionLinks(extDir) {
680
- const hostRuntimeDir = path.join(extDir, 'host-runtime');
756
+ function ensureRuntimeResolutionLinks(layout, tempDir) {
681
757
  const links = [
682
- { linkPath: path.join(extDir, 'console', 'node_modules', '@principles', 'host-runtime'), target: hostRuntimeDir, unixTarget: '../../../host-runtime' },
683
- { linkPath: path.join(extDir, 'pd-cli', 'node_modules', '@principles', 'host-runtime'), target: hostRuntimeDir, unixTarget: '../../../host-runtime' },
684
- { linkPath: path.join(extDir, 'console', 'node_modules', 'principles-disciple'), target: extDir, unixTarget: '../../' },
758
+ { linkPath: path.join(layout.consoleDir, 'node_modules', '@principles', 'host-runtime'), target: layout.hostRuntimeDir },
759
+ { linkPath: path.join(layout.pdCliDir, 'node_modules', '@principles', 'host-runtime'), target: layout.hostRuntimeDir },
760
+ { linkPath: path.join(layout.consoleDir, 'node_modules', '@principles', 'install-layout'), target: layout.installLayoutDir },
761
+ { linkPath: path.join(layout.pdCliDir, 'node_modules', '@principles', 'install-layout'), target: layout.installLayoutDir },
762
+ // host-runtime depends on @principles/install-layout at runtime; /apply-full
763
+ // skips npm install, so its node_modules must self-provision the link too.
764
+ { linkPath: path.join(layout.hostRuntimeDir, 'node_modules', '@principles', 'install-layout'), target: layout.installLayoutDir },
765
+ { linkPath: path.join(layout.consoleDir, 'node_modules', 'principles-disciple'), target: layout.pluginDir },
766
+ ];
767
+ // Data-driven pass: derive links from the STAGED component manifests (see
768
+ // the comment above — staged, never the deployed pre-update manifests).
769
+ const stagedComponents = [
770
+ { manifestDir: path.join(tempDir, 'console'), deployedDir: layout.consoleDir },
771
+ { manifestDir: path.join(tempDir, 'pd-cli'), deployedDir: layout.pdCliDir },
772
+ { manifestDir: path.join(tempDir, 'host-runtime'), deployedDir: layout.hostRuntimeDir },
773
+ { manifestDir: path.join(tempDir, 'install-layout'), deployedDir: layout.installLayoutDir },
774
+ { manifestDir: path.join(tempDir, 'core'), deployedDir: layout.coreDir },
775
+ { manifestDir: path.join(tempDir, 'plugin'), deployedDir: layout.pluginDir },
685
776
  ];
686
- for (const { linkPath, target, unixTarget } of links) {
777
+ const readStagedDependencies = (manifestDir) => {
778
+ try {
779
+ const pkgPath = path.join(manifestDir, 'package.json');
780
+ if (!fs.existsSync(pkgPath))
781
+ return {};
782
+ const parsed = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
783
+ if (!isRecord(parsed) || !isRecord(parsed.dependencies))
784
+ return {};
785
+ const out = {};
786
+ for (const [name, ref] of Object.entries(parsed.dependencies)) {
787
+ if (typeof ref === 'string')
788
+ out[name] = ref;
789
+ }
790
+ return out;
791
+ }
792
+ catch {
793
+ // rc-9: an unreadable staged manifest degrades to "no derived links" —
794
+ // the explicit list above still covers the known-critical links.
795
+ return {};
796
+ }
797
+ };
798
+ const fileDepSpecs = collectFileDepLinkSpecs(stagedComponents, readStagedDependencies);
799
+ const createResolutionLink = (linkPath, target) => {
800
+ // Idempotent: never overwrite an existing link or directory (fresh
801
+ // installs have npm-created real dirs in these slots).
687
802
  if (fs.existsSync(linkPath))
688
- continue;
803
+ return undefined;
689
804
  try {
690
805
  fs.mkdirSync(path.dirname(linkPath), { recursive: true });
691
806
  if (process.platform === 'win32') {
692
807
  fs.symlinkSync(target, linkPath, 'junction');
693
808
  }
694
809
  else {
695
- fs.symlinkSync(unixTarget, linkPath, 'dir');
810
+ fs.symlinkSync(path.relative(path.dirname(linkPath), target), linkPath, 'dir');
696
811
  }
812
+ return undefined;
697
813
  }
698
814
  catch (error) {
699
- return `Failed to create host-runtime resolution link at ${linkPath}: ${error instanceof Error ? error.message : String(error)}`;
815
+ return `Failed to create runtime resolution link at ${linkPath}: ${error instanceof Error ? error.message : String(error)}`;
700
816
  }
817
+ };
818
+ // Pass 1 — explicit known-critical links, fail-closed BEFORE any byte is
819
+ // swapped (a link-creation failure aborts with the installed packages
820
+ // untouched: the PRI-561 ordering contract).
821
+ for (const { linkPath, target } of links) {
822
+ if (!fs.existsSync(target))
823
+ continue;
824
+ const error = createResolutionLink(linkPath, target);
825
+ if (error)
826
+ return error;
827
+ }
828
+ // Pass 2 — data-driven derived links. Their deployed target dir may be
829
+ // created by the copy steps that follow (a brand-new component's dir does
830
+ // not exist yet); each staged target's existence was already proven by the
831
+ // extraction, and the copies below run unconditionally.
832
+ for (const spec of fileDepSpecs) {
833
+ if (fs.existsSync(spec.linkPath))
834
+ continue;
835
+ const error = createResolutionLink(spec.linkPath, spec.target);
836
+ if (error)
837
+ return error;
701
838
  }
702
839
  return undefined;
703
840
  }
704
841
  async function doInlineFullUpdate(workspaceDir) {
705
- const extDir = resolvePluginDir(workspaceDir);
842
+ const layout = resolveUpdateLayout();
843
+ if (!layout) {
844
+ return {
845
+ success: false,
846
+ message: 'PD install runtime could not be resolved.',
847
+ reason: 'install_runtime_missing',
848
+ nextAction: 'Run npx create-principles-disciple to install or repair PD, then retry the update.',
849
+ requiresRestart: false,
850
+ };
851
+ }
852
+ const extDir = layout.pluginDir;
706
853
  // Legacy-contract preflight BEFORE stopping the gateway or touching files:
707
854
  // refuse while an active rule still uses a removed RuleHost contract
708
855
  // symbol — the running installation stays exactly as it was.
@@ -716,23 +863,16 @@ async function doInlineFullUpdate(workspaceDir) {
716
863
  requiresRestart: false,
717
864
  };
718
865
  }
719
- // 1. Stop gateway (releases native module locks held by the gateway process)
720
- const gatewayStatus = await checkOpenClawGateway();
866
+ // gatewayWasStopped records whether we had to stop an OpenClaw gateway to
867
+ // release native module locks. It is only ever set after candidate
868
+ // verification, in the host-aware stop below.
721
869
  let gatewayWasStopped = false;
722
- if (gatewayStatus.isRunning) {
723
- const stopRes = stopOpenClawGateway();
724
- if (stopRes.ok)
725
- gatewayWasStopped = true;
726
- }
727
- // Capture version before changes
870
+ // Capture installed facts before staging any candidate release.
728
871
  const fromVersion = readCurrentVersion(extDir) ?? 'unknown';
729
872
  // Capture the installed skill language before the tarball's manifest
730
873
  // overwrites it (PR #1332 companion — see reapplySkillLanguage).
731
874
  const skillLanguage = detectInstalledSkillLanguage(extDir);
732
875
  let tempDir;
733
- // Heal legacy installs: move old backups out of the extensions dir so
734
- // OpenClaw discovery stops reporting a duplicate plugin (see pd-backups.ts).
735
- logLegacyBackupMigration('pd-update-full');
736
876
  try {
737
877
  // 2. Fetch installer package info from npm
738
878
  const response = await fetchWithRetry(NPM_REGISTRY_INSTALLER, 'Installer registry check');
@@ -740,6 +880,32 @@ async function doInlineFullUpdate(workspaceDir) {
740
880
  if (!isRecord(rawData))
741
881
  return { success: false, message: 'Invalid registry response', requiresRestart: false };
742
882
  const toVersion = typeof rawData.version === 'string' ? rawData.version : undefined;
883
+ const bundledPluginVersion = isRecord(rawData.pd) && typeof rawData.pd.bundledPluginVersion === 'string'
884
+ ? rawData.pd.bundledPluginVersion
885
+ : undefined;
886
+ if (bundledPluginVersion !== undefined) {
887
+ const advancesInstalled = fromVersion !== 'unknown' &&
888
+ semver.valid(fromVersion) !== null &&
889
+ semver.valid(bundledPluginVersion) !== null &&
890
+ semver.gt(bundledPluginVersion, fromVersion);
891
+ if (!advancesInstalled) {
892
+ appendUpdateHistory(workspaceDir, {
893
+ fromVersion,
894
+ toVersion: bundledPluginVersion,
895
+ success: false,
896
+ kind: 'refusal',
897
+ reason: 'installer_bundle_stale',
898
+ nextAction: 'Wait for a newer installer release, then retry the update.',
899
+ });
900
+ return {
901
+ success: false,
902
+ message: 'Installed version would not advance — the update source is stale or malformed.',
903
+ reason: 'installer_bundle_stale',
904
+ nextAction: 'Wait for a newer installer release, then retry the update.',
905
+ requiresRestart: false,
906
+ };
907
+ }
908
+ }
743
909
  const dist = isRecord(rawData.dist) ? rawData.dist : null;
744
910
  const tarball = dist && typeof dist.tarball === 'string' ? dist.tarball : undefined;
745
911
  if (!tarball)
@@ -754,10 +920,53 @@ async function doInlineFullUpdate(workspaceDir) {
754
920
  // shell syntax (Mimosa command-injection finding, 2026-08-22).
755
921
  execFileSync('tar', ['xzf', tarballPath, '-C', tempDir, '--strip-components=1'], { stdio: 'pipe' });
756
922
  fs.unlinkSync(tarballPath);
923
+ // The tarball, not the installer package version, is the release we are
924
+ // about to activate. Prove it advances the installed plugin BEFORE the
925
+ // gateway is stopped or any production file is copied.
926
+ const newPkgPath = path.join(tempDir, 'plugin', 'package.json');
927
+ const stagedVersion = readCurrentVersion(path.join(tempDir, 'plugin'));
928
+ const progressed = fromVersion !== 'unknown' &&
929
+ stagedVersion !== undefined &&
930
+ semver.valid(fromVersion) !== null &&
931
+ semver.valid(stagedVersion) !== null &&
932
+ semver.gt(stagedVersion, fromVersion) &&
933
+ (bundledPluginVersion === undefined || bundledPluginVersion === stagedVersion);
934
+ if (!progressed) {
935
+ if (tempDir && fs.existsSync(tempDir)) {
936
+ fs.rmSync(tempDir, { recursive: true, force: true });
937
+ }
938
+ appendUpdateHistory(workspaceDir, {
939
+ fromVersion,
940
+ toVersion: stagedVersion ?? 'unknown',
941
+ success: false,
942
+ kind: 'refusal',
943
+ reason: 'installer_bundle_stale',
944
+ nextAction: 'Wait for a newer installer release, then retry the update.',
945
+ });
946
+ return {
947
+ success: false,
948
+ message: 'Installed version would not advance — the update source is stale or malformed.',
949
+ reason: 'installer_bundle_stale',
950
+ nextAction: 'Wait for a newer installer release, then retry the update.',
951
+ requiresRestart: false,
952
+ };
953
+ }
954
+ // Only a verified advancing release may cause host interruption or touch
955
+ // the production installation.
956
+ const gatewayStatus = layout.hosts.includes('openclaw')
957
+ ? await checkOpenClawGateway()
958
+ : { isRunning: false };
959
+ if (gatewayStatus.isRunning) {
960
+ const stopRes = stopOpenClawGateway();
961
+ if (stopRes.ok)
962
+ gatewayWasStopped = true;
963
+ }
964
+ // Heal legacy installs only after candidate verification. This writes
965
+ // outside the release tree, so it must not happen for a refused release.
966
+ logLegacyBackupMigration('pd-update-full');
757
967
  // 4. Detect dependency changes (informational — logged but not blocking;
758
968
  // the .js files are still updated; node_modules stays as-is)
759
969
  let depsChanged = false;
760
- const newPkgPath = path.join(tempDir, 'plugin', 'package.json');
761
970
  const oldPkgPath = path.join(extDir, 'package.json');
762
971
  if (fs.existsSync(newPkgPath) && fs.existsSync(oldPkgPath)) {
763
972
  try {
@@ -785,17 +994,22 @@ async function doInlineFullUpdate(workspaceDir) {
785
994
  // console that does not import it, so skipping is consistent for
786
995
  // them. On fresh installs this is an overlay refresh + link no-op.
787
996
  const hostRuntimeSrc = path.join(tempDir, 'host-runtime');
788
- const hostRuntimeDest = path.join(extDir, 'host-runtime');
997
+ const hostRuntimeDest = layout.hostRuntimeDir;
789
998
  if (fs.existsSync(hostRuntimeSrc) &&
790
999
  fs.existsSync(path.join(hostRuntimeSrc, 'package.json')) &&
791
1000
  fs.existsSync(path.join(hostRuntimeSrc, 'dist'))) {
792
1001
  copyDirRecursive(hostRuntimeSrc, hostRuntimeDest, SKIP_DIRS);
793
- const linkError = ensureHostRuntimeResolutionLinks(extDir);
1002
+ const installLayoutSrc = path.join(tempDir, 'install-layout');
1003
+ if (fs.existsSync(path.join(installLayoutSrc, 'package.json')) && fs.existsSync(path.join(installLayoutSrc, 'dist'))) {
1004
+ copyDirRecursive(installLayoutSrc, layout.installLayoutDir, SKIP_DIRS);
1005
+ }
1006
+ const linkError = ensureRuntimeResolutionLinks(layout, tempDir);
794
1007
  if (linkError) {
795
1008
  appendUpdateHistory(workspaceDir, {
796
1009
  fromVersion,
797
1010
  toVersion: 'failed',
798
1011
  success: false,
1012
+ kind: 'failure',
799
1013
  });
800
1014
  return {
801
1015
  success: false,
@@ -818,20 +1032,20 @@ async function doInlineFullUpdate(workspaceDir) {
818
1032
  // console/node_modules/ may contain locked native modules like
819
1033
  // better-sqlite3 that the running console process holds via dlopen)
820
1034
  const consoleSrc = path.join(tempDir, 'console');
821
- const consoleDest = path.join(extDir, 'console');
1035
+ const consoleDest = layout.consoleDir;
822
1036
  if (fs.existsSync(consoleSrc)) {
823
1037
  copyDirRecursive(consoleSrc, consoleDest, SKIP_DIRS);
824
1038
  }
825
1039
  // c. core/ → extDir/core/ (overwrite, skip node_modules for safety)
826
1040
  const coreSrc = path.join(tempDir, 'core');
827
- const coreDest = path.join(extDir, 'core');
1041
+ const coreDest = layout.coreDir;
828
1042
  if (fs.existsSync(coreSrc)) {
829
1043
  copyDirRecursive(coreSrc, coreDest, SKIP_DIRS);
830
1044
  }
831
1045
  // d. pd-cli/dist + package.json → extDir/pd-cli/ (overwrite only,
832
1046
  // do NOT rmSync — preserves node_modules symlinks created at install)
833
1047
  const pdCliSrc = path.join(tempDir, 'pd-cli');
834
- const pdCliDest = path.join(extDir, 'pd-cli');
1048
+ const pdCliDest = layout.pdCliDir;
835
1049
  if (fs.existsSync(pdCliSrc)) {
836
1050
  const distSrc = path.join(pdCliSrc, 'dist');
837
1051
  const distDest = path.join(pdCliDest, 'dist');
@@ -857,11 +1071,8 @@ async function doInlineFullUpdate(workspaceDir) {
857
1071
  // false "update available". Detect that and fail loud (rc-9) instead of
858
1072
  // reporting a false success.
859
1073
  const newVersion = readCurrentVersion(extDir) ?? toVersion ?? 'unknown';
860
- const progressed = fromVersion !== 'unknown' &&
861
- semver.valid(fromVersion) !== null &&
862
- semver.valid(newVersion) !== null &&
863
- semver.gt(newVersion, fromVersion);
864
- if (!progressed) {
1074
+ const installedExpectedRelease = newVersion === stagedVersion;
1075
+ if (!installedExpectedRelease) {
865
1076
  // Files were already rewritten to the same (or lower) version. Record a
866
1077
  // FAILED history entry so the operator sees why, and return a structured
867
1078
  // error with nextAction.
@@ -869,6 +1080,7 @@ async function doInlineFullUpdate(workspaceDir) {
869
1080
  fromVersion,
870
1081
  toVersion: newVersion,
871
1082
  success: false,
1083
+ kind: 'failure',
872
1084
  });
873
1085
  return {
874
1086
  success: false,
@@ -883,6 +1095,7 @@ async function doInlineFullUpdate(workspaceDir) {
883
1095
  fromVersion,
884
1096
  toVersion: newVersion,
885
1097
  success: true,
1098
+ kind: 'update',
886
1099
  });
887
1100
  return {
888
1101
  success: true,
@@ -908,6 +1121,7 @@ async function doInlineFullUpdate(workspaceDir) {
908
1121
  fromVersion,
909
1122
  toVersion: 'failed',
910
1123
  success: false,
1124
+ kind: 'failure',
911
1125
  });
912
1126
  if (isLockError) {
913
1127
  return {
@@ -990,6 +1204,14 @@ export async function handleUpdateRoute(req, res, workspaceDir, subPath) {
990
1204
  }
991
1205
  // createBackup is a boolean (default false)
992
1206
  const createBackup = typeof body.createBackup === 'boolean' ? body.createBackup : false;
1207
+ // The Console updater owns only the installed PD runtime selected at
1208
+ // process start. A caller-supplied path inside a workspace may be a
1209
+ // development checkout; accepting it lets a registry package overwrite
1210
+ // source files and makes version history describe the wrong product.
1211
+ if (path.resolve(targetDir) !== path.resolve(pluginDir)) {
1212
+ sendError(res, 400, 'update_target_not_installed', 'Updates may only target the installed PD runtime.', { nextAction: 'Run the official installer to repair the installation, then retry from Console.' });
1213
+ return;
1214
+ }
993
1215
  // Path traversal validation
994
1216
  if (!validatePathInWorkspace(targetDir, workspaceDir)) {
995
1217
  sendBadRequest(res, 'targetDir must be within workspace or extensions directory');