create-principles-disciple 1.152.2 → 1.152.4

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 (386) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/dist/pd-hook.js +34 -4
  3. package/codex-adapter/package.json +1 -1
  4. package/console/dist/server/config/pd-config-store.d.ts +48 -0
  5. package/console/dist/server/config/pd-config-store.js +273 -93
  6. package/console/dist/server/index.js +16 -1
  7. package/console/dist/server/models/ActivationsConsoleModel.d.ts +72 -1
  8. package/console/dist/server/models/ActivationsConsoleModel.js +92 -14
  9. package/console/dist/server/models/AdaptiveActivationConsoleModel.d.ts +79 -0
  10. package/console/dist/server/models/AdaptiveActivationConsoleModel.js +151 -0
  11. package/console/dist/server/models/ApprovalsConsoleModel.d.ts +28 -0
  12. package/console/dist/server/models/ApprovalsConsoleModel.js +118 -3
  13. package/console/dist/server/models/ApprovalsGroupedConsoleModel.d.ts +38 -0
  14. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +158 -26
  15. package/console/dist/server/models/IntentDecisionModel.d.ts +6 -1
  16. package/console/dist/server/models/IntentDecisionModel.js +17 -9
  17. package/console/dist/server/models/pipeline-health-metrics.d.ts +128 -0
  18. package/console/dist/server/models/pipeline-health-metrics.js +225 -0
  19. package/console/dist/server/routes/approvals.js +14 -0
  20. package/console/dist/server/routes/config.js +212 -1
  21. package/console/dist/server/routes/diagnostician.js +13 -2
  22. package/console/dist/server/routes/intent-decisions.js +19 -1
  23. package/console/dist/server/routes/pipeline-health.d.ts +9 -0
  24. package/console/dist/server/routes/pipeline-health.js +124 -0
  25. package/console/dist/web/assets/app.css +484 -67
  26. package/console/dist/web/assets/app.js +36 -31
  27. package/console/dist/web/assets/evidence-art-1.webp +0 -0
  28. package/console/dist/web/assets/evidence-art-2.webp +0 -0
  29. package/console/dist/web/assets/evidence-art-3.webp +0 -0
  30. package/console/dist/web/assets/evidence-art-4.webp +0 -0
  31. package/console/dist/web/assets/principle-grove.jpg +0 -0
  32. package/console/dist/web/assets/principle-stone-steps.jpg +0 -0
  33. package/console/dist/web/assets/principles-art-1.webp +0 -0
  34. package/console/dist/web/assets/principles-art-2.webp +0 -0
  35. package/console/dist/web/assets/principles-art-3.webp +0 -0
  36. package/console/dist/web/assets/principles-art-4.webp +0 -0
  37. package/console/dist/web/assets/today-art-1.webp +0 -0
  38. package/console/dist/web/assets/today-art-2.webp +0 -0
  39. package/console/dist/web/assets/today-art-3.webp +0 -0
  40. package/console/dist/web/assets/today-art-4.webp +0 -0
  41. package/core/dist/runtime/activation/activation-types.d.ts +6 -0
  42. package/core/dist/runtime/activation/activation-types.d.ts.map +1 -1
  43. package/core/dist/runtime/activation/activation-types.js.map +1 -1
  44. package/core/dist/runtime/activation/index.d.ts +2 -1
  45. package/core/dist/runtime/activation/index.d.ts.map +1 -1
  46. package/core/dist/runtime/activation/index.js +1 -1
  47. package/core/dist/runtime/activation/index.js.map +1 -1
  48. package/core/dist/runtime/activation/ledger-identity.d.ts +8 -0
  49. package/core/dist/runtime/activation/ledger-identity.d.ts.map +1 -1
  50. package/core/dist/runtime/activation/ledger-identity.js +20 -1
  51. package/core/dist/runtime/activation/ledger-identity.js.map +1 -1
  52. package/core/dist/runtime/activation/sqlite-approval-store.d.ts +18 -0
  53. package/core/dist/runtime/activation/sqlite-approval-store.d.ts.map +1 -1
  54. package/core/dist/runtime/activation/sqlite-approval-store.js +146 -20
  55. package/core/dist/runtime/activation/sqlite-approval-store.js.map +1 -1
  56. package/core/dist/runtime/adapter/artificer-l2-adapter.d.ts.map +1 -1
  57. package/core/dist/runtime/adapter/artificer-l2-adapter.js +11 -4
  58. package/core/dist/runtime/adapter/artificer-l2-adapter.js.map +1 -1
  59. package/core/dist/runtime/adapter/l2-agent-loop-adapter.d.ts.map +1 -1
  60. package/core/dist/runtime/adapter/l2-agent-loop-adapter.js +11 -4
  61. package/core/dist/runtime/adapter/l2-agent-loop-adapter.js.map +1 -1
  62. package/core/dist/runtime/adapter/output-repair-contract.d.ts +21 -1
  63. package/core/dist/runtime/adapter/output-repair-contract.d.ts.map +1 -1
  64. package/core/dist/runtime/adapter/output-repair-contract.js.map +1 -1
  65. package/core/dist/runtime/adapter/pi-ai-catalog.d.ts +42 -0
  66. package/core/dist/runtime/adapter/pi-ai-catalog.d.ts.map +1 -1
  67. package/core/dist/runtime/adapter/pi-ai-catalog.js +68 -0
  68. package/core/dist/runtime/adapter/pi-ai-catalog.js.map +1 -1
  69. package/core/dist/runtime/adapter/pi-ai-connection-probe.d.ts +45 -0
  70. package/core/dist/runtime/adapter/pi-ai-connection-probe.d.ts.map +1 -0
  71. package/core/dist/runtime/adapter/pi-ai-connection-probe.js +321 -0
  72. package/core/dist/runtime/adapter/pi-ai-connection-probe.js.map +1 -0
  73. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts +27 -2
  74. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  75. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +71 -10
  76. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
  77. package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts.map +1 -1
  78. package/core/dist/runtime/adapter/schema-prompt-adapter.js +39 -6
  79. package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
  80. package/core/dist/runtime/adapter/structured-output-repair.d.ts +26 -0
  81. package/core/dist/runtime/adapter/structured-output-repair.d.ts.map +1 -1
  82. package/core/dist/runtime/adapter/structured-output-repair.js +140 -2
  83. package/core/dist/runtime/adapter/structured-output-repair.js.map +1 -1
  84. package/core/dist/runtime/config/execution-timing.d.ts +56 -0
  85. package/core/dist/runtime/config/execution-timing.d.ts.map +1 -0
  86. package/core/dist/runtime/config/execution-timing.js +76 -0
  87. package/core/dist/runtime/config/execution-timing.js.map +1 -0
  88. package/core/dist/runtime/config/index.d.ts +4 -0
  89. package/core/dist/runtime/config/index.d.ts.map +1 -1
  90. package/core/dist/runtime/config/index.js +2 -0
  91. package/core/dist/runtime/config/index.js.map +1 -1
  92. package/core/dist/runtime/config/pd-config-redaction.d.ts.map +1 -1
  93. package/core/dist/runtime/config/pd-config-redaction.js +4 -0
  94. package/core/dist/runtime/config/pd-config-redaction.js.map +1 -1
  95. package/core/dist/runtime/config/pd-config-types.d.ts +5 -0
  96. package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
  97. package/core/dist/runtime/config/pd-config-types.js.map +1 -1
  98. package/core/dist/runtime/config/pd-credentials.d.ts +105 -0
  99. package/core/dist/runtime/config/pd-credentials.d.ts.map +1 -0
  100. package/core/dist/runtime/config/pd-credentials.js +409 -0
  101. package/core/dist/runtime/config/pd-credentials.js.map +1 -0
  102. package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts +13 -2
  103. package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts.map +1 -1
  104. package/core/dist/runtime/diagnostician/diag-rootcause-output.js.map +1 -1
  105. package/core/dist/runtime/diagnostician/diagnostic-context-budget.d.ts +45 -0
  106. package/core/dist/runtime/diagnostician/diagnostic-context-budget.d.ts.map +1 -0
  107. package/core/dist/runtime/diagnostician/diagnostic-context-budget.js +74 -0
  108. package/core/dist/runtime/diagnostician/diagnostic-context-budget.js.map +1 -0
  109. package/core/dist/runtime/diagnostician/prompt-projection.d.ts +51 -0
  110. package/core/dist/runtime/diagnostician/prompt-projection.d.ts.map +1 -0
  111. package/core/dist/runtime/diagnostician/prompt-projection.js +192 -0
  112. package/core/dist/runtime/diagnostician/prompt-projection.js.map +1 -0
  113. package/core/dist/runtime/diagnostician-output.d.ts +1 -1
  114. package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
  115. package/core/dist/runtime/diagnostician-output.js +2 -2
  116. package/core/dist/runtime/diagnostician-output.js.map +1 -1
  117. package/core/dist/runtime/index.d.ts +5 -2
  118. package/core/dist/runtime/index.d.ts.map +1 -1
  119. package/core/dist/runtime/index.js +11 -1
  120. package/core/dist/runtime/index.js.map +1 -1
  121. package/core/dist/runtime/intent/index.d.ts +2 -0
  122. package/core/dist/runtime/intent/index.d.ts.map +1 -1
  123. package/core/dist/runtime/intent/index.js +2 -0
  124. package/core/dist/runtime/intent/index.js.map +1 -1
  125. package/core/dist/runtime/intent/intent-decision-record.d.ts +51 -3
  126. package/core/dist/runtime/intent/intent-decision-record.d.ts.map +1 -1
  127. package/core/dist/runtime/intent/intent-snapshot.d.ts +104 -0
  128. package/core/dist/runtime/intent/intent-snapshot.d.ts.map +1 -0
  129. package/core/dist/runtime/intent/intent-snapshot.js +164 -0
  130. package/core/dist/runtime/intent/intent-snapshot.js.map +1 -0
  131. package/core/dist/runtime/intent/strategic-conflict-gate.d.ts +70 -0
  132. package/core/dist/runtime/intent/strategic-conflict-gate.d.ts.map +1 -0
  133. package/core/dist/runtime/intent/strategic-conflict-gate.js +148 -0
  134. package/core/dist/runtime/intent/strategic-conflict-gate.js.map +1 -0
  135. package/core/dist/runtime/internalization/artificer-runner.js +1 -1
  136. package/core/dist/runtime/internalization/artificer-runner.js.map +1 -1
  137. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +6 -0
  138. package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
  139. package/core/dist/runtime/internalization/diag-distiller-runner.js +62 -5
  140. package/core/dist/runtime/internalization/diag-distiller-runner.js.map +1 -1
  141. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +41 -1
  142. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
  143. package/core/dist/runtime/internalization/diag-rootcause-runner.js +190 -43
  144. package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
  145. package/core/dist/runtime/internalization/diag-router-runner.d.ts +6 -0
  146. package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
  147. package/core/dist/runtime/internalization/diag-router-runner.js +114 -69
  148. package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
  149. package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts.map +1 -1
  150. package/core/dist/runtime/internalization/dreamer-prompt-builder.js +3 -0
  151. package/core/dist/runtime/internalization/dreamer-prompt-builder.js.map +1 -1
  152. package/core/dist/runtime/internalization/dreamer-runner.js +1 -1
  153. package/core/dist/runtime/internalization/dreamer-runner.js.map +1 -1
  154. package/core/dist/runtime/internalization/evaluator-runner.js +4 -4
  155. package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
  156. package/core/dist/runtime/internalization/formation-context.d.ts +54 -0
  157. package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
  158. package/core/dist/runtime/internalization/formation-context.js +135 -3
  159. package/core/dist/runtime/internalization/formation-context.js.map +1 -1
  160. package/core/dist/runtime/internalization/index.d.ts +2 -2
  161. package/core/dist/runtime/internalization/index.d.ts.map +1 -1
  162. package/core/dist/runtime/internalization/index.js +1 -1
  163. package/core/dist/runtime/internalization/index.js.map +1 -1
  164. package/core/dist/runtime/internalization/intent-contract.d.ts +107 -0
  165. package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
  166. package/core/dist/runtime/internalization/intent-contract.js +315 -4
  167. package/core/dist/runtime/internalization/intent-contract.js.map +1 -1
  168. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +8 -0
  169. package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
  170. package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
  171. package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts +22 -1
  172. package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts.map +1 -1
  173. package/core/dist/runtime/internalization/philosopher-prompt-builder.js +22 -3
  174. package/core/dist/runtime/internalization/philosopher-prompt-builder.js.map +1 -1
  175. package/core/dist/runtime/internalization/philosopher-runner.d.ts +15 -0
  176. package/core/dist/runtime/internalization/philosopher-runner.d.ts.map +1 -1
  177. package/core/dist/runtime/internalization/philosopher-runner.js +74 -2
  178. package/core/dist/runtime/internalization/philosopher-runner.js.map +1 -1
  179. package/core/dist/runtime/internalization/pitask-metadata.d.ts +32 -0
  180. package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
  181. package/core/dist/runtime/internalization/pitask-metadata.js +44 -0
  182. package/core/dist/runtime/internalization/pitask-metadata.js.map +1 -1
  183. package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +6 -1
  184. package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
  185. package/core/dist/runtime/internalization/rollout-reviewer-runner.js +31 -15
  186. package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
  187. package/core/dist/runtime/internalization/scribe-output.d.ts +21 -0
  188. package/core/dist/runtime/internalization/scribe-output.d.ts.map +1 -1
  189. package/core/dist/runtime/internalization/scribe-output.js +125 -2
  190. package/core/dist/runtime/internalization/scribe-output.js.map +1 -1
  191. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +26 -1
  192. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
  193. package/core/dist/runtime/internalization/scribe-prompt-builder.js +33 -3
  194. package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
  195. package/core/dist/runtime/internalization/scribe-runner.d.ts +32 -2
  196. package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
  197. package/core/dist/runtime/internalization/scribe-runner.js +106 -8
  198. package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
  199. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +46 -0
  200. package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
  201. package/core/dist/runtime/internalization/split-diagnostician-runner.js +220 -20
  202. package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
  203. package/core/dist/runtime/internalization-integrity-remediation.d.ts +7 -0
  204. package/core/dist/runtime/internalization-integrity-remediation.d.ts.map +1 -1
  205. package/core/dist/runtime/internalization-integrity-remediation.js +44 -12
  206. package/core/dist/runtime/internalization-integrity-remediation.js.map +1 -1
  207. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  208. package/core/dist/runtime/pain-signal-runtime-factory.js +25 -4
  209. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  210. package/core/dist/runtime/pain-submit-capability.js +5 -5
  211. package/core/dist/runtime/pain-submit-capability.js.map +1 -1
  212. package/core/dist/runtime/runner/base-peer-runner.d.ts +90 -2
  213. package/core/dist/runtime/runner/base-peer-runner.d.ts.map +1 -1
  214. package/core/dist/runtime/runner/base-peer-runner.js +463 -170
  215. package/core/dist/runtime/runner/base-peer-runner.js.map +1 -1
  216. package/core/dist/runtime/runner/peer-runner-types.d.ts +19 -0
  217. package/core/dist/runtime/runner/peer-runner-types.d.ts.map +1 -1
  218. package/core/dist/runtime/runtime-protocol.d.ts +19 -0
  219. package/core/dist/runtime/runtime-protocol.d.ts.map +1 -1
  220. package/core/dist/runtime/signal-collector/llm-stage.d.ts +5 -0
  221. package/core/dist/runtime/signal-collector/llm-stage.d.ts.map +1 -1
  222. package/core/dist/runtime/signal-collector/llm-stage.js.map +1 -1
  223. package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.d.ts +14 -0
  224. package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.d.ts.map +1 -1
  225. package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.js +16 -1
  226. package/core/dist/runtime/store/artifact/sqlite-pi-artifact-store.js.map +1 -1
  227. package/core/dist/runtime/store/commit/diagnostician-committer.d.ts +19 -0
  228. package/core/dist/runtime/store/commit/diagnostician-committer.d.ts.map +1 -1
  229. package/core/dist/runtime/store/commit/diagnostician-committer.js +11 -0
  230. package/core/dist/runtime/store/commit/diagnostician-committer.js.map +1 -1
  231. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts +2 -2
  232. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts.map +1 -1
  233. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js +285 -35
  234. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js.map +1 -1
  235. package/core/dist/runtime/store/lifecycle/fenced-task-writer.d.ts +64 -0
  236. package/core/dist/runtime/store/lifecycle/fenced-task-writer.d.ts.map +1 -0
  237. package/core/dist/runtime/store/lifecycle/fenced-task-writer.js +231 -0
  238. package/core/dist/runtime/store/lifecycle/fenced-task-writer.js.map +1 -0
  239. package/core/dist/runtime/store/lifecycle/index.d.ts +2 -0
  240. package/core/dist/runtime/store/lifecycle/index.d.ts.map +1 -1
  241. package/core/dist/runtime/store/lifecycle/index.js +1 -0
  242. package/core/dist/runtime/store/lifecycle/index.js.map +1 -1
  243. package/core/dist/runtime/store/lifecycle/lease-fence.d.ts +80 -0
  244. package/core/dist/runtime/store/lifecycle/lease-fence.d.ts.map +1 -0
  245. package/core/dist/runtime/store/lifecycle/lease-fence.js +79 -0
  246. package/core/dist/runtime/store/lifecycle/lease-fence.js.map +1 -0
  247. package/core/dist/runtime/store/lifecycle/lease-heartbeat.d.ts +118 -0
  248. package/core/dist/runtime/store/lifecycle/lease-heartbeat.d.ts.map +1 -0
  249. package/core/dist/runtime/store/lifecycle/lease-heartbeat.js +187 -0
  250. package/core/dist/runtime/store/lifecycle/lease-heartbeat.js.map +1 -0
  251. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +30 -20
  252. package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
  253. package/core/dist/runtime/store/lifecycle/lease-manager.js +94 -53
  254. package/core/dist/runtime/store/lifecycle/lease-manager.js.map +1 -1
  255. package/core/dist/runtime/store/lifecycle/recovery-sweep.d.ts.map +1 -1
  256. package/core/dist/runtime/store/lifecycle/recovery-sweep.js +32 -15
  257. package/core/dist/runtime/store/lifecycle/recovery-sweep.js.map +1 -1
  258. package/core/dist/runtime/store/run/sqlite-run-store.d.ts +29 -0
  259. package/core/dist/runtime/store/run/sqlite-run-store.d.ts.map +1 -1
  260. package/core/dist/runtime/store/run/sqlite-run-store.js +40 -0
  261. package/core/dist/runtime/store/run/sqlite-run-store.js.map +1 -1
  262. package/core/dist/runtime/store/runtime-state-manager.d.ts +64 -10
  263. package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
  264. package/core/dist/runtime/store/runtime-state-manager.js +154 -89
  265. package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
  266. package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
  267. package/core/dist/runtime/store/sqlite-connection.js +73 -4
  268. package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
  269. package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
  270. package/core/dist/runtime/store/task/sqlite-task-store.js +6 -3
  271. package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
  272. package/core/dist/runtime/task-status.d.ts +16 -0
  273. package/core/dist/runtime/task-status.d.ts.map +1 -1
  274. package/core/dist/runtime/task-status.js +8 -0
  275. package/core/dist/runtime/task-status.js.map +1 -1
  276. package/core/dist/runtime/trajectory-schema.d.ts.map +1 -1
  277. package/core/dist/runtime/trajectory-schema.js +20 -1
  278. package/core/dist/runtime/trajectory-schema.js.map +1 -1
  279. package/core/dist/runtime/types/event-types.d.ts +20 -0
  280. package/core/dist/runtime/types/event-types.d.ts.map +1 -1
  281. package/core/dist/runtime/types/event-types.js +7 -0
  282. package/core/dist/runtime/types/event-types.js.map +1 -1
  283. package/core/dist/telemetry-event.d.ts +2 -2
  284. package/core/dist/telemetry-event.d.ts.map +1 -1
  285. package/core/dist/telemetry-event.js +27 -2
  286. package/core/dist/telemetry-event.js.map +1 -1
  287. package/core/dist/trajectory-types.d.ts +33 -0
  288. package/core/dist/trajectory-types.d.ts.map +1 -1
  289. package/core/package.json +1 -1
  290. package/dist/installer.d.ts.map +1 -1
  291. package/dist/installer.js +12 -5
  292. package/dist/installer.js.map +1 -1
  293. package/dist/installers/codex-host-installer.d.ts.map +1 -1
  294. package/dist/installers/codex-host-installer.js +9 -12
  295. package/dist/installers/codex-host-installer.js.map +1 -1
  296. package/host-runtime/dist/adaptive-consumer-schedule.d.ts +103 -0
  297. package/host-runtime/dist/adaptive-consumer-schedule.js +145 -0
  298. package/host-runtime/dist/adaptive-priority-provider.d.ts +7 -1
  299. package/host-runtime/dist/adaptive-priority-provider.js +6 -3
  300. package/host-runtime/dist/adaptive-selection.d.ts +1 -1
  301. package/host-runtime/dist/adaptive-selection.js +2 -1
  302. package/host-runtime/dist/degraded-enforcement-marker.d.ts +35 -0
  303. package/host-runtime/dist/degraded-enforcement-marker.js +79 -0
  304. package/host-runtime/dist/index.d.ts +2 -0
  305. package/host-runtime/dist/index.js +8 -0
  306. package/host-runtime/dist/internalization-consumer-cycle.d.ts +35 -0
  307. package/host-runtime/dist/internalization-consumer-cycle.js +51 -17
  308. package/host-runtime/dist/prompt-activation-deliverability.d.ts +10 -0
  309. package/host-runtime/dist/prompt-activation-deliverability.js +5 -2
  310. package/host-runtime/dist/prompt-injection-event-evidence.d.ts +34 -0
  311. package/host-runtime/dist/prompt-injection-event-evidence.js +96 -0
  312. package/host-runtime/dist/signal-classifier.js +4 -4
  313. package/host-runtime/package.json +1 -1
  314. package/install-layout/dist/mcp-binding-contract.js +4 -15
  315. package/install-layout/package.json +1 -1
  316. package/package.json +3 -3
  317. package/pd-cli/dist/commands/health-codex.d.ts.map +1 -1
  318. package/pd-cli/dist/commands/health-codex.js +26 -1
  319. package/pd-cli/dist/commands/health-codex.js.map +1 -1
  320. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  321. package/pd-cli/dist/commands/health.js +32 -2
  322. package/pd-cli/dist/commands/health.js.map +1 -1
  323. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  324. package/pd-cli/dist/commands/pain-retry.js +6 -4
  325. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  326. package/pd-cli/dist/commands/runtime-init.d.ts.map +1 -1
  327. package/pd-cli/dist/commands/runtime-init.js +29 -1
  328. package/pd-cli/dist/commands/runtime-init.js.map +1 -1
  329. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  330. package/pd-cli/dist/commands/runtime-internalization-run-once.js +9 -14
  331. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  332. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
  333. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +5 -5
  334. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
  335. package/pd-cli/dist/commands/runtime-usage.d.ts +62 -0
  336. package/pd-cli/dist/commands/runtime-usage.d.ts.map +1 -0
  337. package/pd-cli/dist/commands/runtime-usage.js +315 -0
  338. package/pd-cli/dist/commands/runtime-usage.js.map +1 -0
  339. package/pd-cli/dist/commands/runtime.js +6 -6
  340. package/pd-cli/dist/commands/runtime.js.map +1 -1
  341. package/pd-cli/dist/index.d.ts.map +1 -1
  342. package/pd-cli/dist/index.js +51 -17
  343. package/pd-cli/dist/index.js.map +1 -1
  344. package/pd-cli/dist/program.d.ts.map +1 -1
  345. package/pd-cli/dist/program.js +4 -0
  346. package/pd-cli/dist/program.js.map +1 -1
  347. package/pd-cli/dist/services/cli-invocation-log.d.ts +66 -0
  348. package/pd-cli/dist/services/cli-invocation-log.d.ts.map +1 -0
  349. package/pd-cli/dist/services/cli-invocation-log.js +139 -0
  350. package/pd-cli/dist/services/cli-invocation-log.js.map +1 -0
  351. package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
  352. package/pd-cli/dist/services/config-doctor.js +5 -4
  353. package/pd-cli/dist/services/config-doctor.js.map +1 -1
  354. package/pd-cli/dist/services/demo-story-a-runner.d.ts.map +1 -1
  355. package/pd-cli/dist/services/demo-story-a-runner.js +6 -2
  356. package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
  357. package/pd-cli/dist/services/pd-config-loader.d.ts +3 -1
  358. package/pd-cli/dist/services/pd-config-loader.d.ts.map +1 -1
  359. package/pd-cli/dist/services/pd-config-loader.js +20 -8
  360. package/pd-cli/dist/services/pd-config-loader.js.map +1 -1
  361. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
  362. package/pd-cli/dist/services/runtime-adapter-resolver.js +5 -5
  363. package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
  364. package/pd-cli/package.json +1 -1
  365. package/plugin/dist/bundle.js +632 -536
  366. package/plugin/dist/core/signal-collector-host.d.ts +5 -0
  367. package/plugin/dist/governance-audit.js +2 -2
  368. package/plugin/dist/openclaw.plugin.json +1 -1
  369. package/plugin/dist/rulehost-evidence.js +13 -10
  370. package/plugin/dist/service/internalization-auto-consumer-service.d.ts +2 -1
  371. package/plugin/dist/templates/langs/en/skills/pd-pain-signal/SKILL.md +1 -1
  372. package/plugin/dist/templates/langs/zh/skills/pd-pain-signal/SKILL.md +1 -1
  373. package/plugin/openclaw.plugin.json +1 -1
  374. package/plugin/package.json +1 -1
  375. package/plugin/templates/langs/en/skills/pd-pain-signal/SKILL.md +1 -1
  376. package/plugin/templates/langs/zh/skills/pd-pain-signal/SKILL.md +1 -1
  377. package/release-manager/dist/installer.js +12 -5
  378. package/release-manager/dist/installers/codex-host-installer.js +9 -12
  379. package/release-manager/package.json +1 -1
  380. package/workbuddy-adapter/package.json +1 -1
  381. package/workbuddy-adapter/plugin/skills/pd-pain-signal/SKILL.md +1 -1
  382. package/dist/installers/mcp-binding-shape-mirror.d.ts +0 -27
  383. package/dist/installers/mcp-binding-shape-mirror.d.ts.map +0 -1
  384. package/dist/installers/mcp-binding-shape-mirror.js +0 -105
  385. package/dist/installers/mcp-binding-shape-mirror.js.map +0 -1
  386. package/release-manager/dist/installers/mcp-binding-shape-mirror.js +0 -105
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "productVersion": "2.8.6",
4
- "sourceCommit": "a0984037f10c71f565da77ffaaf285369e265c49"
4
+ "sourceCommit": "8ad7b7924a5edb2231486ef0ed99c2462ad78318"
5
5
  }
@@ -66,15 +66,28 @@ function redactStringFields(data) {
66
66
  * writer, so the Codex host path stays independent of the OpenClaw plugin
67
67
  * (codex-adapter must not depend on principles-disciple — bundle guard).
68
68
  */
69
- function codexEventEmitter(stateDir, evidence) {
69
+ function codexEventEmitter(stateDir, evidence, readAdaptiveFact) {
70
70
  return {
71
71
  recordRuntimeActivationsInjected(data) {
72
+ // Adaptive Activation fact for this turn. Appended ONLY on the final
73
+ // assembly basis: a selection whose id did not reach `activationIds`
74
+ // (dropped by budget, replaced, failed packing) is not an append.
75
+ const fact = readAdaptiveFact?.() ?? null;
76
+ const adaptive = fact === null
77
+ ? undefined
78
+ : {
79
+ resultCode: `${fact.status}:${fact.reason}`.slice(0, 240),
80
+ scored: fact.sends > 0,
81
+ ...(fact.targetActivationId !== null && data.activationIds.includes(fact.targetActivationId)
82
+ ? { appendedActivationId: fact.targetActivationId }
83
+ : {}),
84
+ };
72
85
  appendEventLogLine(stateDir, {
73
86
  ts: new Date().toISOString(),
74
87
  type: 'runtime_v2_prompt_activations_injected',
75
88
  category: 'injected',
76
89
  sessionId: data.sessionId,
77
- data,
90
+ data: adaptive === undefined ? data : { ...data, adaptive },
78
91
  });
79
92
  // PD v2 Phase 1: the durable source line is appended — now record the
80
93
  // normalized agent-context delivery attempts (submitted, not delivered).
@@ -436,6 +449,7 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
436
449
  // top of the PD hook. `host.codex.enabled` remains the whole-hook gate.
437
450
  const adaptiveDiagnostics = [];
438
451
  let adaptivePriorityProvider;
452
+ let adaptiveTurnFact = null;
439
453
  if (event.kind === 'before_prompt_build' && flags['host.codex.adaptive_activation']?.enabled === true) {
440
454
  const adaptive = createAdaptivePriorityProviderForConfig(config.effective.config, resolution.workspaceDir, {
441
455
  env: _env,
@@ -444,13 +458,29 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
444
458
  requestTimeoutMs: deps.requestTimeoutMs ?? CODEX_ADAPTIVE_DECISION_MS,
445
459
  ...(deps.minExecutableBudgetMs !== undefined ? { minExecutableBudgetMs: deps.minExecutableBudgetMs } : {}),
446
460
  outerDeadlineAt: adaptiveDeadlineAt,
447
- onDiagnostic: (line) => { adaptiveDiagnostics.push(adaptiveSelectionDiagnostic(line)); },
461
+ onDiagnostic: (line) => {
462
+ adaptiveDiagnostics.push(adaptiveSelectionDiagnostic(line));
463
+ adaptiveTurnFact = {
464
+ status: line.status,
465
+ reason: line.reason,
466
+ sends: line.sends,
467
+ targetActivationId: line.targetActivationId,
468
+ };
469
+ },
448
470
  });
449
471
  if (adaptive.ok) {
450
472
  adaptivePriorityProvider = adaptive.provider;
451
473
  }
452
474
  else {
453
475
  // rc-9: an enabled-but-unusable switch is observable, never silent.
476
+ // `sends: 0` is a fact, not an assumption: no request can leave when
477
+ // the effective configuration cannot build a model.
478
+ adaptiveTurnFact = {
479
+ status: 'needs_setup',
480
+ reason: adaptive.reason,
481
+ sends: 0,
482
+ targetActivationId: null,
483
+ };
454
484
  adaptiveDiagnostics.push(diagnostic(`adaptive_activation_${adaptive.readiness}:${adaptive.reason}`, adaptive.nextAction));
455
485
  }
456
486
  }
@@ -484,7 +514,7 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
484
514
  currentToolUseId: event.context.toolCallId ?? '',
485
515
  toolSemantics,
486
516
  }),
487
- events: codexEventEmitter(path.join(resolution.workspaceDir, '.state'), evidenceContext),
517
+ events: codexEventEmitter(path.join(resolution.workspaceDir, '.state'), evidenceContext, () => adaptiveTurnFact),
488
518
  }).dispatch(event);
489
519
  // PRI-813: the shared gate's evaluation facts leave through metadata —
490
520
  // persist them here (telemetry persistence is host-side business; the
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/codex-adapter",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "Codex CLI host adapter for Principles Disciple — implements HostAdapter interface for OpenAI Codex CLI's stdin/stdout JSON hook model (ADR-0020).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -183,6 +183,47 @@ export declare function getFeedbackChannelConfig(workspaceDir: string): Feedback
183
183
  * Safe partial write: preserves unknown sections, validates before write.
184
184
  */
185
185
  export declare function updatePrinciplesOutputLanguage(workspaceDir: string, payload: unknown): OutputLanguageResult;
186
+ /**
187
+ * The ONE team-confirmed Decisions combination the Console offers on first
188
+ * setup. The endpoint/model/provider/credential-variable are frozen: the entry
189
+ * does not accept arbitrary addresses or arbitrary environment variable names.
190
+ */
191
+ export declare const ADAPTIVE_ACTIVATION_SERVICE_PRESET: {
192
+ readonly id: 'decisions-openrouter-respan';
193
+ readonly label: 'Decisions (OpenRouter / Respan)';
194
+ readonly endpoint: 'https://openrouter.ai/api/alpha/decisions';
195
+ readonly model: 'respan/span-01-lite:free';
196
+ readonly provider: 'Respan';
197
+ readonly apiKeyEnv: 'OPENROUTER_API_KEY';
198
+ /** Frozen EXACT response-model allowlist from the accepted real runs. */
199
+ readonly responseModels: readonly ['respan/span-01-lite:free', 'respan/span-01-lite-20260925'];
200
+ };
201
+ export type AdaptiveServicePresetId = typeof ADAPTIVE_ACTIVATION_SERVICE_PRESET.id;
202
+ export interface AdaptiveActivationUpdateResultOk {
203
+ ok: true;
204
+ enabled: boolean;
205
+ serviceConfigured: boolean;
206
+ }
207
+ export interface AdaptiveActivationUpdateResultErr extends ConfigUpdateFailure {
208
+ ok: false;
209
+ }
210
+ export type AdaptiveActivationUpdateResult = AdaptiveActivationUpdateResultOk | AdaptiveActivationUpdateResultErr;
211
+ /**
212
+ * Write the workspace's Adaptive Activation settings.
213
+ *
214
+ * Supported payload (both fields optional, at least one required):
215
+ * { enabled?: boolean; service?: 'decisions-openrouter-respan' }
216
+ *
217
+ * Guarantees:
218
+ * - ZERO network: saving a configuration never sends a scoring request;
219
+ * - append-only v1: a non-empty `replaceableActivationIds` refuses BOTH a
220
+ * service write and `enabled: true`, while `enabled: false` always works;
221
+ * - the service section is workspace-scoped and shared with the other hosts,
222
+ * so it is not rewritten from this Codex entry while another host has
223
+ * Adaptive enabled;
224
+ * - enable requires a complete section — it is never "enabled but unusable".
225
+ */
226
+ export declare function updateAdaptiveActivationSettings(workspaceDir: string, payload: unknown): AdaptiveActivationUpdateResult;
186
227
  export interface FeatureFlagUpdateResultOk {
187
228
  ok: true;
188
229
  feature: string;
@@ -196,6 +237,13 @@ export interface FeatureFlagUpdateResultErr {
196
237
  nextAction?: string;
197
238
  }
198
239
  export type FeatureFlagUpdateResult = FeatureFlagUpdateResultOk | FeatureFlagUpdateResultErr;
240
+ /** Shared failure shape for config write operations (route layer maps statusCode). */
241
+ export interface ConfigUpdateFailure {
242
+ statusCode: number;
243
+ error: string;
244
+ message: string;
245
+ nextAction?: string;
246
+ }
199
247
  /**
200
248
  * Update a feature flag's `enabled` field in .pd/config.yaml.
201
249
  *
@@ -792,50 +792,44 @@ const _DEFAULT_FLAGS_RESULT = computeFeatureFlagsFromConfig(computeEffectivePdCo
792
792
  const REGISTERED_FEATURE_FLAG_NAMES = new Set(Object.keys(_DEFAULT_FLAGS_RESULT.flags));
793
793
  /** Map of flag ID → category, for preserving category when writing. */
794
794
  const DEFAULT_FLAG_CATEGORY = new Map(Object.entries(_DEFAULT_FLAGS_RESULT.flags).map(([id, flag]) => [id, flag.category]));
795
+ // ── Adaptive Activation (Codex desktop, append-only v1) ──────────────────────
796
+ /** Hosts that can run Adaptive scoring from this workspace's config. */
797
+ const ADAPTIVE_ACTIVATION_FLAG_NAMES = new Set([
798
+ 'host.codex.adaptive_activation',
799
+ 'host.openclaw.adaptive_activation',
800
+ 'host.workbuddy.adaptive_activation',
801
+ ]);
802
+ const CODEX_ADAPTIVE_ACTIVATION_FLAG = 'host.codex.adaptive_activation';
795
803
  /**
796
- * Update a feature flag's `enabled` field in .pd/config.yaml.
797
- *
798
- * Safe partial write: preserves unknown sections, validates before write.
799
- * Follows the load → validate → merge → atomic write pattern of
800
- * updateAgentBinding / updatePrinciplesOutputLanguage.
801
- *
802
- * Constraints (spec §13.4):
803
- * - featureName must be in the registered flag set (DEFAULT_FEATURE_FLAGS)
804
- * - Does NOT create a new `features:` section if absent (rejects)
805
- * - Atomic write + validates merged yaml can be re-parsed by loadPdConfig
806
- *
807
- * ERR entries (spec §13.9):
808
- * - ERR-001/ERR-005: enabled strictly typeof === 'boolean'; featureName
809
- * strictly checked against whitelist
810
- * - ERR-009: unknown featureName → ok:false with reason
811
- * - ERR-013: Object.hasOwn for features section existence check
812
- * - ERR-015/018/019: load-validate-merge-write-reload, no stale cache
804
+ * The ONE team-confirmed Decisions combination the Console offers on first
805
+ * setup. The endpoint/model/provider/credential-variable are frozen: the entry
806
+ * does not accept arbitrary addresses or arbitrary environment variable names.
813
807
  */
814
- export function updateFeatureFlag(workspaceDir, featureName, enabled) {
815
- // 1. Validate featureName against the registered whitelist
816
- if (!REGISTERED_FEATURE_FLAG_NAMES.has(featureName)) {
817
- return {
818
- ok: false,
819
- statusCode: 400,
820
- error: 'unknown_feature',
821
- message: `Unknown feature flag '${featureName}'. Registered flags: ${Array.from(REGISTERED_FEATURE_FLAG_NAMES).join(', ')}`,
822
- nextAction: `Use one of: ${Array.from(REGISTERED_FEATURE_FLAG_NAMES).join(', ')}`,
823
- };
824
- }
825
- // 2. Validate enabled is boolean (typeof check, no `as` — ERR-001)
826
- if (typeof enabled !== 'boolean') {
827
- return {
828
- ok: false,
829
- statusCode: 400,
830
- error: 'bad_request',
831
- message: `enabled must be a boolean. Got: ${typeof enabled}`,
832
- nextAction: 'Send { enabled: true } or { enabled: false }',
833
- };
834
- }
835
- // 3. Read raw config to preserve unknown sections + check features section
836
- // Check features section BEFORE loadPdConfig malformed check: a config
837
- // without a features section is rejected with 422 regardless of whether
838
- // the rest is valid or malformed (spec §13.4: 不允许新增).
808
+ export const ADAPTIVE_ACTIVATION_SERVICE_PRESET = {
809
+ id: 'decisions-openrouter-respan',
810
+ label: 'Decisions (OpenRouter / Respan)',
811
+ endpoint: 'https://openrouter.ai/api/alpha/decisions',
812
+ model: 'respan/span-01-lite:free',
813
+ provider: 'Respan',
814
+ apiKeyEnv: 'OPENROUTER_API_KEY',
815
+ /** Frozen EXACT response-model allowlist from the accepted real runs. */
816
+ responseModels: ['respan/span-01-lite:free', 'respan/span-01-lite-20260925'],
817
+ };
818
+ const ADAPTIVE_ACTIVATION_UPDATE_KEYS = new Set(['enabled', 'service']);
819
+ function isConfiguredSection(section) {
820
+ return section !== undefined
821
+ && typeof section.endpoint === 'string' && section.endpoint.length > 0
822
+ && typeof section.model === 'string' && section.model.length > 0
823
+ && typeof section.apiKeyEnv === 'string' && section.apiKeyEnv.length > 0;
824
+ }
825
+ /**
826
+ * Read + structurally validate the raw config for a partial write, creating an
827
+ * EMPTY `features:` map only when the key is absent (PRI-477). A `features:`
828
+ * value that exists but is not a map is a user error and is never reset
829
+ * (rc-9). Shared by the feature-flag write and the Adaptive Activation entry
830
+ * so both have IDENTICAL malformed-config behaviour.
831
+ */
832
+ function readRawConfigForUpdate(workspaceDir) {
839
833
  const configPath = getPdConfigPath(workspaceDir);
840
834
  let rawConfig;
841
835
  if (fs.existsSync(configPath)) {
@@ -845,51 +839,23 @@ export function updateFeatureFlag(workspaceDir, featureName, enabled) {
845
839
  }
846
840
  catch (err) {
847
841
  const message = errorMessage(err);
848
- return { ok: false, statusCode: 500, error: 'read_error', message: `Failed to read config for update: ${message}` };
842
+ return { ok: false, failure: { statusCode: 500, error: 'read_error', message: `Failed to read config for update: ${message}` } };
849
843
  }
850
844
  let rawParsed;
851
845
  try {
852
846
  rawParsed = yaml.load(rawContent, { schema: yaml.JSON_SCHEMA });
853
847
  }
854
848
  catch (err) {
855
- // YAML syntax error = malformed config (409, not 500). Consistent with
856
- // updateAgentBinding which treats loadPdConfig failures as conflict.
857
849
  const message = errorMessage(err);
858
- return { ok: false, statusCode: 409, error: 'conflict', message: `Cannot update feature flag: existing .pd/config.yaml is malformed. YAML parse error: ${message}` };
859
- }
860
- if (isRecord(rawParsed)) {
861
- rawConfig = { ...rawParsed };
862
- }
863
- else {
864
- rawConfig = {};
850
+ return { ok: false, failure: { statusCode: 409, error: 'conflict', message: `Cannot update feature flag: existing .pd/config.yaml is malformed. YAML parse error: ${message}` } };
865
851
  }
852
+ rawConfig = isRecord(rawParsed) ? { ...rawParsed } : {};
866
853
  }
867
854
  else {
868
855
  rawConfig = {};
869
856
  }
870
- // 4. PRI-477 onboarding: auto-create `features:` section ONLY when absent.
871
- // Original spec §13.4 "不允许新增" applied to UNREGISTERED flags —
872
- // auto-creating the section for registered flags (validated in step 1) is
873
- // safe and required for the FlagToggleCard one-click enable flow on fresh
874
- // installs where .pd/config.yaml has no features: section yet.
875
- //
876
- // IMPORTANT — Runtime Contract `rc-9-no-silent-fallback` (ERR-002):
877
- // If `features` EXISTS but is NOT a record/object, we must NOT silently
878
- // overwrite the user's malformed value with defaults — that would hide a
879
- // config error and lose the original mistake. Return 409 conflict so the
880
- // Owner can fix the config first. Without this guard, a config typo like
881
- // `features: "oops"` would be silently reset on the first flag toggle.
882
- //
883
- // Use Object.hasOwn for untrusted key check (ERR-013).
884
857
  let featuresSection;
885
858
  if (!Object.hasOwn(rawConfig, 'features')) {
886
- // Section absent — create an EMPTY features map (PRI-637). Defaults belong
887
- // in the registry, not in config: seeding the whole registered flag set here
888
- // would materialize an immortal default snapshot on the first toggle of a
889
- // fresh install. `features: {}` is fully valid — validatePdConfig only
890
- // requires the key to be an object, and the effective config merges missing
891
- // flags from DEFAULT_FEATURE_FLAGS at read time. Step 6 below then writes
892
- // exactly one flag: the one the Owner toggled.
893
859
  featuresSection = {};
894
860
  rawConfig.features = featuresSection;
895
861
  }
@@ -897,35 +863,243 @@ export function updateFeatureFlag(workspaceDir, featureName, enabled) {
897
863
  featuresSection = rawConfig.features;
898
864
  }
899
865
  else {
900
- // features: exists but is malformed (string, array, number, null, etc.).
901
- // Reject rather than silently resetting — rc-9-no-silent-fallback.
902
866
  const gotType = rawConfig.features === null ? 'null' : typeof rawConfig.features;
903
867
  return {
904
868
  ok: false,
905
- statusCode: 409,
906
- error: 'conflict',
907
- message: `Cannot update feature flag: .pd/config.yaml has a 'features:' section that ` +
908
- `is not an object/map (got ${gotType}). Fix the config file so 'features:' ` +
909
- `is a map of flag objects before retrying, or remove the 'features:' key ` +
910
- `entirely so PD can seed registered-flag defaults.`,
911
- nextAction: "Open .pd/config.yaml and set 'features: {}' (or remove the 'features:' line).",
869
+ failure: {
870
+ statusCode: 409,
871
+ error: 'conflict',
872
+ message: `Cannot update feature flag: .pd/config.yaml has a 'features:' section that ` +
873
+ `is not an object/map (got ${gotType}). Fix the config file so 'features:' ` +
874
+ `is a map of flag objects before retrying, or remove the 'features:' key ` +
875
+ `entirely so PD can seed registered-flag defaults.`,
876
+ nextAction: "Open .pd/config.yaml and set 'features: {}' (or remove the 'features:' line).",
877
+ },
912
878
  };
913
879
  }
914
- // 5. Validate the in-memory rawConfig (with auto-created features section).
915
- // NOTE: We do NOT call loadPdConfig(workspaceDir) here because that reads
916
- // from DISK, where the features section may still be missing (the exact
917
- // case we just auto-created for). Validating rawConfig in memory gives
918
- // the same malformed-config protection without the false-positive on
919
- // fresh installs. PRI-477.
920
880
  const existingConfigValidation = validatePdConfig(rawConfig);
921
881
  if (!existingConfigValidation.ok) {
882
+ return {
883
+ ok: false,
884
+ failure: {
885
+ statusCode: 409,
886
+ error: 'conflict',
887
+ message: `Cannot update feature flag: existing .pd/config.yaml is malformed. Fix config errors first. Errors: ${existingConfigValidation.errors.map(e => e.reason).join('; ')}`,
888
+ },
889
+ };
890
+ }
891
+ return { ok: true, configPath, rawConfig, featuresSection, config: existingConfigValidation.value };
892
+ }
893
+ /**
894
+ * Write the workspace's Adaptive Activation settings.
895
+ *
896
+ * Supported payload (both fields optional, at least one required):
897
+ * { enabled?: boolean; service?: 'decisions-openrouter-respan' }
898
+ *
899
+ * Guarantees:
900
+ * - ZERO network: saving a configuration never sends a scoring request;
901
+ * - append-only v1: a non-empty `replaceableActivationIds` refuses BOTH a
902
+ * service write and `enabled: true`, while `enabled: false` always works;
903
+ * - the service section is workspace-scoped and shared with the other hosts,
904
+ * so it is not rewritten from this Codex entry while another host has
905
+ * Adaptive enabled;
906
+ * - enable requires a complete section — it is never "enabled but unusable".
907
+ */
908
+ export function updateAdaptiveActivationSettings(workspaceDir, payload) {
909
+ if (!isRecord(payload)) {
910
+ return { ok: false, statusCode: 400, error: 'bad_request', message: 'Body must be a JSON object with enabled and/or service fields' };
911
+ }
912
+ for (const key of Object.keys(payload)) {
913
+ if (!ADAPTIVE_ACTIVATION_UPDATE_KEYS.has(key)) {
914
+ return { ok: false, statusCode: 400, error: 'unknown_field', message: `Unknown field '${key}'. Supported fields: enabled, service` };
915
+ }
916
+ }
917
+ const hasEnabled = Object.hasOwn(payload, 'enabled');
918
+ const hasService = Object.hasOwn(payload, 'service');
919
+ if (!hasEnabled && !hasService) {
920
+ return { ok: false, statusCode: 400, error: 'bad_request', message: 'Nothing to update: send enabled and/or service' };
921
+ }
922
+ if (hasEnabled && typeof payload.enabled !== 'boolean') {
923
+ return { ok: false, statusCode: 400, error: 'bad_request', message: `enabled must be a boolean. Got: ${typeof payload.enabled}` };
924
+ }
925
+ if (hasService && payload.service !== ADAPTIVE_ACTIVATION_SERVICE_PRESET.id) {
926
+ return {
927
+ ok: false,
928
+ statusCode: 400,
929
+ error: 'unknown_service',
930
+ message: `Unknown service '${String(payload.service)}'. The first version supports only '${ADAPTIVE_ACTIVATION_SERVICE_PRESET.id}'.`,
931
+ nextAction: 'Send { service: "decisions-openrouter-respan" }',
932
+ };
933
+ }
934
+ const enableRequested = hasEnabled && payload.enabled === true;
935
+ const rawRead = readRawConfigForUpdate(workspaceDir);
936
+ if (!rawRead.ok) {
937
+ return { ok: false, ...rawRead.failure };
938
+ }
939
+ const { configPath, rawConfig, featuresSection, config } = rawRead;
940
+ const currentSection = config.adaptiveActivation;
941
+ const replaceableIds = currentSection?.replaceableActivationIds ?? [];
942
+ if (replaceableIds.length > 0 && (hasService || enableRequested)) {
943
+ // Replacement mode is an existing Owner decision: preserve it untouched and
944
+ // offer the disable path rather than silently changing its semantics.
922
945
  return {
923
946
  ok: false,
924
947
  statusCode: 409,
925
- error: 'conflict',
926
- message: `Cannot update feature flag: existing .pd/config.yaml is malformed. Fix config errors first. Errors: ${existingConfigValidation.errors.map(e => e.reason).join('; ')}`,
948
+ error: 'append_only_conflict',
949
+ message: `This workspace configures adaptiveActivation.replaceableActivationIds (${replaceableIds.join(', ')}), which runs REPLACEMENT mode. The Console entry ships append-only and will not ${hasService ? 'rewrite the shared service configuration' : 'enable this mode'}.`,
950
+ nextAction: 'Keep the existing configuration unchanged (disable is still allowed), or remove adaptiveActivation.replaceableActivationIds in .pd/config.yaml to switch to append-only.',
951
+ };
952
+ }
953
+ const otherHostAaEnabled = ['host.openclaw.adaptive_activation', 'host.workbuddy.adaptive_activation']
954
+ .filter((name) => config.features[name]?.enabled === true);
955
+ if (hasService && otherHostAaEnabled.length > 0) {
956
+ return {
957
+ ok: false,
958
+ statusCode: 409,
959
+ error: 'shared_service_config_locked',
960
+ message: `Another host in this workspace already has Adaptive enabled (${otherHostAaEnabled.join(', ')}). The Decisions service configuration is shared per workspace and cannot be rewritten from the Codex entry.`,
961
+ nextAction: 'Disable the other host Adaptive flag in .pd/config.yaml first, then save the service configuration here.',
962
+ };
963
+ }
964
+ const effectiveSection = hasService
965
+ ? {
966
+ endpoint: ADAPTIVE_ACTIVATION_SERVICE_PRESET.endpoint,
967
+ model: ADAPTIVE_ACTIVATION_SERVICE_PRESET.model,
968
+ apiKeyEnv: ADAPTIVE_ACTIVATION_SERVICE_PRESET.apiKeyEnv,
969
+ }
970
+ : currentSection;
971
+ if (enableRequested && !isConfiguredSection(effectiveSection)) {
972
+ return {
973
+ ok: false,
974
+ statusCode: 400,
975
+ error: 'adaptive_activation_not_configured',
976
+ message: 'Cannot enable Adaptive Activation: no complete adaptiveActivation section (endpoint, model, apiKeyEnv) is configured in this workspace.',
977
+ nextAction: `Save the '${ADAPTIVE_ACTIVATION_SERVICE_PRESET.id}' service preset first, or add adaptiveActivation: {endpoint, model, apiKeyEnv} to .pd/config.yaml.`,
978
+ };
979
+ }
980
+ // Merge — preserve unrelated sections and every other feature entry.
981
+ const nextFeatures = { ...featuresSection };
982
+ if (hasEnabled) {
983
+ const existingEntry = Object.hasOwn(nextFeatures, CODEX_ADAPTIVE_ACTIVATION_FLAG)
984
+ ? nextFeatures[CODEX_ADAPTIVE_ACTIVATION_FLAG]
985
+ : undefined;
986
+ const category = (isRecord(existingEntry) && Object.hasOwn(existingEntry, 'category') && typeof existingEntry.category === 'string')
987
+ ? existingEntry.category
988
+ : (DEFAULT_FLAG_CATEGORY.get(CODEX_ADAPTIVE_ACTIVATION_FLAG) ?? 'quiet');
989
+ nextFeatures[CODEX_ADAPTIVE_ACTIVATION_FLAG] = { category, enabled: payload.enabled === true, source: 'owner' };
990
+ }
991
+ rawConfig.features = nextFeatures;
992
+ if (hasService) {
993
+ const existingSectionRaw = Object.hasOwn(rawConfig, 'adaptiveActivation') && isRecord(rawConfig.adaptiveActivation)
994
+ ? rawConfig.adaptiveActivation
995
+ : {};
996
+ rawConfig.adaptiveActivation = {
997
+ ...existingSectionRaw,
998
+ endpoint: ADAPTIVE_ACTIVATION_SERVICE_PRESET.endpoint,
999
+ model: ADAPTIVE_ACTIVATION_SERVICE_PRESET.model,
1000
+ apiKeyEnv: ADAPTIVE_ACTIVATION_SERVICE_PRESET.apiKeyEnv,
1001
+ provider: ADAPTIVE_ACTIVATION_SERVICE_PRESET.provider,
1002
+ responseModels: [...ADAPTIVE_ACTIVATION_SERVICE_PRESET.responseModels],
927
1003
  };
928
1004
  }
1005
+ const validation = validatePdConfig(rawConfig);
1006
+ if (!validation.ok) {
1007
+ return {
1008
+ ok: false,
1009
+ statusCode: 400,
1010
+ error: 'validation_error',
1011
+ message: `Updated config would be invalid: ${validation.errors.map(e => e.reason).join('; ')}`,
1012
+ nextAction: 'Fix config validation errors before retrying',
1013
+ };
1014
+ }
1015
+ try {
1016
+ writeConfigAtomic(configPath, rawConfig);
1017
+ }
1018
+ catch (err) {
1019
+ const message = errorMessage(err);
1020
+ return { ok: false, statusCode: 500, error: 'write_error', message: `Failed to write config: ${message}`, nextAction: 'Check disk space and file permissions for .pd/config.yaml' };
1021
+ }
1022
+ const confirmResult = loadPdConfig(workspaceDir);
1023
+ if (!confirmResult.ok) {
1024
+ return {
1025
+ ok: false,
1026
+ statusCode: 500,
1027
+ error: 'confirm_read_failed',
1028
+ message: 'Write succeeded but re-read failed: config is now malformed',
1029
+ nextAction: 'Inspect .pd/config.yaml manually for corruption',
1030
+ };
1031
+ }
1032
+ const confirmed = confirmResult.effective.config;
1033
+ return {
1034
+ ok: true,
1035
+ enabled: confirmed.features[CODEX_ADAPTIVE_ACTIVATION_FLAG]?.enabled === true,
1036
+ serviceConfigured: isConfiguredSection(confirmed.adaptiveActivation),
1037
+ };
1038
+ }
1039
+ /**
1040
+ * Update a feature flag's `enabled` field in .pd/config.yaml.
1041
+ *
1042
+ * Safe partial write: preserves unknown sections, validates before write.
1043
+ * Follows the load → validate → merge → atomic write pattern of
1044
+ * updateAgentBinding / updatePrinciplesOutputLanguage.
1045
+ *
1046
+ * Constraints (spec §13.4):
1047
+ * - featureName must be in the registered flag set (DEFAULT_FEATURE_FLAGS)
1048
+ * - Does NOT create a new `features:` section if absent (rejects)
1049
+ * - Atomic write + validates merged yaml can be re-parsed by loadPdConfig
1050
+ *
1051
+ * ERR entries (spec §13.9):
1052
+ * - ERR-001/ERR-005: enabled strictly typeof === 'boolean'; featureName
1053
+ * strictly checked against whitelist
1054
+ * - ERR-009: unknown featureName → ok:false with reason
1055
+ * - ERR-013: Object.hasOwn for features section existence check
1056
+ * - ERR-015/018/019: load-validate-merge-write-reload, no stale cache
1057
+ */
1058
+ export function updateFeatureFlag(workspaceDir, featureName, enabled) {
1059
+ // 1. Validate featureName against the registered whitelist
1060
+ if (!REGISTERED_FEATURE_FLAG_NAMES.has(featureName)) {
1061
+ return {
1062
+ ok: false,
1063
+ statusCode: 400,
1064
+ error: 'unknown_feature',
1065
+ message: `Unknown feature flag '${featureName}'. Registered flags: ${Array.from(REGISTERED_FEATURE_FLAG_NAMES).join(', ')}`,
1066
+ nextAction: `Use one of: ${Array.from(REGISTERED_FEATURE_FLAG_NAMES).join(', ')}`,
1067
+ };
1068
+ }
1069
+ // 2. Validate enabled is boolean (typeof check, no `as` — ERR-001)
1070
+ if (typeof enabled !== 'boolean') {
1071
+ return {
1072
+ ok: false,
1073
+ statusCode: 400,
1074
+ error: 'bad_request',
1075
+ message: `enabled must be a boolean. Got: ${typeof enabled}`,
1076
+ nextAction: 'Send { enabled: true } or { enabled: false }',
1077
+ };
1078
+ }
1079
+ // 3–5. Read raw config, seed an empty `features:` map when absent, reject a
1080
+ // malformed one, and validate the in-memory result. Shared with the
1081
+ // Adaptive Activation write (identical malformed-config behaviour).
1082
+ const rawRead = readRawConfigForUpdate(workspaceDir);
1083
+ if (!rawRead.ok) {
1084
+ return { ok: false, ...rawRead.failure };
1085
+ }
1086
+ const { configPath, rawConfig, featuresSection } = rawRead;
1087
+ // 5b. Append-only v1 boundary: enabling an Adaptive host while the shared
1088
+ // `replaceableActivationIds` opt-in is non-empty would run REPLACEMENT
1089
+ // mode. The generic toggle must not be able to cross that boundary
1090
+ // (the dedicated Adaptive entry refuses the same combination).
1091
+ if (enabled === true && ADAPTIVE_ACTIVATION_FLAG_NAMES.has(featureName)) {
1092
+ const replaceableIds = rawRead.config.adaptiveActivation?.replaceableActivationIds ?? [];
1093
+ if (replaceableIds.length > 0) {
1094
+ return {
1095
+ ok: false,
1096
+ statusCode: 409,
1097
+ error: 'append_only_conflict',
1098
+ message: `Cannot enable '${featureName}': this workspace configures adaptiveActivation.replaceableActivationIds (${replaceableIds.join(', ')}), which runs REPLACEMENT mode.`,
1099
+ nextAction: 'Remove adaptiveActivation.replaceableActivationIds in .pd/config.yaml to use append-only, or leave the existing configuration unchanged.',
1100
+ };
1101
+ }
1102
+ }
929
1103
  // 6. Merge: update features[featureName].enabled, preserving other flags
930
1104
  const existingFeatures = { ...featuresSection };
931
1105
  const existingEntry = Object.hasOwn(existingFeatures, featureName)
@@ -1048,11 +1222,17 @@ function extractProfileFields(payload, type) {
1048
1222
  }
1049
1223
  /**
1050
1224
  * Read raw config file preserving unknown root sections.
1051
- * Returns an empty record if the file does not exist.
1225
+ *
1226
+ * A missing file is seeded with the complete default config, not `{}`:
1227
+ * `validatePdConfig` requires `version`, `features` and `internalAgents`, so a
1228
+ * profile write to a fresh workspace must start from defaults. Writing an empty
1229
+ * record failed with "missing required field version/features/internalAgents".
1230
+ *
1052
1231
  * Treats parsed YAML as unknown (ERR-001).
1053
- */ function readRawConfig(configPath) {
1232
+ */
1233
+ function readRawConfig(configPath) {
1054
1234
  if (!fs.existsSync(configPath)) {
1055
- return {};
1235
+ return Object.fromEntries(Object.entries(computeEffectivePdConfig(null).config));
1056
1236
  }
1057
1237
  const rawContent = fs.readFileSync(configPath, 'utf8');
1058
1238
  const rawParsed = yaml.load(rawContent, { schema: yaml.JSON_SCHEMA });
@@ -14,6 +14,7 @@ import { EXPERIMENT_CONSOLE_PORT, defaultConsolePort } from './console-ports.js'
14
14
  import { WorkspaceService } from './models/WorkspaceService.js';
15
15
  import { handleFeedbackReportsRoute, handleFeedbackChannelsRoute, disposeFeedbackReportModels, } from './routes/feedback-reports.js';
16
16
  import { handleFailedTasksRoute, disposeFailedTasksModels } from './routes/failed-tasks.js';
17
+ import { handlePipelineHealthRoute, disposePipelineHealthModels } from './routes/pipeline-health.js';
17
18
  import { handleDiagnosticianRoute } from './routes/diagnostician.js';
18
19
  import { handleApprovalsRoute, disposeApprovalsModels } from './routes/approvals.js';
19
20
  import { handleHealthRoute, handleIngestionHealthRoute, disposeHealthModels } from './routes/health.js';
@@ -153,6 +154,8 @@ const MIME_MAP = {
153
154
  '.css': 'text/css; charset=utf-8',
154
155
  '.json': 'application/json; charset=utf-8',
155
156
  '.png': 'image/png',
157
+ '.jpg': 'image/jpeg',
158
+ '.webp': 'image/webp',
156
159
  '.svg': 'image/svg+xml',
157
160
  '.ico': 'image/x-icon',
158
161
  '.woff': 'font/woff',
@@ -200,6 +203,10 @@ function serveFile(res, filePath) {
200
203
  // recovery probe budget from the same constant (strictly smaller), so a probe
201
204
  // can never outlive the request that awaits it.
202
205
  export const REQUEST_TIMEOUT_MS = CONSOLE_REQUEST_BUDGET_MS;
206
+ // PRI-1213: the one route that waits on a remote provider. The probe itself is
207
+ // bounded (15s model list + 20s minimal chat, no retries); this only keeps the
208
+ // transport wrapper from 504-ing before that bound is reached.
209
+ const CONNECTION_PROBE_TIMEOUT_MS = 60_000;
203
210
  const UPDATE_APPLY_TIMEOUT_MS = 120000;
204
211
  // Full update downloads a tarball + copies files — allow 3 min for slow networks.
205
212
  // PD_UPDATE_APPLY_FULL_TIMEOUT_MS (ms) overrides it for slow-disk machines:
@@ -313,6 +320,7 @@ export async function initServices(workspaceDir) {
313
320
  export async function closeServices() {
314
321
  disposeFeedbackReportModels();
315
322
  disposeFailedTasksModels();
323
+ disposePipelineHealthModels();
316
324
  disposeReceiptsModels();
317
325
  disposeApprovalsModels();
318
326
  disposeApprovalsGroupedModels();
@@ -392,6 +400,13 @@ export function handleRequest(services) {
392
400
  asyncHandler(() => handleDiagnosticianRoute(req, res, { workspaceDir: services.workspaceDir, subPath, featureFlags: services.feedbackFlags }))(req, res);
393
401
  return;
394
402
  }
403
+ // SPEC-PD-PIPELINE-RELIABILITY-AND-EFFICIENCY-001 §3.4: read-only
404
+ // pipeline metrics (queue/latency/reliability/provider) derived from
405
+ // state.db. Registered before the failed-tasks mount (different prefix).
406
+ if (routePath === '/api/pipeline-health') {
407
+ asyncHandler(() => handlePipelineHealthRoute(req, res, { workspaceDir: services.workspaceDir, featureFlags: services.feedbackFlags }))(req, res);
408
+ return;
409
+ }
395
410
  // Task 9: GET /api/failed-tasks, /api/failed-tasks/:id
396
411
  if (routePath === '/api/failed-tasks' || routePath.startsWith('/api/failed-tasks/')) {
397
412
  const subPath = routePath.slice('/api/failed-tasks'.length);
@@ -491,7 +506,7 @@ export function handleRequest(services) {
491
506
  // /api/config/agents/:name/binding, /api/config/readiness/:name
492
507
  if (routePath === '/api/config' || routePath.startsWith('/api/config/')) {
493
508
  const subPath = routePath.slice('/api/config'.length);
494
- asyncHandler(() => handleConfigRoute(req, res, { workspaceDir: services.workspaceDir, subPath }))(req, res);
509
+ asyncHandler(() => handleConfigRoute(req, res, { workspaceDir: services.workspaceDir, subPath }), subPath === '/connection-test' ? CONNECTION_PROBE_TIMEOUT_MS : REQUEST_TIMEOUT_MS)(req, res);
495
510
  return;
496
511
  }
497
512
  // CR8: GET /api/lifecycle/principles/:principleId