create-principles-disciple 1.85.0 → 1.87.0

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 (1338) hide show
  1. package/console/dist/server/index.js +6 -50
  2. package/console/dist/server/models/ActivationsConsoleModel.d.ts +0 -4
  3. package/console/dist/server/models/ActivationsConsoleModel.js +64 -72
  4. package/console/dist/server/models/ApprovalsConsoleModel.d.ts +33 -7
  5. package/console/dist/server/models/ApprovalsConsoleModel.js +203 -57
  6. package/console/dist/server/models/ApprovalsGroupedConsoleModel.d.ts +4 -2
  7. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +179 -91
  8. package/console/dist/server/models/EvidenceChainConsoleModel.d.ts +4 -28
  9. package/console/dist/server/models/EvidenceChainConsoleModel.js +103 -298
  10. package/console/dist/server/models/GovernanceConsoleModel.d.ts +6 -4
  11. package/console/dist/server/models/GovernanceConsoleModel.js +269 -195
  12. package/console/dist/server/models/PrincipleClassifier.js +1 -1
  13. package/console/dist/server/models/PrincipleTrajectoryModel.d.ts +49 -0
  14. package/console/dist/server/models/PrincipleTrajectoryModel.js +485 -0
  15. package/console/dist/server/routes/approvals.js +65 -2
  16. package/console/dist/server/routes/principles.js +33 -0
  17. package/console/dist/server/routes/update.js +75 -26
  18. package/console/dist/ui/App.js +4 -2
  19. package/console/dist/ui/api.d.ts +6 -11
  20. package/console/dist/ui/api.js +19 -23
  21. package/console/dist/ui/components/focus/daily-thought-card.d.ts +1 -0
  22. package/console/dist/ui/components/focus/daily-thought-card.js +41 -0
  23. package/console/dist/ui/components/layout/app-sidebar.js +6 -4
  24. package/console/dist/ui/components/layout/page-loading.d.ts +13 -0
  25. package/console/dist/ui/components/layout/page-loading.js +14 -0
  26. package/console/dist/ui/components/layout/page-shell.d.ts +1 -0
  27. package/console/dist/ui/components/layout/page-shell.js +2 -1
  28. package/console/dist/ui/components/layout/section-title.js +1 -1
  29. package/console/dist/ui/components/notifications/NotificationProvider.d.ts +14 -0
  30. package/console/dist/ui/components/notifications/NotificationProvider.js +130 -0
  31. package/console/dist/ui/components/notifications/favicon-badge.d.ts +3 -0
  32. package/console/dist/ui/components/notifications/favicon-badge.js +68 -0
  33. package/console/dist/ui/components/notifications/notification-reducer.d.ts +9 -0
  34. package/console/dist/ui/components/notifications/notification-reducer.js +9 -0
  35. package/console/dist/ui/components/notifications/sound-storage.d.ts +3 -0
  36. package/console/dist/ui/components/notifications/sound-storage.js +37 -0
  37. package/console/dist/ui/components/notifications/useNotifications.d.ts +1 -0
  38. package/console/dist/ui/components/notifications/useNotifications.js +9 -0
  39. package/console/dist/ui/components/ui/badge.js +1 -1
  40. package/console/dist/ui/components/ui/button.d.ts +2 -2
  41. package/console/dist/ui/components/ui/button.js +1 -1
  42. package/console/dist/ui/components/ui/card.js +1 -1
  43. package/console/dist/ui/components/ui/input.js +1 -1
  44. package/console/dist/ui/components/ui/sheet.d.ts +1 -1
  45. package/console/dist/ui/data/daily-thoughts.d.ts +15 -0
  46. package/console/dist/ui/data/daily-thoughts.js +164 -0
  47. package/console/dist/ui/hooks/useNotificationSound.d.ts +12 -0
  48. package/console/dist/ui/hooks/useNotificationSound.js +74 -0
  49. package/console/dist/ui/i18n/en.json +94 -12
  50. package/console/dist/ui/i18n/zh-CN.json +94 -12
  51. package/console/dist/ui/pages/activation/ActivationPage.js +8 -15
  52. package/console/dist/ui/pages/control-center/ControlCenterPage.js +11 -9
  53. package/console/dist/ui/pages/focus/FocusPage.d.ts +13 -0
  54. package/console/dist/ui/pages/focus/FocusPage.js +140 -19
  55. package/console/dist/ui/pages/pain/PainPage.js +71 -32
  56. package/console/dist/ui/pages/pain/pain-card-helpers.d.ts +100 -0
  57. package/console/dist/ui/pages/pain/pain-card-helpers.js +103 -0
  58. package/console/dist/ui/pages/principles/PrincipleDetailPage.js +99 -20
  59. package/console/dist/ui/pages/principles/PrinciplesPage.js +8 -8
  60. package/console/dist/ui/pages/report-problem/ReportProblemPage.js +20 -18
  61. package/console/dist/ui/pages/settings/SettingsPage.js +9 -5
  62. package/console/dist/ui/pages/settings/UpdatePage.d.ts +0 -4
  63. package/console/dist/ui/pages/settings/UpdatePage.js +78 -75
  64. package/console/dist/ui/utils/control-center-helpers.d.ts +2 -0
  65. package/console/dist/ui/utils/enum-labels.d.ts +50 -0
  66. package/console/dist/ui/utils/enum-labels.js +164 -0
  67. package/console/dist/ui/utils/validators.d.ts +62 -6
  68. package/console/dist/ui/utils/validators.js +222 -22
  69. package/console/dist/web/assets/app.css +269 -122
  70. package/console/dist/web/assets/app.js +8134 -3177
  71. package/console/package.json +6 -3
  72. package/core/dist/evolution-store.js +0 -2
  73. package/core/dist/evolution-store.js.map +1 -1
  74. package/core/dist/index.d.ts +1 -10
  75. package/core/dist/index.d.ts.map +1 -1
  76. package/core/dist/index.js +1 -7
  77. package/core/dist/index.js.map +1 -1
  78. package/core/dist/io.d.ts +0 -1
  79. package/core/dist/io.d.ts.map +1 -1
  80. package/core/dist/io.js +0 -4
  81. package/core/dist/io.js.map +1 -1
  82. package/core/dist/principle-injector.d.ts +1 -1
  83. package/core/dist/principle-injector.d.ts.map +1 -1
  84. package/core/dist/prompt-builder/__tests__/prompt-builder-core.test.js.map +1 -1
  85. package/core/dist/quality-scorecard/__tests__/quality-scorecard.test.d.ts +2 -0
  86. package/core/dist/quality-scorecard/__tests__/quality-scorecard.test.d.ts.map +1 -0
  87. package/core/dist/quality-scorecard/__tests__/quality-scorecard.test.js +531 -0
  88. package/core/dist/quality-scorecard/__tests__/quality-scorecard.test.js.map +1 -0
  89. package/core/dist/quality-scorecard/index.d.ts +11 -0
  90. package/core/dist/quality-scorecard/index.d.ts.map +1 -0
  91. package/core/dist/quality-scorecard/index.js +4 -0
  92. package/core/dist/quality-scorecard/index.js.map +1 -0
  93. package/core/dist/quality-scorecard/report-generator.d.ts +11 -0
  94. package/core/dist/quality-scorecard/report-generator.d.ts.map +1 -0
  95. package/core/dist/quality-scorecard/report-generator.js +204 -0
  96. package/core/dist/quality-scorecard/report-generator.js.map +1 -0
  97. package/core/dist/quality-scorecard/types.d.ts +106 -0
  98. package/core/dist/quality-scorecard/types.d.ts.map +1 -0
  99. package/core/dist/quality-scorecard/types.js +51 -0
  100. package/core/dist/quality-scorecard/types.js.map +1 -0
  101. package/core/dist/quality-scorecard/validation.d.ts +73 -0
  102. package/core/dist/quality-scorecard/validation.d.ts.map +1 -0
  103. package/core/dist/quality-scorecard/validation.js +251 -0
  104. package/core/dist/quality-scorecard/validation.js.map +1 -0
  105. package/core/dist/runtime-v2/__tests__/activation-types-helpers.test.d.ts +20 -0
  106. package/core/dist/runtime-v2/__tests__/activation-types-helpers.test.d.ts.map +1 -0
  107. package/core/dist/runtime-v2/__tests__/activation-types-helpers.test.js +223 -0
  108. package/core/dist/runtime-v2/__tests__/activation-types-helpers.test.js.map +1 -0
  109. package/core/dist/runtime-v2/__tests__/admission-gate.test.js +56 -3
  110. package/core/dist/runtime-v2/__tests__/admission-gate.test.js.map +1 -1
  111. package/core/dist/runtime-v2/__tests__/adversarial-loop.test.d.ts +2 -0
  112. package/core/dist/runtime-v2/__tests__/adversarial-loop.test.d.ts.map +1 -0
  113. package/core/dist/runtime-v2/__tests__/adversarial-loop.test.js +381 -0
  114. package/core/dist/runtime-v2/__tests__/adversarial-loop.test.js.map +1 -0
  115. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +175 -83
  116. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  117. package/core/dist/runtime-v2/__tests__/artificer-runner-vslice.test.js +40 -80
  118. package/core/dist/runtime-v2/__tests__/artificer-runner-vslice.test.js.map +1 -1
  119. package/core/dist/runtime-v2/__tests__/attack-e2e-pipeline-smoke.test.js +126 -21
  120. package/core/dist/runtime-v2/__tests__/attack-e2e-pipeline-smoke.test.js.map +1 -1
  121. package/core/dist/runtime-v2/__tests__/build-golden-trace-from-artificer.test.d.ts +2 -0
  122. package/core/dist/runtime-v2/__tests__/build-golden-trace-from-artificer.test.d.ts.map +1 -0
  123. package/core/dist/runtime-v2/__tests__/build-golden-trace-from-artificer.test.js +169 -0
  124. package/core/dist/runtime-v2/__tests__/build-golden-trace-from-artificer.test.js.map +1 -0
  125. package/core/dist/runtime-v2/__tests__/build-l2-principle-reader.test.d.ts +2 -0
  126. package/core/dist/runtime-v2/__tests__/build-l2-principle-reader.test.d.ts.map +1 -0
  127. package/core/dist/runtime-v2/__tests__/build-l2-principle-reader.test.js +200 -0
  128. package/core/dist/runtime-v2/__tests__/build-l2-principle-reader.test.js.map +1 -0
  129. package/core/dist/runtime-v2/__tests__/chain-integrity-real-path.test.js +20 -3
  130. package/core/dist/runtime-v2/__tests__/chain-integrity-real-path.test.js.map +1 -1
  131. package/core/dist/runtime-v2/__tests__/dreamer-output-validator.test.js.map +1 -1
  132. package/core/dist/runtime-v2/__tests__/dreamer-runner-vslice.test.js +12 -0
  133. package/core/dist/runtime-v2/__tests__/dreamer-runner-vslice.test.js.map +1 -1
  134. package/core/dist/runtime-v2/__tests__/dreamer-runner.test.js +10 -5
  135. package/core/dist/runtime-v2/__tests__/dreamer-runner.test.js.map +1 -1
  136. package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.d.ts +2 -0
  137. package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.d.ts.map +1 -0
  138. package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.js +831 -0
  139. package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.js.map +1 -0
  140. package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice.test.js +22 -0
  141. package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice.test.js.map +1 -1
  142. package/core/dist/runtime-v2/__tests__/evidence-chain-contract.test.d.ts +2 -0
  143. package/core/dist/runtime-v2/__tests__/evidence-chain-contract.test.d.ts.map +1 -0
  144. package/core/dist/runtime-v2/__tests__/evidence-chain-contract.test.js +344 -0
  145. package/core/dist/runtime-v2/__tests__/evidence-chain-contract.test.js.map +1 -0
  146. package/core/dist/runtime-v2/__tests__/evidence-guards.test.d.ts +18 -0
  147. package/core/dist/runtime-v2/__tests__/evidence-guards.test.d.ts.map +1 -0
  148. package/core/dist/runtime-v2/__tests__/evidence-guards.test.js +155 -0
  149. package/core/dist/runtime-v2/__tests__/evidence-guards.test.js.map +1 -0
  150. package/core/dist/runtime-v2/__tests__/evidence-sanitizer.test.js +4 -3
  151. package/core/dist/runtime-v2/__tests__/evidence-sanitizer.test.js.map +1 -1
  152. package/core/dist/runtime-v2/__tests__/feedback/privacy-preview.test.js.map +1 -1
  153. package/core/dist/runtime-v2/__tests__/feedback/render-github-url.test.js.map +1 -1
  154. package/core/dist/runtime-v2/__tests__/feedback/render-markdown.test.js.map +1 -1
  155. package/core/dist/runtime-v2/__tests__/fixtures/llm-e2e-config.d.ts.map +1 -1
  156. package/core/dist/runtime-v2/__tests__/fixtures/llm-e2e-config.js +3 -2
  157. package/core/dist/runtime-v2/__tests__/fixtures/llm-e2e-config.js.map +1 -1
  158. package/core/dist/runtime-v2/__tests__/fixtures/llm-e2e-config.test.js +19 -29
  159. package/core/dist/runtime-v2/__tests__/fixtures/llm-e2e-config.test.js.map +1 -1
  160. package/core/dist/runtime-v2/__tests__/full-chain-real-llm.test.js +2 -2
  161. package/core/dist/runtime-v2/__tests__/full-chain-real-llm.test.js.map +1 -1
  162. package/core/dist/runtime-v2/__tests__/golden-path-diagnostician-e2e.test.d.ts +2 -0
  163. package/core/dist/runtime-v2/__tests__/golden-path-diagnostician-e2e.test.d.ts.map +1 -0
  164. package/core/dist/runtime-v2/__tests__/golden-path-diagnostician-e2e.test.js +372 -0
  165. package/core/dist/runtime-v2/__tests__/golden-path-diagnostician-e2e.test.js.map +1 -0
  166. package/core/dist/runtime-v2/__tests__/intake-to-internalization-bridge.test.js +219 -2
  167. package/core/dist/runtime-v2/__tests__/intake-to-internalization-bridge.test.js.map +1 -1
  168. package/core/dist/runtime-v2/__tests__/internalization-chain-integrity-read-model.test.js +96 -0
  169. package/core/dist/runtime-v2/__tests__/internalization-chain-integrity-read-model.test.js.map +1 -1
  170. package/core/dist/runtime-v2/__tests__/internalization-consumer-product-path.test.d.ts +2 -0
  171. package/core/dist/runtime-v2/__tests__/internalization-consumer-product-path.test.d.ts.map +1 -0
  172. package/core/dist/runtime-v2/__tests__/internalization-consumer-product-path.test.js +226 -0
  173. package/core/dist/runtime-v2/__tests__/internalization-consumer-product-path.test.js.map +1 -0
  174. package/core/dist/runtime-v2/__tests__/internalization-failure-persistence.test.d.ts +2 -0
  175. package/core/dist/runtime-v2/__tests__/internalization-failure-persistence.test.d.ts.map +1 -0
  176. package/core/dist/runtime-v2/__tests__/internalization-failure-persistence.test.js +153 -0
  177. package/core/dist/runtime-v2/__tests__/internalization-failure-persistence.test.js.map +1 -0
  178. package/core/dist/runtime-v2/__tests__/internalization-integrity-remediation.test.js +525 -5
  179. package/core/dist/runtime-v2/__tests__/internalization-integrity-remediation.test.js.map +1 -1
  180. package/core/dist/runtime-v2/__tests__/internalization-orchestrator.test.js +1 -3
  181. package/core/dist/runtime-v2/__tests__/internalization-orchestrator.test.js.map +1 -1
  182. package/core/dist/runtime-v2/__tests__/internalization-peer-runner-contracts.test.js +6 -0
  183. package/core/dist/runtime-v2/__tests__/internalization-peer-runner-contracts.test.js.map +1 -1
  184. package/core/dist/runtime-v2/__tests__/internalization-queue-read-model.test.js +0 -1
  185. package/core/dist/runtime-v2/__tests__/internalization-queue-read-model.test.js.map +1 -1
  186. package/core/dist/runtime-v2/__tests__/internalization-state-machine.test.js.map +1 -1
  187. package/core/dist/runtime-v2/__tests__/mainline-contract.test.d.ts +2 -0
  188. package/core/dist/runtime-v2/__tests__/mainline-contract.test.d.ts.map +1 -0
  189. package/core/dist/runtime-v2/__tests__/mainline-contract.test.js +194 -0
  190. package/core/dist/runtime-v2/__tests__/mainline-contract.test.js.map +1 -0
  191. package/core/dist/runtime-v2/__tests__/mainline-product-path.test.d.ts +2 -0
  192. package/core/dist/runtime-v2/__tests__/mainline-product-path.test.d.ts.map +1 -0
  193. package/core/dist/runtime-v2/__tests__/mainline-product-path.test.js +429 -0
  194. package/core/dist/runtime-v2/__tests__/mainline-product-path.test.js.map +1 -0
  195. package/core/dist/runtime-v2/__tests__/pain-chain-read-model.test.js +0 -1
  196. package/core/dist/runtime-v2/__tests__/pain-chain-read-model.test.js.map +1 -1
  197. package/core/dist/runtime-v2/__tests__/pain-evidence-contract.test.js +5 -2
  198. package/core/dist/runtime-v2/__tests__/pain-evidence-contract.test.js.map +1 -1
  199. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-retried.test.js +10 -6
  200. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-retried.test.js.map +1 -1
  201. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-short-circuit.test.d.ts +2 -0
  202. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-short-circuit.test.d.ts.map +1 -0
  203. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-short-circuit.test.js +211 -0
  204. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-short-circuit.test.js.map +1 -0
  205. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-workspace-dir.test.d.ts +2 -0
  206. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-workspace-dir.test.d.ts.map +1 -0
  207. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-workspace-dir.test.js +182 -0
  208. package/core/dist/runtime-v2/__tests__/pain-signal-bridge-workspace-dir.test.js.map +1 -0
  209. package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js +53 -0
  210. package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js.map +1 -1
  211. package/core/dist/runtime-v2/__tests__/philosopher-runner-vslice.test.js +4 -0
  212. package/core/dist/runtime-v2/__tests__/philosopher-runner-vslice.test.js.map +1 -1
  213. package/core/dist/runtime-v2/__tests__/pitask-metadata.test.js +5 -1
  214. package/core/dist/runtime-v2/__tests__/pitask-metadata.test.js.map +1 -1
  215. package/core/dist/runtime-v2/__tests__/principle-compiler-core.test.js +85 -7
  216. package/core/dist/runtime-v2/__tests__/principle-compiler-core.test.js.map +1 -1
  217. package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js +14 -1
  218. package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js.map +1 -1
  219. package/core/dist/runtime-v2/__tests__/pruning-read-model.test.js +11 -6
  220. package/core/dist/runtime-v2/__tests__/pruning-read-model.test.js.map +1 -1
  221. package/core/dist/runtime-v2/__tests__/rollout-reviewer-runner-vslice.test.js +8 -0
  222. package/core/dist/runtime-v2/__tests__/rollout-reviewer-runner-vslice.test.js.map +1 -1
  223. package/core/dist/runtime-v2/__tests__/rulehost-oob-defense-simulation.test.js.map +1 -1
  224. package/core/dist/runtime-v2/__tests__/scribe-runner-vslice.test.js +4 -0
  225. package/core/dist/runtime-v2/__tests__/scribe-runner-vslice.test.js.map +1 -1
  226. package/core/dist/runtime-v2/__tests__/stalled-diagnostician-task.test.d.ts +2 -0
  227. package/core/dist/runtime-v2/__tests__/stalled-diagnostician-task.test.d.ts.map +1 -0
  228. package/core/dist/runtime-v2/__tests__/stalled-diagnostician-task.test.js +168 -0
  229. package/core/dist/runtime-v2/__tests__/stalled-diagnostician-task.test.js.map +1 -0
  230. package/core/dist/runtime-v2/__tests__/task-three-strikes.test.js.map +1 -1
  231. package/core/dist/runtime-v2/__tests__/trace-refiner-agent.test.js.map +1 -1
  232. package/core/dist/runtime-v2/__tests__/trainer-output-validator.test.js.map +1 -1
  233. package/core/dist/runtime-v2/__tests__/trainer-runner-vslice.test.js +8 -0
  234. package/core/dist/runtime-v2/__tests__/trainer-runner-vslice.test.js.map +1 -1
  235. package/core/dist/runtime-v2/activation/__tests__/activation-dispatcher.test.js +7 -1
  236. package/core/dist/runtime-v2/activation/__tests__/activation-dispatcher.test.js.map +1 -1
  237. package/core/dist/runtime-v2/activation/__tests__/approval-completion-service.test.d.ts +21 -0
  238. package/core/dist/runtime-v2/activation/__tests__/approval-completion-service.test.d.ts.map +1 -0
  239. package/core/dist/runtime-v2/activation/__tests__/approval-completion-service.test.js +363 -0
  240. package/core/dist/runtime-v2/activation/__tests__/approval-completion-service.test.js.map +1 -0
  241. package/core/dist/runtime-v2/activation/__tests__/approval-queue.test.d.ts +15 -0
  242. package/core/dist/runtime-v2/activation/__tests__/approval-queue.test.d.ts.map +1 -1
  243. package/core/dist/runtime-v2/activation/__tests__/approval-queue.test.js +339 -164
  244. package/core/dist/runtime-v2/activation/__tests__/approval-queue.test.js.map +1 -1
  245. package/core/dist/runtime-v2/activation/__tests__/approval-store-extended.test.js +0 -1
  246. package/core/dist/runtime-v2/activation/__tests__/approval-store-extended.test.js.map +1 -1
  247. package/core/dist/runtime-v2/activation/__tests__/edit-then-approve.test.d.ts +20 -0
  248. package/core/dist/runtime-v2/activation/__tests__/edit-then-approve.test.d.ts.map +1 -0
  249. package/core/dist/runtime-v2/activation/__tests__/edit-then-approve.test.js +145 -0
  250. package/core/dist/runtime-v2/activation/__tests__/edit-then-approve.test.js.map +1 -0
  251. package/core/dist/runtime-v2/activation/__tests__/low-risk-writers.test.d.ts +21 -0
  252. package/core/dist/runtime-v2/activation/__tests__/low-risk-writers.test.d.ts.map +1 -0
  253. package/core/dist/runtime-v2/activation/__tests__/low-risk-writers.test.js +468 -0
  254. package/core/dist/runtime-v2/activation/__tests__/low-risk-writers.test.js.map +1 -0
  255. package/core/dist/runtime-v2/activation/__tests__/production-gate-deps.test.d.ts +15 -0
  256. package/core/dist/runtime-v2/activation/__tests__/production-gate-deps.test.d.ts.map +1 -0
  257. package/core/dist/runtime-v2/activation/__tests__/production-gate-deps.test.js +272 -0
  258. package/core/dist/runtime-v2/activation/__tests__/production-gate-deps.test.js.map +1 -0
  259. package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js +11 -0
  260. package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js.map +1 -1
  261. package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js +54 -1
  262. package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js.map +1 -1
  263. package/core/dist/runtime-v2/activation/__tests__/story-a-acceptance.test.d.ts +35 -0
  264. package/core/dist/runtime-v2/activation/__tests__/story-a-acceptance.test.d.ts.map +1 -0
  265. package/core/dist/runtime-v2/activation/__tests__/story-a-acceptance.test.js +511 -0
  266. package/core/dist/runtime-v2/activation/__tests__/story-a-acceptance.test.js.map +1 -0
  267. package/core/dist/runtime-v2/activation/activation-dispatcher.d.ts.map +1 -1
  268. package/core/dist/runtime-v2/activation/activation-dispatcher.js +87 -1
  269. package/core/dist/runtime-v2/activation/activation-dispatcher.js.map +1 -1
  270. package/core/dist/runtime-v2/activation/activation-types.d.ts +49 -2
  271. package/core/dist/runtime-v2/activation/activation-types.d.ts.map +1 -1
  272. package/core/dist/runtime-v2/activation/activation-types.js +6 -0
  273. package/core/dist/runtime-v2/activation/activation-types.js.map +1 -1
  274. package/core/dist/runtime-v2/activation/approval-completion-service.d.ts +50 -0
  275. package/core/dist/runtime-v2/activation/approval-completion-service.d.ts.map +1 -0
  276. package/core/dist/runtime-v2/activation/approval-completion-service.js +160 -0
  277. package/core/dist/runtime-v2/activation/approval-completion-service.js.map +1 -0
  278. package/core/dist/runtime-v2/activation/approval-queue.d.ts +7 -1
  279. package/core/dist/runtime-v2/activation/approval-queue.d.ts.map +1 -1
  280. package/core/dist/runtime-v2/activation/approval-queue.js +14 -0
  281. package/core/dist/runtime-v2/activation/approval-queue.js.map +1 -1
  282. package/core/dist/runtime-v2/activation/index.d.ts +5 -2
  283. package/core/dist/runtime-v2/activation/index.d.ts.map +1 -1
  284. package/core/dist/runtime-v2/activation/index.js +8 -1
  285. package/core/dist/runtime-v2/activation/index.js.map +1 -1
  286. package/core/dist/runtime-v2/activation/memory-activation-state-store.d.ts +2 -1
  287. package/core/dist/runtime-v2/activation/memory-activation-state-store.d.ts.map +1 -1
  288. package/core/dist/runtime-v2/activation/memory-activation-state-store.js +11 -2
  289. package/core/dist/runtime-v2/activation/memory-activation-state-store.js.map +1 -1
  290. package/core/dist/runtime-v2/activation/memory-approval-store.d.ts +2 -1
  291. package/core/dist/runtime-v2/activation/memory-approval-store.d.ts.map +1 -1
  292. package/core/dist/runtime-v2/activation/memory-approval-store.js +18 -0
  293. package/core/dist/runtime-v2/activation/memory-approval-store.js.map +1 -1
  294. package/core/dist/runtime-v2/activation/production-gate-deps.d.ts +32 -0
  295. package/core/dist/runtime-v2/activation/production-gate-deps.d.ts.map +1 -0
  296. package/core/dist/runtime-v2/activation/production-gate-deps.js +213 -0
  297. package/core/dist/runtime-v2/activation/production-gate-deps.js.map +1 -0
  298. package/core/dist/runtime-v2/activation/sqlite-activation-state-store.d.ts +2 -1
  299. package/core/dist/runtime-v2/activation/sqlite-activation-state-store.d.ts.map +1 -1
  300. package/core/dist/runtime-v2/activation/sqlite-activation-state-store.js +21 -7
  301. package/core/dist/runtime-v2/activation/sqlite-activation-state-store.js.map +1 -1
  302. package/core/dist/runtime-v2/activation/sqlite-approval-store.d.ts +2 -1
  303. package/core/dist/runtime-v2/activation/sqlite-approval-store.d.ts.map +1 -1
  304. package/core/dist/runtime-v2/activation/sqlite-approval-store.js +24 -0
  305. package/core/dist/runtime-v2/activation/sqlite-approval-store.js.map +1 -1
  306. package/core/dist/runtime-v2/adapter/__tests__/artificer-l2-adapter.test.d.ts +2 -0
  307. package/core/dist/runtime-v2/adapter/__tests__/artificer-l2-adapter.test.d.ts.map +1 -0
  308. package/core/dist/runtime-v2/adapter/__tests__/artificer-l2-adapter.test.js +340 -0
  309. package/core/dist/runtime-v2/adapter/__tests__/artificer-l2-adapter.test.js.map +1 -0
  310. package/core/dist/runtime-v2/adapter/__tests__/l2-agent-loop-adapter.test.d.ts +2 -0
  311. package/core/dist/runtime-v2/adapter/__tests__/l2-agent-loop-adapter.test.d.ts.map +1 -0
  312. package/core/dist/runtime-v2/adapter/__tests__/l2-agent-loop-adapter.test.js +420 -0
  313. package/core/dist/runtime-v2/adapter/__tests__/l2-agent-loop-adapter.test.js.map +1 -0
  314. package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js +283 -1
  315. package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js.map +1 -1
  316. package/core/dist/runtime-v2/adapter/__tests__/schema-prompt-adapter.test.js +4 -4
  317. package/core/dist/runtime-v2/adapter/__tests__/schema-prompt-adapter.test.js.map +1 -1
  318. package/core/dist/runtime-v2/adapter/__tests__/structured-output-repair.test.js.map +1 -1
  319. package/core/dist/runtime-v2/adapter/__tests__/test-double-runtime-adapter.test.js +221 -0
  320. package/core/dist/runtime-v2/adapter/__tests__/test-double-runtime-adapter.test.js.map +1 -1
  321. package/core/dist/runtime-v2/adapter/artificer-l2-adapter.d.ts +49 -0
  322. package/core/dist/runtime-v2/adapter/artificer-l2-adapter.d.ts.map +1 -0
  323. package/core/dist/runtime-v2/adapter/artificer-l2-adapter.js +319 -0
  324. package/core/dist/runtime-v2/adapter/artificer-l2-adapter.js.map +1 -0
  325. package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.d.ts +78 -0
  326. package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.d.ts.map +1 -0
  327. package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.js +478 -0
  328. package/core/dist/runtime-v2/adapter/l2-agent-loop-adapter.js.map +1 -0
  329. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts +6 -0
  330. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  331. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +33 -9
  332. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
  333. package/core/dist/runtime-v2/adapter/structured-output-repair.js +0 -1
  334. package/core/dist/runtime-v2/adapter/structured-output-repair.js.map +1 -1
  335. package/core/dist/runtime-v2/adapter/test-double-runtime-adapter.d.ts +7 -0
  336. package/core/dist/runtime-v2/adapter/test-double-runtime-adapter.d.ts.map +1 -1
  337. package/core/dist/runtime-v2/adapter/test-double-runtime-adapter.js +40 -1
  338. package/core/dist/runtime-v2/adapter/test-double-runtime-adapter.js.map +1 -1
  339. package/core/dist/runtime-v2/admission-gate.d.ts +5 -1
  340. package/core/dist/runtime-v2/admission-gate.d.ts.map +1 -1
  341. package/core/dist/runtime-v2/admission-gate.js +12 -1
  342. package/core/dist/runtime-v2/admission-gate.js.map +1 -1
  343. package/core/dist/runtime-v2/adversarial-loop.d.ts +65 -0
  344. package/core/dist/runtime-v2/adversarial-loop.d.ts.map +1 -0
  345. package/core/dist/runtime-v2/adversarial-loop.js +181 -0
  346. package/core/dist/runtime-v2/adversarial-loop.js.map +1 -0
  347. package/core/dist/runtime-v2/agent-spec.d.ts +1 -1
  348. package/core/dist/runtime-v2/build-l2-principle-reader.d.ts +49 -0
  349. package/core/dist/runtime-v2/build-l2-principle-reader.d.ts.map +1 -0
  350. package/core/dist/runtime-v2/build-l2-principle-reader.js +70 -0
  351. package/core/dist/runtime-v2/build-l2-principle-reader.js.map +1 -0
  352. package/core/dist/runtime-v2/candidate-intake-service.js +0 -1
  353. package/core/dist/runtime-v2/candidate-intake-service.js.map +1 -1
  354. package/core/dist/runtime-v2/cli/diagnose.d.ts +8 -2
  355. package/core/dist/runtime-v2/cli/diagnose.d.ts.map +1 -1
  356. package/core/dist/runtime-v2/cli/diagnose.js +10 -0
  357. package/core/dist/runtime-v2/cli/diagnose.js.map +1 -1
  358. package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +46 -4
  359. package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
  360. package/core/dist/runtime-v2/config/__tests__/pd-config-redaction-deep.test.js +2 -2
  361. package/core/dist/runtime-v2/config/__tests__/pd-config-redaction-deep.test.js.map +1 -1
  362. package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js +1 -1
  363. package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js.map +1 -1
  364. package/core/dist/runtime-v2/config/__tests__/pd-config-workspace.test.d.ts +2 -0
  365. package/core/dist/runtime-v2/config/__tests__/pd-config-workspace.test.d.ts.map +1 -0
  366. package/core/dist/runtime-v2/config/__tests__/pd-config-workspace.test.js +154 -0
  367. package/core/dist/runtime-v2/config/__tests__/pd-config-workspace.test.js.map +1 -0
  368. package/core/dist/runtime-v2/config/index.d.ts +1 -1
  369. package/core/dist/runtime-v2/config/index.d.ts.map +1 -1
  370. package/core/dist/runtime-v2/config/index.js.map +1 -1
  371. package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts +1 -0
  372. package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts.map +1 -1
  373. package/core/dist/runtime-v2/config/pd-config-agent-binding.js +3 -0
  374. package/core/dist/runtime-v2/config/pd-config-agent-binding.js.map +1 -1
  375. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
  376. package/core/dist/runtime-v2/config/pd-config-defaults.js +8 -18
  377. package/core/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  378. package/core/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
  379. package/core/dist/runtime-v2/config/pd-config-effective.js +17 -3
  380. package/core/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
  381. package/core/dist/runtime-v2/config/pd-config-feature-flags.d.ts.map +1 -1
  382. package/core/dist/runtime-v2/config/pd-config-feature-flags.js +11 -2
  383. package/core/dist/runtime-v2/config/pd-config-feature-flags.js.map +1 -1
  384. package/core/dist/runtime-v2/config/pd-config-redaction.d.ts.map +1 -1
  385. package/core/dist/runtime-v2/config/pd-config-redaction.js +10 -0
  386. package/core/dist/runtime-v2/config/pd-config-redaction.js.map +1 -1
  387. package/core/dist/runtime-v2/config/pd-config-types.d.ts +23 -1
  388. package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  389. package/core/dist/runtime-v2/config/pd-config-types.js +5 -1
  390. package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  391. package/core/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
  392. package/core/dist/runtime-v2/config/pd-config-validate.js +69 -0
  393. package/core/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
  394. package/core/dist/runtime-v2/context-payload.d.ts +4 -6
  395. package/core/dist/runtime-v2/context-payload.d.ts.map +1 -1
  396. package/core/dist/runtime-v2/context-payload.js +0 -2
  397. package/core/dist/runtime-v2/context-payload.js.map +1 -1
  398. package/core/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.d.ts +5 -0
  399. package/core/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.d.ts.map +1 -0
  400. package/core/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.js +91 -0
  401. package/core/dist/runtime-v2/core-principles/__tests__/core-axiom-block.test.js.map +1 -0
  402. package/core/dist/runtime-v2/core-principles/__tests__/core-principle-registry.test.d.ts +2 -0
  403. package/core/dist/runtime-v2/core-principles/__tests__/core-principle-registry.test.d.ts.map +1 -0
  404. package/core/dist/runtime-v2/core-principles/__tests__/core-principle-registry.test.js +71 -0
  405. package/core/dist/runtime-v2/core-principles/__tests__/core-principle-registry.test.js.map +1 -0
  406. package/core/dist/runtime-v2/core-principles/__tests__/strip-fabricated-ids.test.d.ts +2 -0
  407. package/core/dist/runtime-v2/core-principles/__tests__/strip-fabricated-ids.test.d.ts.map +1 -0
  408. package/core/dist/runtime-v2/core-principles/__tests__/strip-fabricated-ids.test.js +78 -0
  409. package/core/dist/runtime-v2/core-principles/__tests__/strip-fabricated-ids.test.js.map +1 -0
  410. package/core/dist/runtime-v2/core-principles/core-axiom-block.d.ts +67 -0
  411. package/core/dist/runtime-v2/core-principles/core-axiom-block.d.ts.map +1 -0
  412. package/core/dist/runtime-v2/core-principles/core-axiom-block.js +76 -0
  413. package/core/dist/runtime-v2/core-principles/core-axiom-block.js.map +1 -0
  414. package/core/dist/runtime-v2/core-principles/core-principle-registry.d.ts +41 -0
  415. package/core/dist/runtime-v2/core-principles/core-principle-registry.d.ts.map +1 -0
  416. package/core/dist/runtime-v2/core-principles/core-principle-registry.js +112 -0
  417. package/core/dist/runtime-v2/core-principles/core-principle-registry.js.map +1 -0
  418. package/core/dist/runtime-v2/core-principles/index.d.ts +6 -0
  419. package/core/dist/runtime-v2/core-principles/index.d.ts.map +1 -0
  420. package/core/dist/runtime-v2/core-principles/index.js +4 -0
  421. package/core/dist/runtime-v2/core-principles/index.js.map +1 -0
  422. package/core/dist/runtime-v2/core-principles/strip-fabricated-ids.d.ts +15 -0
  423. package/core/dist/runtime-v2/core-principles/strip-fabricated-ids.d.ts.map +1 -0
  424. package/core/dist/runtime-v2/core-principles/strip-fabricated-ids.js +28 -0
  425. package/core/dist/runtime-v2/core-principles/strip-fabricated-ids.js.map +1 -0
  426. package/core/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.d.ts +2 -0
  427. package/core/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.d.ts.map +1 -0
  428. package/core/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.js +45 -0
  429. package/core/dist/runtime-v2/diagnostician/__tests__/diag-distiller-output.test.js.map +1 -0
  430. package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.d.ts +2 -0
  431. package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.d.ts.map +1 -0
  432. package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js +91 -0
  433. package/core/dist/runtime-v2/diagnostician/__tests__/diag-rootcause-output.test.js.map +1 -0
  434. package/core/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.d.ts +2 -0
  435. package/core/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.d.ts.map +1 -0
  436. package/core/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.js +39 -0
  437. package/core/dist/runtime-v2/diagnostician/__tests__/distiller-prompt-builder.test.js.map +1 -0
  438. package/core/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.d.ts +2 -0
  439. package/core/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.d.ts.map +1 -0
  440. package/core/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.js +34 -0
  441. package/core/dist/runtime-v2/diagnostician/__tests__/rootcause-prompt-builder.test.js.map +1 -0
  442. package/core/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.d.ts +2 -0
  443. package/core/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.d.ts.map +1 -0
  444. package/core/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.js +57 -0
  445. package/core/dist/runtime-v2/diagnostician/__tests__/router-prompt-builder.test.js.map +1 -0
  446. package/core/dist/runtime-v2/diagnostician/diag-distiller-output.d.ts +80 -0
  447. package/core/dist/runtime-v2/diagnostician/diag-distiller-output.d.ts.map +1 -0
  448. package/core/dist/runtime-v2/diagnostician/diag-distiller-output.js +103 -0
  449. package/core/dist/runtime-v2/diagnostician/diag-distiller-output.js.map +1 -0
  450. package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.d.ts +117 -0
  451. package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.d.ts.map +1 -0
  452. package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.js +182 -0
  453. package/core/dist/runtime-v2/diagnostician/diag-rootcause-output.js.map +1 -0
  454. package/core/dist/runtime-v2/diagnostician/distiller-prompt-builder.d.ts +134 -0
  455. package/core/dist/runtime-v2/diagnostician/distiller-prompt-builder.d.ts.map +1 -0
  456. package/core/dist/runtime-v2/diagnostician/distiller-prompt-builder.js +149 -0
  457. package/core/dist/runtime-v2/diagnostician/distiller-prompt-builder.js.map +1 -0
  458. package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts +96 -0
  459. package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.d.ts.map +1 -0
  460. package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js +212 -0
  461. package/core/dist/runtime-v2/diagnostician/rootcause-prompt-builder.js.map +1 -0
  462. package/core/dist/runtime-v2/diagnostician/router-prompt-builder.d.ts +127 -0
  463. package/core/dist/runtime-v2/diagnostician/router-prompt-builder.d.ts.map +1 -0
  464. package/core/dist/runtime-v2/diagnostician/router-prompt-builder.js +131 -0
  465. package/core/dist/runtime-v2/diagnostician/router-prompt-builder.js.map +1 -0
  466. package/core/dist/runtime-v2/diagnostician-prompt-builder.d.ts +10 -50
  467. package/core/dist/runtime-v2/diagnostician-prompt-builder.d.ts.map +1 -1
  468. package/core/dist/runtime-v2/diagnostician-prompt-builder.js +0 -148
  469. package/core/dist/runtime-v2/diagnostician-prompt-builder.js.map +1 -1
  470. package/core/dist/runtime-v2/evidence-guards.d.ts +31 -0
  471. package/core/dist/runtime-v2/evidence-guards.d.ts.map +1 -0
  472. package/core/dist/runtime-v2/evidence-guards.js +29 -0
  473. package/core/dist/runtime-v2/evidence-guards.js.map +1 -0
  474. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +106 -7
  475. package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
  476. package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.js +3 -3
  477. package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.js.map +1 -1
  478. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  479. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +39 -4
  480. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  481. package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.d.ts.map +1 -1
  482. package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js +27 -22
  483. package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js.map +1 -1
  484. package/core/dist/runtime-v2/feedback/redact-sensitive.js.map +1 -1
  485. package/core/dist/runtime-v2/feedback/safe-stringify.js.map +1 -1
  486. package/core/dist/runtime-v2/full-trace-contract.d.ts +3 -3
  487. package/core/dist/runtime-v2/golden-trace-replay-validator.d.ts +8 -0
  488. package/core/dist/runtime-v2/golden-trace-replay-validator.d.ts.map +1 -1
  489. package/core/dist/runtime-v2/golden-trace-replay-validator.js +3 -3
  490. package/core/dist/runtime-v2/golden-trace-replay-validator.js.map +1 -1
  491. package/core/dist/runtime-v2/golden-trace.d.ts +46 -1
  492. package/core/dist/runtime-v2/golden-trace.d.ts.map +1 -1
  493. package/core/dist/runtime-v2/golden-trace.js +70 -4
  494. package/core/dist/runtime-v2/golden-trace.js.map +1 -1
  495. package/core/dist/runtime-v2/index.d.ts +62 -31
  496. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  497. package/core/dist/runtime-v2/index.js +54 -18
  498. package/core/dist/runtime-v2/index.js.map +1 -1
  499. package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.d.ts +25 -0
  500. package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.d.ts.map +1 -0
  501. package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.js +123 -0
  502. package/core/dist/runtime-v2/internalization/__tests__/__fixtures__/split-pipeline-mock-outputs.js.map +1 -0
  503. package/core/dist/runtime-v2/internalization/__tests__/adversarial-case.test.d.ts +2 -0
  504. package/core/dist/runtime-v2/internalization/__tests__/adversarial-case.test.d.ts.map +1 -0
  505. package/core/dist/runtime-v2/internalization/__tests__/adversarial-case.test.js +139 -0
  506. package/core/dist/runtime-v2/internalization/__tests__/adversarial-case.test.js.map +1 -0
  507. package/core/dist/runtime-v2/internalization/__tests__/adversarial-feedback.test.d.ts +2 -0
  508. package/core/dist/runtime-v2/internalization/__tests__/adversarial-feedback.test.d.ts.map +1 -0
  509. package/core/dist/runtime-v2/internalization/__tests__/adversarial-feedback.test.js +62 -0
  510. package/core/dist/runtime-v2/internalization/__tests__/adversarial-feedback.test.js.map +1 -0
  511. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.d.ts +2 -0
  512. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.d.ts.map +1 -0
  513. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.js +24 -0
  514. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.js.map +1 -0
  515. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder.test.js +5 -4
  516. package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder.test.js.map +1 -1
  517. package/core/dist/runtime-v2/internalization/__tests__/artificer-rule-output.test.d.ts +2 -0
  518. package/core/dist/runtime-v2/internalization/__tests__/artificer-rule-output.test.d.ts.map +1 -0
  519. package/core/dist/runtime-v2/internalization/__tests__/artificer-rule-output.test.js +248 -0
  520. package/core/dist/runtime-v2/internalization/__tests__/artificer-rule-output.test.js.map +1 -0
  521. package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.d.ts +2 -0
  522. package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.d.ts.map +1 -0
  523. package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js +803 -0
  524. package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js.map +1 -0
  525. package/core/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.d.ts +2 -0
  526. package/core/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.d.ts.map +1 -0
  527. package/core/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.js +441 -0
  528. package/core/dist/runtime-v2/internalization/__tests__/diag-distiller-runner.test.js.map +1 -0
  529. package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.d.ts +2 -0
  530. package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.d.ts.map +1 -0
  531. package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js +340 -0
  532. package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js.map +1 -0
  533. package/core/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.d.ts +2 -0
  534. package/core/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.d.ts.map +1 -0
  535. package/core/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.js +441 -0
  536. package/core/dist/runtime-v2/internalization/__tests__/diag-router-runner.test.js.map +1 -0
  537. package/core/dist/runtime-v2/internalization/__tests__/evaluator-output-v2.test.d.ts +2 -0
  538. package/core/dist/runtime-v2/internalization/__tests__/evaluator-output-v2.test.d.ts.map +1 -0
  539. package/core/dist/runtime-v2/internalization/__tests__/evaluator-output-v2.test.js +209 -0
  540. package/core/dist/runtime-v2/internalization/__tests__/evaluator-output-v2.test.js.map +1 -0
  541. package/core/dist/runtime-v2/internalization/__tests__/evaluator-prompt-builder-v2.test.d.ts +2 -0
  542. package/core/dist/runtime-v2/internalization/__tests__/evaluator-prompt-builder-v2.test.d.ts.map +1 -0
  543. package/core/dist/runtime-v2/internalization/__tests__/evaluator-prompt-builder-v2.test.js +125 -0
  544. package/core/dist/runtime-v2/internalization/__tests__/evaluator-prompt-builder-v2.test.js.map +1 -0
  545. package/core/dist/runtime-v2/internalization/__tests__/internalization-consumer-decision.test.d.ts +2 -0
  546. package/core/dist/runtime-v2/internalization/__tests__/internalization-consumer-decision.test.d.ts.map +1 -0
  547. package/core/dist/runtime-v2/internalization/__tests__/internalization-consumer-decision.test.js +223 -0
  548. package/core/dist/runtime-v2/internalization/__tests__/internalization-consumer-decision.test.js.map +1 -0
  549. package/core/dist/runtime-v2/internalization/__tests__/philosopher-runner-trust-boundary.test.js +4 -0
  550. package/core/dist/runtime-v2/internalization/__tests__/philosopher-runner-trust-boundary.test.js.map +1 -1
  551. package/core/dist/runtime-v2/internalization/__tests__/refiner-sandbox-wrapper.test.js.map +1 -1
  552. package/core/dist/runtime-v2/internalization/__tests__/rule-code-dialect.test.d.ts +2 -0
  553. package/core/dist/runtime-v2/internalization/__tests__/rule-code-dialect.test.d.ts.map +1 -0
  554. package/core/dist/runtime-v2/internalization/__tests__/rule-code-dialect.test.js +270 -0
  555. package/core/dist/runtime-v2/internalization/__tests__/rule-code-dialect.test.js.map +1 -0
  556. package/core/dist/runtime-v2/internalization/__tests__/rule-host-input-builder.test.d.ts +2 -0
  557. package/core/dist/runtime-v2/internalization/__tests__/rule-host-input-builder.test.d.ts.map +1 -0
  558. package/core/dist/runtime-v2/internalization/__tests__/rule-host-input-builder.test.js +180 -0
  559. package/core/dist/runtime-v2/internalization/__tests__/rule-host-input-builder.test.js.map +1 -0
  560. package/core/dist/runtime-v2/internalization/__tests__/runnerkind-seam.test.d.ts +2 -0
  561. package/core/dist/runtime-v2/internalization/__tests__/runnerkind-seam.test.d.ts.map +1 -0
  562. package/core/dist/runtime-v2/internalization/__tests__/runnerkind-seam.test.js +224 -0
  563. package/core/dist/runtime-v2/internalization/__tests__/runnerkind-seam.test.js.map +1 -0
  564. package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-builder.test.js +13 -8
  565. package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-builder.test.js.map +1 -1
  566. package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.js +4 -3
  567. package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.js.map +1 -1
  568. package/core/dist/runtime-v2/internalization/__tests__/split-diagnostician-runner-retry.test.d.ts +2 -0
  569. package/core/dist/runtime-v2/internalization/__tests__/split-diagnostician-runner-retry.test.d.ts.map +1 -0
  570. package/core/dist/runtime-v2/internalization/__tests__/split-diagnostician-runner-retry.test.js +227 -0
  571. package/core/dist/runtime-v2/internalization/__tests__/split-diagnostician-runner-retry.test.js.map +1 -0
  572. package/core/dist/runtime-v2/internalization/adversarial-case.d.ts +32 -0
  573. package/core/dist/runtime-v2/internalization/adversarial-case.d.ts.map +1 -0
  574. package/core/dist/runtime-v2/internalization/adversarial-case.js +68 -0
  575. package/core/dist/runtime-v2/internalization/adversarial-case.js.map +1 -0
  576. package/core/dist/runtime-v2/internalization/adversarial-feedback.d.ts +23 -0
  577. package/core/dist/runtime-v2/internalization/adversarial-feedback.d.ts.map +1 -0
  578. package/core/dist/runtime-v2/internalization/adversarial-feedback.js +20 -0
  579. package/core/dist/runtime-v2/internalization/adversarial-feedback.js.map +1 -0
  580. package/core/dist/runtime-v2/internalization/artificer-output.d.ts +54 -30
  581. package/core/dist/runtime-v2/internalization/artificer-output.d.ts.map +1 -1
  582. package/core/dist/runtime-v2/internalization/artificer-output.js +144 -36
  583. package/core/dist/runtime-v2/internalization/artificer-output.js.map +1 -1
  584. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts +10 -2
  585. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
  586. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +37 -20
  587. package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
  588. package/core/dist/runtime-v2/internalization/artificer-runner.d.ts +19 -9
  589. package/core/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
  590. package/core/dist/runtime-v2/internalization/artificer-runner.js +21 -9
  591. package/core/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
  592. package/core/dist/runtime-v2/internalization/correction-proposal.d.ts.map +1 -1
  593. package/core/dist/runtime-v2/internalization/correction-proposal.js +27 -16
  594. package/core/dist/runtime-v2/internalization/correction-proposal.js.map +1 -1
  595. package/core/dist/runtime-v2/internalization/diag-distiller-runner.d.ts +83 -0
  596. package/core/dist/runtime-v2/internalization/diag-distiller-runner.d.ts.map +1 -0
  597. package/core/dist/runtime-v2/internalization/diag-distiller-runner.js +274 -0
  598. package/core/dist/runtime-v2/internalization/diag-distiller-runner.js.map +1 -0
  599. package/core/dist/runtime-v2/internalization/diag-rootcause-runner.d.ts +73 -0
  600. package/core/dist/runtime-v2/internalization/diag-rootcause-runner.d.ts.map +1 -0
  601. package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js +229 -0
  602. package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js.map +1 -0
  603. package/core/dist/runtime-v2/internalization/diag-router-runner.d.ts +85 -0
  604. package/core/dist/runtime-v2/internalization/diag-router-runner.d.ts.map +1 -0
  605. package/core/dist/runtime-v2/internalization/diag-router-runner.js +353 -0
  606. package/core/dist/runtime-v2/internalization/diag-router-runner.js.map +1 -0
  607. package/core/dist/runtime-v2/internalization/dreamer-prompt-builder.d.ts +19 -1
  608. package/core/dist/runtime-v2/internalization/dreamer-prompt-builder.d.ts.map +1 -1
  609. package/core/dist/runtime-v2/internalization/dreamer-prompt-builder.js +48 -8
  610. package/core/dist/runtime-v2/internalization/dreamer-prompt-builder.js.map +1 -1
  611. package/core/dist/runtime-v2/internalization/dreamer-runner.d.ts +7 -1
  612. package/core/dist/runtime-v2/internalization/dreamer-runner.d.ts.map +1 -1
  613. package/core/dist/runtime-v2/internalization/dreamer-runner.js +13 -3
  614. package/core/dist/runtime-v2/internalization/dreamer-runner.js.map +1 -1
  615. package/core/dist/runtime-v2/internalization/evaluator-output.d.ts +63 -0
  616. package/core/dist/runtime-v2/internalization/evaluator-output.d.ts.map +1 -1
  617. package/core/dist/runtime-v2/internalization/evaluator-output.js +158 -0
  618. package/core/dist/runtime-v2/internalization/evaluator-output.js.map +1 -1
  619. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts +8 -1
  620. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  621. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js +17 -4
  622. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js.map +1 -1
  623. package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts +114 -4
  624. package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  625. package/core/dist/runtime-v2/internalization/evaluator-runner.js +629 -7
  626. package/core/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  627. package/core/dist/runtime-v2/internalization/golden-dogfood-fixtures.d.ts +17 -0
  628. package/core/dist/runtime-v2/internalization/golden-dogfood-fixtures.d.ts.map +1 -0
  629. package/core/dist/runtime-v2/internalization/golden-dogfood-fixtures.js +451 -0
  630. package/core/dist/runtime-v2/internalization/golden-dogfood-fixtures.js.map +1 -0
  631. package/core/dist/runtime-v2/internalization/index.d.ts +21 -9
  632. package/core/dist/runtime-v2/internalization/index.d.ts.map +1 -1
  633. package/core/dist/runtime-v2/internalization/index.js +16 -6
  634. package/core/dist/runtime-v2/internalization/index.js.map +1 -1
  635. package/core/dist/runtime-v2/internalization/intake-to-internalization-bridge.d.ts +25 -0
  636. package/core/dist/runtime-v2/internalization/intake-to-internalization-bridge.d.ts.map +1 -1
  637. package/core/dist/runtime-v2/internalization/intake-to-internalization-bridge.js +67 -12
  638. package/core/dist/runtime-v2/internalization/intake-to-internalization-bridge.js.map +1 -1
  639. package/core/dist/runtime-v2/internalization/internalization-consumer-decision.d.ts +17 -0
  640. package/core/dist/runtime-v2/internalization/internalization-consumer-decision.d.ts.map +1 -0
  641. package/core/dist/runtime-v2/internalization/internalization-consumer-decision.js +28 -0
  642. package/core/dist/runtime-v2/internalization/internalization-consumer-decision.js.map +1 -0
  643. package/core/dist/runtime-v2/internalization/internalization-job-graph.d.ts +14 -1
  644. package/core/dist/runtime-v2/internalization/internalization-job-graph.d.ts.map +1 -1
  645. package/core/dist/runtime-v2/internalization/internalization-job-graph.js +22 -0
  646. package/core/dist/runtime-v2/internalization/internalization-job-graph.js.map +1 -1
  647. package/core/dist/runtime-v2/internalization/internalization-orchestrator.d.ts +9 -9
  648. package/core/dist/runtime-v2/internalization/internalization-orchestrator.d.ts.map +1 -1
  649. package/core/dist/runtime-v2/internalization/internalization-orchestrator.js +32 -9
  650. package/core/dist/runtime-v2/internalization/internalization-orchestrator.js.map +1 -1
  651. package/core/dist/runtime-v2/internalization/internalization-state-machine.d.ts +2 -2
  652. package/core/dist/runtime-v2/internalization/internalization-state-machine.d.ts.map +1 -1
  653. package/core/dist/runtime-v2/internalization/internalization-state-machine.js +35 -4
  654. package/core/dist/runtime-v2/internalization/internalization-state-machine.js.map +1 -1
  655. package/core/dist/runtime-v2/internalization/peer-runner-contracts.d.ts +31 -4
  656. package/core/dist/runtime-v2/internalization/peer-runner-contracts.d.ts.map +1 -1
  657. package/core/dist/runtime-v2/internalization/peer-runner-contracts.js +42 -12
  658. package/core/dist/runtime-v2/internalization/peer-runner-contracts.js.map +1 -1
  659. package/core/dist/runtime-v2/internalization/philosopher-prompt-builder.d.ts +20 -1
  660. package/core/dist/runtime-v2/internalization/philosopher-prompt-builder.d.ts.map +1 -1
  661. package/core/dist/runtime-v2/internalization/philosopher-prompt-builder.js +47 -6
  662. package/core/dist/runtime-v2/internalization/philosopher-prompt-builder.js.map +1 -1
  663. package/core/dist/runtime-v2/internalization/philosopher-runner.d.ts +6 -1
  664. package/core/dist/runtime-v2/internalization/philosopher-runner.d.ts.map +1 -1
  665. package/core/dist/runtime-v2/internalization/philosopher-runner.js +10 -3
  666. package/core/dist/runtime-v2/internalization/philosopher-runner.js.map +1 -1
  667. package/core/dist/runtime-v2/internalization/pitask-metadata.d.ts +9 -2
  668. package/core/dist/runtime-v2/internalization/pitask-metadata.d.ts.map +1 -1
  669. package/core/dist/runtime-v2/internalization/pitask-metadata.js +22 -11
  670. package/core/dist/runtime-v2/internalization/pitask-metadata.js.map +1 -1
  671. package/core/dist/runtime-v2/internalization/prompt-serializer.d.ts +3 -0
  672. package/core/dist/runtime-v2/internalization/prompt-serializer.d.ts.map +1 -0
  673. package/core/dist/runtime-v2/internalization/prompt-serializer.js +22 -0
  674. package/core/dist/runtime-v2/internalization/prompt-serializer.js.map +1 -0
  675. package/core/dist/runtime-v2/internalization/queue-actionability.d.ts +3 -3
  676. package/core/dist/runtime-v2/internalization/queue-actionability.d.ts.map +1 -1
  677. package/core/dist/runtime-v2/internalization/refiner-sandbox-wrapper.d.ts.map +1 -1
  678. package/core/dist/runtime-v2/internalization/refiner-sandbox-wrapper.js +16 -1
  679. package/core/dist/runtime-v2/internalization/refiner-sandbox-wrapper.js.map +1 -1
  680. package/core/dist/runtime-v2/internalization/rollout-reviewer-prompt-builder.d.ts +1 -1
  681. package/core/dist/runtime-v2/internalization/rollout-reviewer-prompt-builder.d.ts.map +1 -1
  682. package/core/dist/runtime-v2/internalization/rollout-reviewer-prompt-builder.js +2 -2
  683. package/core/dist/runtime-v2/internalization/rule-code-validator.d.ts +29 -0
  684. package/core/dist/runtime-v2/internalization/rule-code-validator.d.ts.map +1 -1
  685. package/core/dist/runtime-v2/internalization/rule-code-validator.js +87 -1
  686. package/core/dist/runtime-v2/internalization/rule-code-validator.js.map +1 -1
  687. package/core/dist/runtime-v2/internalization/rule-host-evaluator.d.ts +1 -0
  688. package/core/dist/runtime-v2/internalization/rule-host-evaluator.d.ts.map +1 -1
  689. package/core/dist/runtime-v2/internalization/rule-host-evaluator.js +15 -1
  690. package/core/dist/runtime-v2/internalization/rule-host-evaluator.js.map +1 -1
  691. package/core/dist/runtime-v2/internalization/rule-host-input-builder.d.ts +62 -0
  692. package/core/dist/runtime-v2/internalization/rule-host-input-builder.d.ts.map +1 -0
  693. package/core/dist/runtime-v2/internalization/rule-host-input-builder.js +182 -0
  694. package/core/dist/runtime-v2/internalization/rule-host-input-builder.js.map +1 -0
  695. package/core/dist/runtime-v2/internalization/rule-host-validator.d.ts +37 -0
  696. package/core/dist/runtime-v2/internalization/rule-host-validator.d.ts.map +1 -0
  697. package/core/dist/runtime-v2/internalization/rule-host-validator.js +154 -0
  698. package/core/dist/runtime-v2/internalization/rule-host-validator.js.map +1 -0
  699. package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts +20 -6
  700. package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts.map +1 -1
  701. package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js +31 -15
  702. package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js.map +1 -1
  703. package/core/dist/runtime-v2/internalization/scribe-runner.d.ts +6 -1
  704. package/core/dist/runtime-v2/internalization/scribe-runner.d.ts.map +1 -1
  705. package/core/dist/runtime-v2/internalization/scribe-runner.js +10 -3
  706. package/core/dist/runtime-v2/internalization/scribe-runner.js.map +1 -1
  707. package/core/dist/runtime-v2/internalization/split-diagnostician-runner.d.ts +103 -0
  708. package/core/dist/runtime-v2/internalization/split-diagnostician-runner.d.ts.map +1 -0
  709. package/core/dist/runtime-v2/internalization/split-diagnostician-runner.js +286 -0
  710. package/core/dist/runtime-v2/internalization/split-diagnostician-runner.js.map +1 -0
  711. package/core/dist/runtime-v2/internalization/template-generator.d.ts +7 -2
  712. package/core/dist/runtime-v2/internalization/template-generator.d.ts.map +1 -1
  713. package/core/dist/runtime-v2/internalization/template-generator.js +10 -5
  714. package/core/dist/runtime-v2/internalization/template-generator.js.map +1 -1
  715. package/core/dist/runtime-v2/internalization/trainer-prompt-builder.d.ts +1 -1
  716. package/core/dist/runtime-v2/internalization/trainer-prompt-builder.d.ts.map +1 -1
  717. package/core/dist/runtime-v2/internalization/trainer-prompt-builder.js +2 -2
  718. package/core/dist/runtime-v2/internalization-chain-integrity-read-model.d.ts +5 -0
  719. package/core/dist/runtime-v2/internalization-chain-integrity-read-model.d.ts.map +1 -1
  720. package/core/dist/runtime-v2/internalization-chain-integrity-read-model.js +48 -2
  721. package/core/dist/runtime-v2/internalization-chain-integrity-read-model.js.map +1 -1
  722. package/core/dist/runtime-v2/internalization-integrity-remediation.d.ts +67 -0
  723. package/core/dist/runtime-v2/internalization-integrity-remediation.d.ts.map +1 -1
  724. package/core/dist/runtime-v2/internalization-integrity-remediation.js +802 -0
  725. package/core/dist/runtime-v2/internalization-integrity-remediation.js.map +1 -1
  726. package/core/dist/runtime-v2/internalization-queue-read-model.d.ts +7 -7
  727. package/core/dist/runtime-v2/internalization-queue-read-model.d.ts.map +1 -1
  728. package/core/dist/runtime-v2/internalization-queue-read-model.js +4 -4
  729. package/core/dist/runtime-v2/internalization-queue-read-model.js.map +1 -1
  730. package/core/dist/runtime-v2/mainline-contract.d.ts +138 -0
  731. package/core/dist/runtime-v2/mainline-contract.d.ts.map +1 -0
  732. package/core/dist/runtime-v2/mainline-contract.js +224 -0
  733. package/core/dist/runtime-v2/mainline-contract.js.map +1 -0
  734. package/core/dist/runtime-v2/observer/__tests__/empathy-observer.real-e2e.test.js +29 -22
  735. package/core/dist/runtime-v2/observer/__tests__/empathy-observer.real-e2e.test.js.map +1 -1
  736. package/core/dist/runtime-v2/observer/agent-scheduler.js.map +1 -1
  737. package/core/dist/runtime-v2/observer/empathy-observer.js +1 -1
  738. package/core/dist/runtime-v2/observer/empathy-observer.js.map +1 -1
  739. package/core/dist/runtime-v2/pain-signal-bridge.d.ts +36 -4
  740. package/core/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
  741. package/core/dist/runtime-v2/pain-signal-bridge.js +81 -37
  742. package/core/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
  743. package/core/dist/runtime-v2/pain-signal-observability.d.ts +4 -0
  744. package/core/dist/runtime-v2/pain-signal-observability.d.ts.map +1 -1
  745. package/core/dist/runtime-v2/pain-signal-observability.js +58 -8
  746. package/core/dist/runtime-v2/pain-signal-observability.js.map +1 -1
  747. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts +20 -1
  748. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
  749. package/core/dist/runtime-v2/pain-signal-runtime-factory.js +80 -23
  750. package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
  751. package/core/dist/runtime-v2/pain-to-principle-service.d.ts +5 -1
  752. package/core/dist/runtime-v2/pain-to-principle-service.d.ts.map +1 -1
  753. package/core/dist/runtime-v2/pain-to-principle-service.js +39 -0
  754. package/core/dist/runtime-v2/pain-to-principle-service.js.map +1 -1
  755. package/core/dist/runtime-v2/proven-channel-baseline.d.ts.map +1 -1
  756. package/core/dist/runtime-v2/proven-channel-baseline.js +14 -0
  757. package/core/dist/runtime-v2/proven-channel-baseline.js.map +1 -1
  758. package/core/dist/runtime-v2/recovery-sweep-service.d.ts +18 -0
  759. package/core/dist/runtime-v2/recovery-sweep-service.d.ts.map +1 -1
  760. package/core/dist/runtime-v2/recovery-sweep-service.js +46 -0
  761. package/core/dist/runtime-v2/recovery-sweep-service.js.map +1 -1
  762. package/core/dist/runtime-v2/runner/__tests__/base-peer-runner-trust-boundary.test.js +11 -2
  763. package/core/dist/runtime-v2/runner/__tests__/base-peer-runner-trust-boundary.test.js.map +1 -1
  764. package/core/dist/runtime-v2/runner/__tests__/diagnose.test.js.map +1 -1
  765. package/core/dist/runtime-v2/runner/__tests__/pain-signal-bridge-admission.test.js +6 -0
  766. package/core/dist/runtime-v2/runner/__tests__/pain-signal-bridge-admission.test.js.map +1 -1
  767. package/core/dist/runtime-v2/runner/__tests__/pain-signal-bridge.test.js.map +1 -1
  768. package/core/dist/runtime-v2/runner/base-peer-runner.d.ts +10 -3
  769. package/core/dist/runtime-v2/runner/base-peer-runner.d.ts.map +1 -1
  770. package/core/dist/runtime-v2/runner/base-peer-runner.js +58 -15
  771. package/core/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
  772. package/core/dist/runtime-v2/runner/peer-runner-types.d.ts +10 -3
  773. package/core/dist/runtime-v2/runner/peer-runner-types.d.ts.map +1 -1
  774. package/core/dist/runtime-v2/runtime-protocol.d.ts +3 -3
  775. package/core/dist/runtime-v2/runtime-protocol.d.ts.map +1 -1
  776. package/core/dist/runtime-v2/runtime-protocol.js +1 -0
  777. package/core/dist/runtime-v2/runtime-protocol.js.map +1 -1
  778. package/core/dist/runtime-v2/runtime-selector.d.ts +3 -3
  779. package/core/dist/runtime-v2/stalled-diagnostician-task-read-model.d.ts +26 -0
  780. package/core/dist/runtime-v2/stalled-diagnostician-task-read-model.d.ts.map +1 -0
  781. package/core/dist/runtime-v2/stalled-diagnostician-task-read-model.js +59 -0
  782. package/core/dist/runtime-v2/stalled-diagnostician-task-read-model.js.map +1 -0
  783. package/core/dist/runtime-v2/store/candidate/sqlite-candidate-store.js +2 -2
  784. package/core/dist/runtime-v2/store/candidate/sqlite-candidate-store.js.map +1 -1
  785. package/core/dist/runtime-v2/store/concurrent-lease.test.js +13 -13
  786. package/core/dist/runtime-v2/store/concurrent-lease.test.js.map +1 -1
  787. package/core/dist/runtime-v2/store/context/index.d.ts +1 -0
  788. package/core/dist/runtime-v2/store/context/index.d.ts.map +1 -1
  789. package/core/dist/runtime-v2/store/context/sqlite-context-assembler.d.ts +8 -0
  790. package/core/dist/runtime-v2/store/context/sqlite-context-assembler.d.ts.map +1 -1
  791. package/core/dist/runtime-v2/store/context/sqlite-context-assembler.js +54 -3
  792. package/core/dist/runtime-v2/store/context/sqlite-context-assembler.js.map +1 -1
  793. package/core/dist/runtime-v2/store/context/sqlite-context-assembler.test.js +373 -2
  794. package/core/dist/runtime-v2/store/context/sqlite-context-assembler.test.js.map +1 -1
  795. package/core/dist/runtime-v2/store/context/trajectory-turn-reader.d.ts +32 -0
  796. package/core/dist/runtime-v2/store/context/trajectory-turn-reader.d.ts.map +1 -0
  797. package/core/dist/runtime-v2/store/context/trajectory-turn-reader.js +12 -0
  798. package/core/dist/runtime-v2/store/context/trajectory-turn-reader.js.map +1 -0
  799. package/core/dist/runtime-v2/store/event-emitter.js +0 -1
  800. package/core/dist/runtime-v2/store/event-emitter.js.map +1 -1
  801. package/core/dist/runtime-v2/store/history/sqlite-history-query.test.js +1 -1
  802. package/core/dist/runtime-v2/store/history/sqlite-history-query.test.js.map +1 -1
  803. package/core/dist/runtime-v2/store/idempotent-transitions.test.js +0 -5
  804. package/core/dist/runtime-v2/store/idempotent-transitions.test.js.map +1 -1
  805. package/core/dist/runtime-v2/store/lifecycle/lease-manager.d.ts.map +1 -1
  806. package/core/dist/runtime-v2/store/lifecycle/lease-manager.js +5 -0
  807. package/core/dist/runtime-v2/store/lifecycle/lease-manager.js.map +1 -1
  808. package/core/dist/runtime-v2/store/lifecycle/lease-manager.test.js +0 -2
  809. package/core/dist/runtime-v2/store/lifecycle/lease-manager.test.js.map +1 -1
  810. package/core/dist/runtime-v2/store/lifecycle/recovery-sweep.test.js +0 -2
  811. package/core/dist/runtime-v2/store/lifecycle/recovery-sweep.test.js.map +1 -1
  812. package/core/dist/runtime-v2/store/run/memory-run-store.d.ts +2 -1
  813. package/core/dist/runtime-v2/store/run/memory-run-store.d.ts.map +1 -1
  814. package/core/dist/runtime-v2/store/run/memory-run-store.js +5 -0
  815. package/core/dist/runtime-v2/store/run/memory-run-store.js.map +1 -1
  816. package/core/dist/runtime-v2/store/run/run-store.d.ts +27 -0
  817. package/core/dist/runtime-v2/store/run/run-store.d.ts.map +1 -1
  818. package/core/dist/runtime-v2/store/run/sqlite-run-store.d.ts +26 -2
  819. package/core/dist/runtime-v2/store/run/sqlite-run-store.d.ts.map +1 -1
  820. package/core/dist/runtime-v2/store/run/sqlite-run-store.js +134 -20
  821. package/core/dist/runtime-v2/store/run/sqlite-run-store.js.map +1 -1
  822. package/core/dist/runtime-v2/store/runtime-state-manager-malformed-run-tolerance.test.d.ts +2 -0
  823. package/core/dist/runtime-v2/store/runtime-state-manager-malformed-run-tolerance.test.d.ts.map +1 -0
  824. package/core/dist/runtime-v2/store/runtime-state-manager-malformed-run-tolerance.test.js +160 -0
  825. package/core/dist/runtime-v2/store/runtime-state-manager-malformed-run-tolerance.test.js.map +1 -0
  826. package/core/dist/runtime-v2/store/runtime-state-manager.d.ts +25 -3
  827. package/core/dist/runtime-v2/store/runtime-state-manager.d.ts.map +1 -1
  828. package/core/dist/runtime-v2/store/runtime-state-manager.js +55 -7
  829. package/core/dist/runtime-v2/store/runtime-state-manager.js.map +1 -1
  830. package/core/dist/runtime-v2/store/schema-conformance.test.js +0 -10
  831. package/core/dist/runtime-v2/store/schema-conformance.test.js.map +1 -1
  832. package/core/dist/runtime-v2/store/sqlite-connection-pragma.test.js +2 -2
  833. package/core/dist/runtime-v2/store/sqlite-connection-pragma.test.js.map +1 -1
  834. package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
  835. package/core/dist/runtime-v2/store/sqlite-connection.js +12 -0
  836. package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
  837. package/core/dist/runtime-v2/store/sqlite-run-store.test.js +172 -2
  838. package/core/dist/runtime-v2/store/sqlite-run-store.test.js.map +1 -1
  839. package/core/dist/runtime-v2/store/sqlite-task-store.test.js +0 -2
  840. package/core/dist/runtime-v2/store/sqlite-task-store.test.js.map +1 -1
  841. package/core/dist/runtime-v2/store/trajectory/source-trace-locator.test.js +0 -1
  842. package/core/dist/runtime-v2/store/trajectory/source-trace-locator.test.js.map +1 -1
  843. package/core/dist/runtime-v2/store/trajectory/sqlite-trajectory-locator.test.js +1 -1
  844. package/core/dist/runtime-v2/store/trajectory/sqlite-trajectory-locator.test.js.map +1 -1
  845. package/core/dist/runtime-v2/store/workspace-isolation.test.js +0 -2
  846. package/core/dist/runtime-v2/store/workspace-isolation.test.js.map +1 -1
  847. package/core/dist/runtime-v2/tools/__tests__/agent-tool-contract.test.d.ts +2 -0
  848. package/core/dist/runtime-v2/tools/__tests__/agent-tool-contract.test.d.ts.map +1 -0
  849. package/core/dist/runtime-v2/tools/__tests__/agent-tool-contract.test.js +171 -0
  850. package/core/dist/runtime-v2/tools/__tests__/agent-tool-contract.test.js.map +1 -0
  851. package/core/dist/runtime-v2/tools/__tests__/artificer-l2-tool-contract.test.d.ts +2 -0
  852. package/core/dist/runtime-v2/tools/__tests__/artificer-l2-tool-contract.test.d.ts.map +1 -0
  853. package/core/dist/runtime-v2/tools/__tests__/artificer-l2-tool-contract.test.js +322 -0
  854. package/core/dist/runtime-v2/tools/__tests__/artificer-l2-tool-contract.test.js.map +1 -0
  855. package/core/dist/runtime-v2/tools/__tests__/artificer-output-typebox.test.d.ts +2 -0
  856. package/core/dist/runtime-v2/tools/__tests__/artificer-output-typebox.test.d.ts.map +1 -0
  857. package/core/dist/runtime-v2/tools/__tests__/artificer-output-typebox.test.js +149 -0
  858. package/core/dist/runtime-v2/tools/__tests__/artificer-output-typebox.test.js.map +1 -0
  859. package/core/dist/runtime-v2/tools/__tests__/dreamer-output-typebox.test.d.ts +2 -0
  860. package/core/dist/runtime-v2/tools/__tests__/dreamer-output-typebox.test.d.ts.map +1 -0
  861. package/core/dist/runtime-v2/tools/__tests__/dreamer-output-typebox.test.js +109 -0
  862. package/core/dist/runtime-v2/tools/__tests__/dreamer-output-typebox.test.js.map +1 -0
  863. package/core/dist/runtime-v2/tools/agent-tool-contract.d.ts +76 -0
  864. package/core/dist/runtime-v2/tools/agent-tool-contract.d.ts.map +1 -0
  865. package/core/dist/runtime-v2/tools/agent-tool-contract.js +136 -0
  866. package/core/dist/runtime-v2/tools/agent-tool-contract.js.map +1 -0
  867. package/core/dist/runtime-v2/tools/artificer-l2-tool-contract.d.ts +72 -0
  868. package/core/dist/runtime-v2/tools/artificer-l2-tool-contract.d.ts.map +1 -0
  869. package/core/dist/runtime-v2/tools/artificer-l2-tool-contract.js +275 -0
  870. package/core/dist/runtime-v2/tools/artificer-l2-tool-contract.js.map +1 -0
  871. package/core/dist/runtime-v2/tools/artificer-output-typebox.d.ts +78 -0
  872. package/core/dist/runtime-v2/tools/artificer-output-typebox.d.ts.map +1 -0
  873. package/core/dist/runtime-v2/tools/artificer-output-typebox.js +70 -0
  874. package/core/dist/runtime-v2/tools/artificer-output-typebox.js.map +1 -0
  875. package/core/dist/runtime-v2/tools/dreamer-output-typebox.d.ts +63 -0
  876. package/core/dist/runtime-v2/tools/dreamer-output-typebox.d.ts.map +1 -0
  877. package/core/dist/runtime-v2/tools/dreamer-output-typebox.js +55 -0
  878. package/core/dist/runtime-v2/tools/dreamer-output-typebox.js.map +1 -0
  879. package/core/dist/runtime-v2/types/event-types.d.ts +32 -3
  880. package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
  881. package/core/dist/runtime-v2/types/event-types.js +8 -0
  882. package/core/dist/runtime-v2/types/event-types.js.map +1 -1
  883. package/core/dist/runtime-v2/types/evidence-chain-contract.d.ts +213 -0
  884. package/core/dist/runtime-v2/types/evidence-chain-contract.d.ts.map +1 -0
  885. package/core/dist/runtime-v2/types/evidence-chain-contract.js +1064 -0
  886. package/core/dist/runtime-v2/types/evidence-chain-contract.js.map +1 -0
  887. package/core/dist/runtime-v2/types/index.d.ts +4 -2
  888. package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
  889. package/core/dist/runtime-v2/types/index.js +2 -1
  890. package/core/dist/runtime-v2/types/index.js.map +1 -1
  891. package/core/dist/runtime-v2/types/principle-enums.d.ts +2 -2
  892. package/core/dist/runtime-v2/types/principle-enums.d.ts.map +1 -1
  893. package/core/dist/runtime-v2/types/principle-enums.js +1 -0
  894. package/core/dist/runtime-v2/types/principle-enums.js.map +1 -1
  895. package/core/dist/runtime-v2/types/principle-schema.d.ts +1 -1
  896. package/core/dist/runtime-v2/types/principle-tree-store.d.ts +1 -1
  897. package/core/dist/runtime-v2/utils/cli-process-runner.d.ts.map +1 -1
  898. package/core/dist/runtime-v2/utils/cli-process-runner.js +5 -2
  899. package/core/dist/runtime-v2/utils/cli-process-runner.js.map +1 -1
  900. package/core/dist/runtime-v2/utils/cli-process-runner.test.js +7 -5
  901. package/core/dist/runtime-v2/utils/cli-process-runner.test.js.map +1 -1
  902. package/core/dist/telemetry-event.d.ts +3 -3
  903. package/core/dist/telemetry-event.d.ts.map +1 -1
  904. package/core/dist/telemetry-event.js +34 -1
  905. package/core/dist/telemetry-event.js.map +1 -1
  906. package/core/dist/trajectory-store.js +0 -2
  907. package/core/dist/trajectory-store.js.map +1 -1
  908. package/core/package.json +10 -1
  909. package/dist/installer.d.ts +11 -0
  910. package/dist/installer.d.ts.map +1 -1
  911. package/dist/installer.js +47 -2
  912. package/dist/installer.js.map +1 -1
  913. package/dist/mvp-config.d.ts.map +1 -1
  914. package/dist/mvp-config.js +2 -0
  915. package/dist/mvp-config.js.map +1 -1
  916. package/package.json +3 -2
  917. package/pd-cli/dist/commands/__tests__/legacy-cleanup.test.d.ts +18 -0
  918. package/pd-cli/dist/commands/__tests__/legacy-cleanup.test.d.ts.map +1 -0
  919. package/pd-cli/dist/commands/__tests__/legacy-cleanup.test.js +459 -0
  920. package/pd-cli/dist/commands/__tests__/legacy-cleanup.test.js.map +1 -0
  921. package/pd-cli/dist/commands/__tests__/mvp-smoke.test.d.ts +15 -0
  922. package/pd-cli/dist/commands/__tests__/mvp-smoke.test.d.ts.map +1 -0
  923. package/pd-cli/dist/commands/__tests__/mvp-smoke.test.js +262 -0
  924. package/pd-cli/dist/commands/__tests__/mvp-smoke.test.js.map +1 -0
  925. package/pd-cli/dist/commands/__tests__/rulecode-flag-wiring.test.d.ts +21 -0
  926. package/pd-cli/dist/commands/__tests__/rulecode-flag-wiring.test.d.ts.map +1 -0
  927. package/pd-cli/dist/commands/__tests__/rulecode-flag-wiring.test.js +179 -0
  928. package/pd-cli/dist/commands/__tests__/rulecode-flag-wiring.test.js.map +1 -0
  929. package/pd-cli/dist/commands/__tests__/rulecode-handler.test.d.ts +16 -0
  930. package/pd-cli/dist/commands/__tests__/rulecode-handler.test.d.ts.map +1 -0
  931. package/pd-cli/dist/commands/__tests__/rulecode-handler.test.js +285 -0
  932. package/pd-cli/dist/commands/__tests__/rulecode-handler.test.js.map +1 -0
  933. package/pd-cli/dist/commands/__tests__/run-rulehost-flag-wiring.test.d.ts +24 -0
  934. package/pd-cli/dist/commands/__tests__/run-rulehost-flag-wiring.test.d.ts.map +1 -0
  935. package/pd-cli/dist/commands/__tests__/run-rulehost-flag-wiring.test.js +223 -0
  936. package/pd-cli/dist/commands/__tests__/run-rulehost-flag-wiring.test.js.map +1 -0
  937. package/pd-cli/dist/commands/__tests__/runtime-probe-config.test.d.ts +20 -0
  938. package/pd-cli/dist/commands/__tests__/runtime-probe-config.test.d.ts.map +1 -0
  939. package/pd-cli/dist/commands/__tests__/runtime-probe-config.test.js +388 -0
  940. package/pd-cli/dist/commands/__tests__/runtime-probe-config.test.js.map +1 -0
  941. package/pd-cli/dist/commands/build-trajectory-evidence.d.ts +21 -0
  942. package/pd-cli/dist/commands/build-trajectory-evidence.d.ts.map +1 -0
  943. package/pd-cli/dist/commands/build-trajectory-evidence.js +161 -0
  944. package/pd-cli/dist/commands/build-trajectory-evidence.js.map +1 -0
  945. package/pd-cli/dist/commands/candidate.d.ts +24 -0
  946. package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
  947. package/pd-cli/dist/commands/candidate.js +147 -75
  948. package/pd-cli/dist/commands/candidate.js.map +1 -1
  949. package/pd-cli/dist/commands/command-helpers.d.ts +19 -0
  950. package/pd-cli/dist/commands/command-helpers.d.ts.map +1 -0
  951. package/pd-cli/dist/commands/command-helpers.js +22 -0
  952. package/pd-cli/dist/commands/command-helpers.js.map +1 -0
  953. package/pd-cli/dist/commands/config-doctor.d.ts.map +1 -1
  954. package/pd-cli/dist/commands/config-doctor.js +21 -0
  955. package/pd-cli/dist/commands/config-doctor.js.map +1 -1
  956. package/pd-cli/dist/commands/diagnose.d.ts +1 -0
  957. package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
  958. package/pd-cli/dist/commands/diagnose.js +252 -149
  959. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  960. package/pd-cli/dist/commands/evolution-tasks-show.js +0 -1
  961. package/pd-cli/dist/commands/evolution-tasks-show.js.map +1 -1
  962. package/pd-cli/dist/commands/legacy-cleanup.d.ts +72 -6
  963. package/pd-cli/dist/commands/legacy-cleanup.d.ts.map +1 -1
  964. package/pd-cli/dist/commands/legacy-cleanup.js +243 -23
  965. package/pd-cli/dist/commands/legacy-cleanup.js.map +1 -1
  966. package/pd-cli/dist/commands/mvp-smoke.d.ts +30 -0
  967. package/pd-cli/dist/commands/mvp-smoke.d.ts.map +1 -0
  968. package/pd-cli/dist/commands/mvp-smoke.js +139 -0
  969. package/pd-cli/dist/commands/mvp-smoke.js.map +1 -0
  970. package/pd-cli/dist/commands/pain-record.d.ts +2 -0
  971. package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
  972. package/pd-cli/dist/commands/pain-record.js +45 -7
  973. package/pd-cli/dist/commands/pain-record.js.map +1 -1
  974. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  975. package/pd-cli/dist/commands/pain-retry.js +46 -43
  976. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  977. package/pd-cli/dist/commands/quality-scorecard.d.ts +9 -0
  978. package/pd-cli/dist/commands/quality-scorecard.d.ts.map +1 -0
  979. package/pd-cli/dist/commands/quality-scorecard.js +241 -0
  980. package/pd-cli/dist/commands/quality-scorecard.js.map +1 -0
  981. package/pd-cli/dist/commands/rulecode.d.ts +85 -0
  982. package/pd-cli/dist/commands/rulecode.d.ts.map +1 -0
  983. package/pd-cli/dist/commands/rulecode.js +356 -0
  984. package/pd-cli/dist/commands/rulecode.js.map +1 -0
  985. package/pd-cli/dist/commands/runtime-activation.d.ts +37 -0
  986. package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
  987. package/pd-cli/dist/commands/runtime-activation.js +416 -2
  988. package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
  989. package/pd-cli/dist/commands/runtime-features.d.ts.map +1 -1
  990. package/pd-cli/dist/commands/runtime-features.js +2 -7
  991. package/pd-cli/dist/commands/runtime-features.js.map +1 -1
  992. package/pd-cli/dist/commands/runtime-internalization-integrity-repair.d.ts.map +1 -1
  993. package/pd-cli/dist/commands/runtime-internalization-integrity-repair.js +25 -15
  994. package/pd-cli/dist/commands/runtime-internalization-integrity-repair.js.map +1 -1
  995. package/pd-cli/dist/commands/runtime-internalization-integrity.d.ts.map +1 -1
  996. package/pd-cli/dist/commands/runtime-internalization-integrity.js +42 -1
  997. package/pd-cli/dist/commands/runtime-internalization-integrity.js.map +1 -1
  998. package/pd-cli/dist/commands/runtime-internalization-queue.d.ts.map +1 -1
  999. package/pd-cli/dist/commands/runtime-internalization-queue.js +35 -3
  1000. package/pd-cli/dist/commands/runtime-internalization-queue.js.map +1 -1
  1001. package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
  1002. package/pd-cli/dist/commands/runtime-internalization-run-once.js +316 -320
  1003. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  1004. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts +23 -0
  1005. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -0
  1006. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +361 -0
  1007. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -0
  1008. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.d.ts +10 -0
  1009. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.d.ts.map +1 -0
  1010. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js +164 -0
  1011. package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js.map +1 -0
  1012. package/pd-cli/dist/commands/runtime-recovery.d.ts.map +1 -1
  1013. package/pd-cli/dist/commands/runtime-recovery.js +9 -8
  1014. package/pd-cli/dist/commands/runtime-recovery.js.map +1 -1
  1015. package/pd-cli/dist/commands/runtime.d.ts +7 -1
  1016. package/pd-cli/dist/commands/runtime.d.ts.map +1 -1
  1017. package/pd-cli/dist/commands/runtime.js +223 -30
  1018. package/pd-cli/dist/commands/runtime.js.map +1 -1
  1019. package/pd-cli/dist/commands/samples-list.js +0 -1
  1020. package/pd-cli/dist/commands/samples-list.js.map +1 -1
  1021. package/pd-cli/dist/commands/task.d.ts +11 -0
  1022. package/pd-cli/dist/commands/task.d.ts.map +1 -1
  1023. package/pd-cli/dist/commands/task.js +148 -6
  1024. package/pd-cli/dist/commands/task.js.map +1 -1
  1025. package/pd-cli/dist/index.d.ts +1 -1
  1026. package/pd-cli/dist/index.js +155 -70
  1027. package/pd-cli/dist/index.js.map +1 -1
  1028. package/pd-cli/dist/legacy/session-history-import.js +0 -19
  1029. package/pd-cli/dist/legacy/session-history-import.js.map +1 -1
  1030. package/pd-cli/dist/resolve-workspace.d.ts +15 -3
  1031. package/pd-cli/dist/resolve-workspace.d.ts.map +1 -1
  1032. package/pd-cli/dist/resolve-workspace.js +54 -8
  1033. package/pd-cli/dist/resolve-workspace.js.map +1 -1
  1034. package/pd-cli/dist/services/__tests__/cli-output.test.d.ts +18 -0
  1035. package/pd-cli/dist/services/__tests__/cli-output.test.d.ts.map +1 -0
  1036. package/pd-cli/dist/services/__tests__/cli-output.test.js +103 -0
  1037. package/pd-cli/dist/services/__tests__/cli-output.test.js.map +1 -0
  1038. package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.d.ts +18 -0
  1039. package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.d.ts.map +1 -0
  1040. package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.js +651 -0
  1041. package/pd-cli/dist/services/__tests__/runtime-adapter-resolver.test.js.map +1 -0
  1042. package/pd-cli/dist/services/cli-output.d.ts +61 -0
  1043. package/pd-cli/dist/services/cli-output.d.ts.map +1 -0
  1044. package/pd-cli/dist/services/cli-output.js +72 -0
  1045. package/pd-cli/dist/services/cli-output.js.map +1 -0
  1046. package/pd-cli/dist/services/config-doctor.d.ts +2 -0
  1047. package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
  1048. package/pd-cli/dist/services/config-doctor.js +11 -8
  1049. package/pd-cli/dist/services/config-doctor.js.map +1 -1
  1050. package/pd-cli/dist/services/console-launcher.js +1 -1
  1051. package/pd-cli/dist/services/console-launcher.js.map +1 -1
  1052. package/pd-cli/dist/services/demo-rule-compiler.d.ts +24 -0
  1053. package/pd-cli/dist/services/demo-rule-compiler.d.ts.map +1 -0
  1054. package/pd-cli/dist/services/demo-rule-compiler.js +58 -0
  1055. package/pd-cli/dist/services/demo-rule-compiler.js.map +1 -0
  1056. package/pd-cli/dist/services/feature-flag-loader.js +0 -1
  1057. package/pd-cli/dist/services/feature-flag-loader.js.map +1 -1
  1058. package/pd-cli/dist/services/mainline-snapshot-assembler.d.ts +35 -0
  1059. package/pd-cli/dist/services/mainline-snapshot-assembler.d.ts.map +1 -0
  1060. package/pd-cli/dist/services/mainline-snapshot-assembler.js +428 -0
  1061. package/pd-cli/dist/services/mainline-snapshot-assembler.js.map +1 -0
  1062. package/pd-cli/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
  1063. package/pd-cli/dist/services/pain-flood-simulation-runner.js +95 -10
  1064. package/pd-cli/dist/services/pain-flood-simulation-runner.js.map +1 -1
  1065. package/pd-cli/dist/services/pd-config-loader.d.ts +20 -0
  1066. package/pd-cli/dist/services/pd-config-loader.d.ts.map +1 -1
  1067. package/pd-cli/dist/services/pd-config-loader.js +113 -0
  1068. package/pd-cli/dist/services/pd-config-loader.js.map +1 -1
  1069. package/pd-cli/dist/services/quality-scorecard/data-extractor.d.ts +28 -0
  1070. package/pd-cli/dist/services/quality-scorecard/data-extractor.d.ts.map +1 -0
  1071. package/pd-cli/dist/services/quality-scorecard/data-extractor.js +118 -0
  1072. package/pd-cli/dist/services/quality-scorecard/data-extractor.js.map +1 -0
  1073. package/pd-cli/dist/services/quality-scorecard/local-evaluator.d.ts +18 -0
  1074. package/pd-cli/dist/services/quality-scorecard/local-evaluator.d.ts.map +1 -0
  1075. package/pd-cli/dist/services/quality-scorecard/local-evaluator.js +112 -0
  1076. package/pd-cli/dist/services/quality-scorecard/local-evaluator.js.map +1 -0
  1077. package/pd-cli/dist/services/quality-scorecard/strong-model-gate.d.ts +14 -0
  1078. package/pd-cli/dist/services/quality-scorecard/strong-model-gate.d.ts.map +1 -0
  1079. package/pd-cli/dist/services/quality-scorecard/strong-model-gate.js +128 -0
  1080. package/pd-cli/dist/services/quality-scorecard/strong-model-gate.js.map +1 -0
  1081. package/pd-cli/dist/services/resolve-runtime-from-pd-config.d.ts +70 -0
  1082. package/pd-cli/dist/services/resolve-runtime-from-pd-config.d.ts.map +1 -0
  1083. package/pd-cli/dist/services/resolve-runtime-from-pd-config.js +138 -0
  1084. package/pd-cli/dist/services/resolve-runtime-from-pd-config.js.map +1 -0
  1085. package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts +132 -0
  1086. package/pd-cli/dist/services/rulehost-pipeline-runner.d.ts.map +1 -0
  1087. package/pd-cli/dist/services/rulehost-pipeline-runner.js +392 -0
  1088. package/pd-cli/dist/services/rulehost-pipeline-runner.js.map +1 -0
  1089. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts +105 -0
  1090. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -0
  1091. package/pd-cli/dist/services/runtime-adapter-resolver.js +188 -0
  1092. package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -0
  1093. package/pd-cli/dist/services/synthetic-baseline-runner.d.ts.map +1 -1
  1094. package/pd-cli/dist/services/synthetic-baseline-runner.js +97 -6
  1095. package/pd-cli/dist/services/synthetic-baseline-runner.js.map +1 -1
  1096. package/pd-cli/dist/utils/production-workspace-guard.d.ts +0 -7
  1097. package/pd-cli/dist/utils/production-workspace-guard.d.ts.map +1 -1
  1098. package/pd-cli/dist/utils/production-workspace-guard.js +0 -11
  1099. package/pd-cli/dist/utils/production-workspace-guard.js.map +1 -1
  1100. package/pd-cli/dist/utils/production-workspace-guard.test.js +9 -2
  1101. package/pd-cli/dist/utils/production-workspace-guard.test.js.map +1 -1
  1102. package/pd-cli/package.json +3 -2
  1103. package/plugin/dist/config/defaults/runtime.d.ts +0 -6
  1104. package/plugin/dist/config/defaults/runtime.js +0 -7
  1105. package/plugin/dist/core/code-implementation-storage.d.ts +0 -9
  1106. package/plugin/dist/core/code-implementation-storage.js +0 -34
  1107. package/plugin/dist/core/config-health.d.ts +27 -0
  1108. package/plugin/dist/core/config-health.js +60 -0
  1109. package/plugin/dist/core/event-log.d.ts +10 -1
  1110. package/plugin/dist/core/event-log.js +11 -0
  1111. package/plugin/dist/core/init.d.ts +1 -1
  1112. package/plugin/dist/core/init.js +10 -14
  1113. package/plugin/dist/core/paths.d.ts +0 -6
  1114. package/plugin/dist/core/paths.js +0 -6
  1115. package/plugin/dist/core/principle-compiler/code-validator.js +4 -1
  1116. package/plugin/dist/core/principle-tree-ledger.d.ts +0 -4
  1117. package/plugin/dist/core/principle-tree-ledger.js +0 -7
  1118. package/plugin/dist/core/rule-host.d.ts +45 -15
  1119. package/plugin/dist/core/rule-host.js +240 -81
  1120. package/plugin/dist/core/rule-implementation-runtime.d.ts +13 -0
  1121. package/plugin/dist/core/rule-implementation-runtime.js +91 -3
  1122. package/plugin/dist/core/runtime-v2-prompt-activation-reader.js +2 -2
  1123. package/plugin/dist/core/thinking-models.d.ts +3 -2
  1124. package/plugin/dist/core/thinking-models.js +9 -29
  1125. package/plugin/dist/core/trajectory-types.d.ts +4 -0
  1126. package/plugin/dist/core/trajectory.js +55 -5
  1127. package/plugin/dist/core/workspace-dir-validation.d.ts +2 -2
  1128. package/plugin/dist/core/workspace-dir-validation.js +2 -2
  1129. package/plugin/dist/hooks/after-tool-call-helpers.d.ts +8 -9
  1130. package/plugin/dist/hooks/after-tool-call-helpers.js +89 -100
  1131. package/plugin/dist/hooks/after-tool-call-types.d.ts +2 -8
  1132. package/plugin/dist/hooks/gate.js +1 -1
  1133. package/plugin/dist/hooks/llm.js +11 -2
  1134. package/plugin/dist/hooks/pain.d.ts +0 -1
  1135. package/plugin/dist/hooks/pain.js +3 -2
  1136. package/plugin/dist/hooks/raw-observation-adapter.d.ts +57 -0
  1137. package/plugin/dist/hooks/raw-observation-adapter.js +170 -0
  1138. package/plugin/dist/hooks/raw-observation-types.d.ts +62 -0
  1139. package/plugin/dist/hooks/raw-observation-types.js +15 -0
  1140. package/plugin/dist/hooks/trajectory-collector.d.ts +17 -28
  1141. package/plugin/dist/hooks/trajectory-collector.js +71 -104
  1142. package/plugin/dist/hooks/trajectory-evidence.js +23 -0
  1143. package/plugin/dist/hooks/triage-adapter.d.ts +7 -31
  1144. package/plugin/dist/hooks/triage-adapter.js +32 -61
  1145. package/plugin/dist/hooks/trigger-cooldown-tracker.d.ts +30 -0
  1146. package/plugin/dist/hooks/trigger-cooldown-tracker.js +55 -0
  1147. package/plugin/dist/index.d.ts +11 -0
  1148. package/plugin/dist/index.js +73 -27
  1149. package/plugin/dist/openclaw-sdk.d.ts +1 -0
  1150. package/plugin/dist/service/evolution-worker.d.ts +1 -1
  1151. package/plugin/dist/service/internalization-auto-consumer-service.d.ts +8 -0
  1152. package/plugin/dist/service/internalization-auto-consumer-service.js +322 -0
  1153. package/plugin/dist/types/event-types.d.ts +1 -1
  1154. package/plugin/dist/utils/io.js +24 -3
  1155. package/plugin/package.json +4 -3
  1156. package/plugin/scripts/sync-plugin.mjs +43 -0
  1157. package/plugin/templates/langs/en/principles/THINKING_OS.md +12 -0
  1158. package/plugin/templates/langs/en/skills/pd-runtime-v2/SKILL.md +1 -1
  1159. package/plugin/templates/langs/zh/principles/THINKING_OS.md +12 -0
  1160. package/plugin/templates/langs/zh/skills/pd-runtime-v2/SKILL.md +1 -1
  1161. package/templates/langs/en/principles/THINKING_OS.md +12 -0
  1162. package/templates/langs/zh/principles/THINKING_OS.md +12 -0
  1163. package/console/dist/server/routes/state.d.ts +0 -11
  1164. package/console/dist/server/routes/state.js +0 -97
  1165. package/console/dist/ui/components/UpdateBanner.d.ts +0 -1
  1166. package/console/dist/ui/components/UpdateBanner.js +0 -41
  1167. package/console/dist/ui/components/UpdateProgressDialog.d.ts +0 -12
  1168. package/console/dist/ui/components/UpdateProgressDialog.js +0 -28
  1169. package/console/dist/ui/components/approval-card.d.ts +0 -8
  1170. package/console/dist/ui/components/approval-card.js +0 -39
  1171. package/console/dist/ui/components/approval-detail-dialog.d.ts +0 -9
  1172. package/console/dist/ui/components/approval-detail-dialog.js +0 -20
  1173. package/console/dist/ui/components/rejection-reason-dialog.d.ts +0 -6
  1174. package/console/dist/ui/components/rejection-reason-dialog.js +0 -23
  1175. package/core/dist/evolution-hook.d.ts +0 -70
  1176. package/core/dist/evolution-hook.d.ts.map +0 -1
  1177. package/core/dist/evolution-hook.js +0 -10
  1178. package/core/dist/evolution-hook.js.map +0 -1
  1179. package/core/dist/pain-flag-resolver.d.ts +0 -18
  1180. package/core/dist/pain-flag-resolver.d.ts.map +0 -1
  1181. package/core/dist/pain-flag-resolver.js +0 -21
  1182. package/core/dist/pain-flag-resolver.js.map +0 -1
  1183. package/core/dist/pain-recorder.d.ts +0 -38
  1184. package/core/dist/pain-recorder.d.ts.map +0 -1
  1185. package/core/dist/pain-recorder.js +0 -62
  1186. package/core/dist/pain-recorder.js.map +0 -1
  1187. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.integration.test.d.ts +0 -2
  1188. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.integration.test.d.ts.map +0 -1
  1189. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.integration.test.js +0 -170
  1190. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.integration.test.js.map +0 -1
  1191. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.test.d.ts +0 -2
  1192. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.test.d.ts.map +0 -1
  1193. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.test.js +0 -396
  1194. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.test.js.map +0 -1
  1195. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.d.ts +0 -13
  1196. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.d.ts.map +0 -1
  1197. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.js +0 -97
  1198. package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.js.map +0 -1
  1199. package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.integration.test.d.ts +0 -2
  1200. package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.integration.test.d.ts.map +0 -1
  1201. package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.integration.test.js +0 -378
  1202. package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.integration.test.js.map +0 -1
  1203. package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.d.ts +0 -2
  1204. package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.d.ts.map +0 -1
  1205. package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.js +0 -682
  1206. package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.js.map +0 -1
  1207. package/core/dist/runtime-v2/runner/__tests__/diagnostician-telemetry.test.d.ts +0 -2
  1208. package/core/dist/runtime-v2/runner/__tests__/diagnostician-telemetry.test.d.ts.map +0 -1
  1209. package/core/dist/runtime-v2/runner/__tests__/diagnostician-telemetry.test.js +0 -286
  1210. package/core/dist/runtime-v2/runner/__tests__/diagnostician-telemetry.test.js.map +0 -1
  1211. package/core/dist/runtime-v2/runner/__tests__/dual-track-e2e.test.d.ts +0 -2
  1212. package/core/dist/runtime-v2/runner/__tests__/dual-track-e2e.test.d.ts.map +0 -1
  1213. package/core/dist/runtime-v2/runner/__tests__/dual-track-e2e.test.js +0 -320
  1214. package/core/dist/runtime-v2/runner/__tests__/dual-track-e2e.test.js.map +0 -1
  1215. package/core/dist/runtime-v2/runner/__tests__/lease-expiration-recovery.integration.test.d.ts +0 -2
  1216. package/core/dist/runtime-v2/runner/__tests__/lease-expiration-recovery.integration.test.d.ts.map +0 -1
  1217. package/core/dist/runtime-v2/runner/__tests__/lease-expiration-recovery.integration.test.js +0 -261
  1218. package/core/dist/runtime-v2/runner/__tests__/lease-expiration-recovery.integration.test.js.map +0 -1
  1219. package/core/dist/runtime-v2/runner/__tests__/m5-05-e2e.test.d.ts +0 -2
  1220. package/core/dist/runtime-v2/runner/__tests__/m5-05-e2e.test.d.ts.map +0 -1
  1221. package/core/dist/runtime-v2/runner/__tests__/m5-05-e2e.test.js +0 -405
  1222. package/core/dist/runtime-v2/runner/__tests__/m5-05-e2e.test.js.map +0 -1
  1223. package/core/dist/runtime-v2/runner/__tests__/m6-06-e2e.test.d.ts +0 -2
  1224. package/core/dist/runtime-v2/runner/__tests__/m6-06-e2e.test.d.ts.map +0 -1
  1225. package/core/dist/runtime-v2/runner/__tests__/m6-06-e2e.test.js +0 -347
  1226. package/core/dist/runtime-v2/runner/__tests__/m6-06-e2e.test.js.map +0 -1
  1227. package/core/dist/runtime-v2/runner/__tests__/m6-06-legacy.test.d.ts +0 -2
  1228. package/core/dist/runtime-v2/runner/__tests__/m6-06-legacy.test.d.ts.map +0 -1
  1229. package/core/dist/runtime-v2/runner/__tests__/m6-06-legacy.test.js +0 -186
  1230. package/core/dist/runtime-v2/runner/__tests__/m6-06-legacy.test.js.map +0 -1
  1231. package/core/dist/runtime-v2/runner/__tests__/m6-06-real-path.test.d.ts +0 -2
  1232. package/core/dist/runtime-v2/runner/__tests__/m6-06-real-path.test.d.ts.map +0 -1
  1233. package/core/dist/runtime-v2/runner/__tests__/m6-06-real-path.test.js +0 -355
  1234. package/core/dist/runtime-v2/runner/__tests__/m6-06-real-path.test.js.map +0 -1
  1235. package/core/dist/runtime-v2/runner/__tests__/m8-02-e2e.test.d.ts +0 -2
  1236. package/core/dist/runtime-v2/runner/__tests__/m8-02-e2e.test.d.ts.map +0 -1
  1237. package/core/dist/runtime-v2/runner/__tests__/m8-02-e2e.test.js +0 -488
  1238. package/core/dist/runtime-v2/runner/__tests__/m8-02-e2e.test.js.map +0 -1
  1239. package/core/dist/runtime-v2/runner/__tests__/m9-adapter-integration.test.d.ts +0 -2
  1240. package/core/dist/runtime-v2/runner/__tests__/m9-adapter-integration.test.d.ts.map +0 -1
  1241. package/core/dist/runtime-v2/runner/__tests__/m9-adapter-integration.test.js +0 -171
  1242. package/core/dist/runtime-v2/runner/__tests__/m9-adapter-integration.test.js.map +0 -1
  1243. package/core/dist/runtime-v2/runner/__tests__/m9-e2e.test.d.ts +0 -2
  1244. package/core/dist/runtime-v2/runner/__tests__/m9-e2e.test.d.ts.map +0 -1
  1245. package/core/dist/runtime-v2/runner/__tests__/m9-e2e.test.js +0 -182
  1246. package/core/dist/runtime-v2/runner/__tests__/m9-e2e.test.js.map +0 -1
  1247. package/core/dist/runtime-v2/runner/__tests__/max-attempts-exceeded.integration.test.d.ts +0 -2
  1248. package/core/dist/runtime-v2/runner/__tests__/max-attempts-exceeded.integration.test.d.ts.map +0 -1
  1249. package/core/dist/runtime-v2/runner/__tests__/max-attempts-exceeded.integration.test.js +0 -276
  1250. package/core/dist/runtime-v2/runner/__tests__/max-attempts-exceeded.integration.test.js.map +0 -1
  1251. package/core/dist/runtime-v2/runner/__tests__/retry-wait-recovery.integration.test.d.ts +0 -2
  1252. package/core/dist/runtime-v2/runner/__tests__/retry-wait-recovery.integration.test.d.ts.map +0 -1
  1253. package/core/dist/runtime-v2/runner/__tests__/retry-wait-recovery.integration.test.js +0 -272
  1254. package/core/dist/runtime-v2/runner/__tests__/retry-wait-recovery.integration.test.js.map +0 -1
  1255. package/core/dist/runtime-v2/runner/__tests__/start-run-input.test.d.ts +0 -2
  1256. package/core/dist/runtime-v2/runner/__tests__/start-run-input.test.d.ts.map +0 -1
  1257. package/core/dist/runtime-v2/runner/__tests__/start-run-input.test.js +0 -67
  1258. package/core/dist/runtime-v2/runner/__tests__/start-run-input.test.js.map +0 -1
  1259. package/core/dist/runtime-v2/runner/diagnostician-runner-options.d.ts +0 -47
  1260. package/core/dist/runtime-v2/runner/diagnostician-runner-options.d.ts.map +0 -1
  1261. package/core/dist/runtime-v2/runner/diagnostician-runner-options.js +0 -20
  1262. package/core/dist/runtime-v2/runner/diagnostician-runner-options.js.map +0 -1
  1263. package/core/dist/runtime-v2/runner/diagnostician-runner.d.ts +0 -87
  1264. package/core/dist/runtime-v2/runner/diagnostician-runner.d.ts.map +0 -1
  1265. package/core/dist/runtime-v2/runner/diagnostician-runner.js +0 -441
  1266. package/core/dist/runtime-v2/runner/diagnostician-runner.js.map +0 -1
  1267. package/core/dist/storage-adapter.d.ts +0 -59
  1268. package/core/dist/storage-adapter.d.ts.map +0 -1
  1269. package/core/dist/storage-adapter.js +0 -2
  1270. package/core/dist/storage-adapter.js.map +0 -1
  1271. package/core/dist/types/workspace-resolver.d.ts +0 -25
  1272. package/core/dist/types/workspace-resolver.d.ts.map +0 -1
  1273. package/core/dist/types/workspace-resolver.js +0 -10
  1274. package/core/dist/types/workspace-resolver.js.map +0 -1
  1275. package/core/dist/types.d.ts +0 -56
  1276. package/core/dist/types.d.ts.map +0 -1
  1277. package/core/dist/types.js +0 -16
  1278. package/core/dist/types.js.map +0 -1
  1279. package/pd-cli/dist/principle-tree-ledger-adapter.d.ts +0 -12
  1280. package/pd-cli/dist/principle-tree-ledger-adapter.d.ts.map +0 -1
  1281. package/pd-cli/dist/principle-tree-ledger-adapter.js +0 -12
  1282. package/pd-cli/dist/principle-tree-ledger-adapter.js.map +0 -1
  1283. package/plugin/dist/core/evolution-hook.d.ts +0 -54
  1284. package/plugin/dist/core/evolution-hook.js +0 -9
  1285. package/plugin/dist/core/file-storage-adapter.d.ts +0 -43
  1286. package/plugin/dist/core/file-storage-adapter.js +0 -158
  1287. package/plugin/dist/core/merge-gate-audit.d.ts +0 -21
  1288. package/plugin/dist/core/merge-gate-audit.js +0 -241
  1289. package/plugin/dist/core/pain-context-extractor.d.ts +0 -31
  1290. package/plugin/dist/core/pain-context-extractor.js +0 -278
  1291. package/plugin/dist/core/pain-lifecycle.d.ts +0 -15
  1292. package/plugin/dist/core/pain-lifecycle.js +0 -37
  1293. package/plugin/dist/core/pain-signal-adapter.d.ts +0 -37
  1294. package/plugin/dist/core/pain-signal-adapter.js +0 -1
  1295. package/plugin/dist/core/pain-signal.d.ts +0 -6
  1296. package/plugin/dist/core/pain-signal.js +0 -3
  1297. package/plugin/dist/core/principle-injector.d.ts +0 -55
  1298. package/plugin/dist/core/principle-injector.js +0 -17
  1299. package/plugin/dist/core/principle-tree-migration.d.ts +0 -35
  1300. package/plugin/dist/core/principle-tree-migration.js +0 -137
  1301. package/plugin/dist/core/storage-adapter.d.ts +0 -58
  1302. package/plugin/dist/core/storage-adapter.js +0 -1
  1303. package/plugin/dist/core/telemetry-event.d.ts +0 -66
  1304. package/plugin/dist/core/telemetry-event.js +0 -86
  1305. package/plugin/dist/core/training-program.d.ts +0 -233
  1306. package/plugin/dist/core/training-program.js +0 -435
  1307. package/plugin/dist/core/workspace-dir-service.d.ts +0 -33
  1308. package/plugin/dist/core/workspace-dir-service.js +0 -71
  1309. package/plugin/dist/hooks/lifecycle-routing.d.ts +0 -24
  1310. package/plugin/dist/hooks/lifecycle-routing.js +0 -110
  1311. package/plugin/dist/service/event-log-auditor.d.ts +0 -46
  1312. package/plugin/dist/service/event-log-auditor.js +0 -236
  1313. package/plugin/dist/service/evolution-queue-lock.d.ts +0 -18
  1314. package/plugin/dist/service/evolution-queue-lock.js +0 -36
  1315. package/plugin/dist/service/failure-classifier.d.ts +0 -46
  1316. package/plugin/dist/service/failure-classifier.js +0 -57
  1317. package/plugin/dist/service/internalization-trigger-adapter.d.ts +0 -51
  1318. package/plugin/dist/service/internalization-trigger-adapter.js +0 -184
  1319. package/plugin/dist/service/monitoring-query-service.d.ts +0 -21
  1320. package/plugin/dist/service/monitoring-query-service.js +0 -45
  1321. package/plugin/dist/service/subagent-workflow/index.d.ts +0 -3
  1322. package/plugin/dist/service/subagent-workflow/index.js +0 -2
  1323. package/plugin/dist/tools/critique-prompt.d.ts +0 -1
  1324. package/plugin/dist/tools/critique-prompt.js +0 -1
  1325. package/plugin/dist/tools/deep-reflect.d.ts +0 -1
  1326. package/plugin/dist/tools/deep-reflect.js +0 -1
  1327. package/plugin/dist/tools/model-index.d.ts +0 -1
  1328. package/plugin/dist/tools/model-index.js +0 -1
  1329. package/plugin/dist/types/event-payload.d.ts +0 -2
  1330. package/plugin/dist/types/event-payload.js +0 -1
  1331. package/plugin/dist/utils/glob-match.d.ts +0 -28
  1332. package/plugin/dist/utils/glob-match.js +0 -49
  1333. package/plugin/dist/utils/nlp.d.ts +0 -4
  1334. package/plugin/dist/utils/nlp.js +0 -21
  1335. package/plugin/dist/utils/plugin-logger.d.ts +0 -39
  1336. package/plugin/dist/utils/plugin-logger.js +0 -70
  1337. package/plugin/dist/utils/subagent-probe.d.ts +0 -35
  1338. package/plugin/dist/utils/subagent-probe.js +0 -67
@@ -0,0 +1,478 @@
1
+ /**
2
+ * PRI-419 §M2+§M3 — L2AgentLoopAdapter.
3
+ *
4
+ * A PDRuntimeAdapter that runs the dreamer through a multi-turn agent loop
5
+ * (@earendil-works/pi-agent-core) with read-only tools, instead of the one-shot
6
+ * completeSimple path in PiAiRuntimeAdapter.
7
+ *
8
+ * Why the low-level runAgentLoop() and not the Agent class (review P0-1):
9
+ * Agent.createLoopConfig() does NOT forward shouldStopAfterTurn (agent.ts:422-449),
10
+ * which is exactly the hook we need to (a) cap turns and (b) terminate the loop when
11
+ * submit_output captures output. runAgentLoop gives us shouldStopAfterTurn +
12
+ * beforeToolCall + tools + abort signal in one config, and returns the final
13
+ * transcript directly. The Agent class adds steering/followup/session machinery the
14
+ * headless dreamer runner does not need.
15
+ *
16
+ * Why submit_output termination is NOT left to terminate: (review P0-2)
17
+ * agent-loop's shouldTerminateToolBatch uses .every(r => r.result.terminate) over the
18
+ * whole batch (agent-loop.ts:544). If the model calls read_principles + submit_output
19
+ * in the same turn, the batch does not terminate. We instead stop via
20
+ * shouldStopAfterTurn checking the L2OutputCapture, which is turn-granular.
21
+ *
22
+ * Output extraction:
23
+ * 1. Primary: the params captured by the submit_output tool (deterministic, the
24
+ * model called the tool with a full DreamerOutputV1).
25
+ * 2. Fallback: if the loop ends without a capture, walk the transcript backwards to
26
+ * the last assistant message containing text content, then extract JSON via the
27
+ * same extractJsonObject used by the L1 path. This preserves behaviour when a
28
+ * model emits free text instead of calling submit_output.
29
+ *
30
+ * Boundary: this adapter lives in core (it is pure orchestration of pi-agent-core +
31
+ * the in-process tool contract from §M1; no node:* imports, no fs). The injected
32
+ * readers (PdL2ArtifactReader / PdL2PrincipleReader) are supplied by the factory with
33
+ * concrete stores that satisfy them structurally.
34
+ */
35
+ import { runAgentLoop } from '@earendil-works/pi-agent-core';
36
+ import { getModel, getProviders, completeSimple } from '@earendil-works/pi-ai';
37
+ import { storeEmitter } from '../store/event-emitter.js';
38
+ import { PDRuntimeError } from '../error-categories.js';
39
+ import { extractJsonObject } from './json-extractor.js';
40
+ import { safeStringifyPreview } from './output-repair-contract.js';
41
+ import { buildDreamerL2Tools, DREAMER_L2_TOOL_WHITELIST, } from '../tools/agent-tool-contract.js';
42
+ /**
43
+ * Resolve a pi-ai Model from provider/model/baseUrl config (mirrors PiAiRuntimeAdapter's
44
+ * internal resolveModel — duplicated here because L2 imports from the @earendil-works scope
45
+ * while L1 uses @mariozechner; the two scopes must not cross-import). Built-in providers use
46
+ * getModel(); custom OpenAI-compatible endpoints construct a Model object directly.
47
+ */
48
+ export function resolveL2Model(provider, modelId, baseUrl) {
49
+ const knownProviders = getProviders();
50
+ if (knownProviders.includes(provider) && !baseUrl) {
51
+ // @ts-expect-error — getModel requires literal model ID types; runtime strings from config are acceptable
52
+ return getModel(provider, modelId);
53
+ }
54
+ if (!baseUrl) {
55
+ throw new PDRuntimeError('runtime_unavailable', `Provider '${provider}' is not a built-in pi-ai provider and requires a custom baseUrl.`);
56
+ }
57
+ // Custom provider with baseUrl — construct a Model object directly (openai-completions API).
58
+ // The literal object doesn't fully satisfy Model<string>'s discriminant union, so narrow via unknown.
59
+ const customModel = {
60
+ id: modelId,
61
+ name: modelId,
62
+ api: 'openai-completions',
63
+ provider,
64
+ baseUrl,
65
+ reasoning: false,
66
+ input: ['text'],
67
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
68
+ contextWindow: 128000,
69
+ maxTokens: 32000,
70
+ compat: {
71
+ supportsStore: false,
72
+ supportsDeveloperRole: false,
73
+ supportsReasoningEffort: false,
74
+ supportsUsageInStreaming: true,
75
+ maxTokensField: 'max_tokens',
76
+ requiresToolResultName: false,
77
+ requiresAssistantAfterToolResult: false,
78
+ requiresThinkingAsText: false,
79
+ requiresReasoningContentOnAssistantMessages: false,
80
+ thinkingFormat: 'deepseek',
81
+ supportsStrictMode: false,
82
+ },
83
+ };
84
+ // RUNTIME_CONTRACT: this double-assertion narrows a literal object to Model<string>'s
85
+ // discriminant union (the literal doesn't fully satisfy every union arm). If pi-agent-core
86
+ // changes Model's shape after an upgrade, this will NOT be caught at compile time — re-verify
87
+ // resolveL2Model's return against the live provider path after any @earendil-works/pi-ai bump.
88
+ return customModel;
89
+ }
90
+ const DEFAULT_MAX_TURNS = 5;
91
+ const DEFAULT_TOTAL_BUDGET_MS = 300_000;
92
+ const DEFAULT_MAX_EMPTY_RETRIES = 2;
93
+ /**
94
+ * Maximum number of completed run records retained in memory. The runs Map is bounded to
95
+ * prevent unbounded growth in long-running services (e.g. the auto-consumer wakes every 120s).
96
+ * When exceeded, the oldest entries are evicted. fetchOutput/pollRun only need recent runs.
97
+ */
98
+ const MAX_RETAINED_RUNS = 100;
99
+ /** Walk the transcript backwards to the last assistant message containing text content. */
100
+ function extractLastAssistantText(messages) {
101
+ for (let i = messages.length - 1; i >= 0; i--) {
102
+ const msg = messages[i];
103
+ if (!msg || msg.role !== 'assistant')
104
+ continue;
105
+ const content = msg.content;
106
+ if (typeof content === 'string' && content.trim().length > 0) {
107
+ return content;
108
+ }
109
+ if (Array.isArray(content)) {
110
+ for (const part of content) {
111
+ if (part && typeof part === 'object' && Object.hasOwn(part, 'type')) {
112
+ const typeValue = Reflect.get(part, 'type');
113
+ if (typeValue === 'text') {
114
+ const textValue = Reflect.get(part, 'text');
115
+ if (typeof textValue === 'string' && textValue.trim().length > 0)
116
+ return textValue;
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+ return null;
123
+ }
124
+ export class L2AgentLoopAdapter {
125
+ config;
126
+ deps;
127
+ eventEmitter;
128
+ runs = new Map();
129
+ abortControllers = new Map();
130
+ constructor(config, deps) {
131
+ this.config = config;
132
+ this.deps = deps;
133
+ this.eventEmitter = config.eventEmitter ?? storeEmitter;
134
+ }
135
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this -- required by PDRuntimeAdapter interface
136
+ kind() {
137
+ return 'pi-ai-l2';
138
+ }
139
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this -- required by PDRuntimeAdapter interface
140
+ async getCapabilities() {
141
+ return {
142
+ supportsStructuredJsonOutput: true,
143
+ supportsToolUse: true, // L2 is defined by tool use
144
+ supportsWorkingDirectory: false,
145
+ supportsModelSelection: true,
146
+ supportsLongRunningSessions: false,
147
+ supportsCancellation: true,
148
+ supportsArtifactWriteBack: false,
149
+ supportsConcurrentRuns: false,
150
+ supportsStreaming: false,
151
+ };
152
+ }
153
+ async refreshCapabilities() {
154
+ return this.getCapabilities();
155
+ }
156
+ async healthCheck() {
157
+ const lastCheckedAt = new Date().toISOString();
158
+ const apiKey = process.env[this.config.apiKeyEnv];
159
+ if (!apiKey) {
160
+ return {
161
+ healthy: false,
162
+ degraded: false,
163
+ warnings: [`API key not found in env: ${this.config.apiKeyEnv}`],
164
+ lastCheckedAt,
165
+ };
166
+ }
167
+ return {
168
+ healthy: true,
169
+ degraded: false,
170
+ warnings: [],
171
+ lastCheckedAt,
172
+ };
173
+ }
174
+ async startRun(input) {
175
+ const runId = crypto.randomUUID();
176
+ const startedAt = new Date().toISOString();
177
+ const apiKey = process.env[this.config.apiKeyEnv];
178
+ if (!apiKey) {
179
+ throw new PDRuntimeError('runtime_unavailable', `API key not found in env: ${this.config.apiKeyEnv}`);
180
+ }
181
+ const taskId = input.taskRef?.taskId ?? runId;
182
+ const runState = { runId, startedAt, endedAt: startedAt, status: 'failed' };
183
+ this.runs.set(runId, runState);
184
+ this.evictOldRuns();
185
+ const totalBudgetMs = this.config.totalBudgetMs ?? DEFAULT_TOTAL_BUDGET_MS;
186
+ const maxTurns = this.config.maxTurns ?? DEFAULT_MAX_TURNS;
187
+ const maxEmptyRetries = this.config.maxEmptyRetries ?? DEFAULT_MAX_EMPTY_RETRIES;
188
+ const l2FallbackToL1 = this.config.l2FallbackToL1 ?? true;
189
+ const abortController = new AbortController();
190
+ this.abortControllers.set(runId, abortController);
191
+ const budgetTimer = setTimeout(() => abortController.abort(), totalBudgetMs);
192
+ // Build the prompt message (the dreamer prompt builder already produces one JSON-string message).
193
+ // Serialized before the try block: if inputPayload is non-serializable (circular/BigInt),
194
+ // fail loud with cleanup so budgetTimer/abortController don't leak.
195
+ let messageContent;
196
+ try {
197
+ messageContent = typeof input.inputPayload === 'string'
198
+ ? input.inputPayload
199
+ : JSON.stringify(input.inputPayload);
200
+ }
201
+ catch (err) {
202
+ clearTimeout(budgetTimer);
203
+ this.abortControllers.delete(runId);
204
+ const reason = err instanceof Error ? err.message : String(err);
205
+ runState.status = 'failed';
206
+ runState.reason = `inputPayload not serializable: ${reason}`;
207
+ runState.endedAt = new Date().toISOString();
208
+ throw new PDRuntimeError('input_invalid', `L2 inputPayload is not serializable: ${reason}`, { nextAction: 'ensure StartRunInput.inputPayload is a string or JSON-serializable object' });
209
+ }
210
+ // Tool usage instruction appended so the model knows the tool protocol.
211
+ const toolInstruction = '\n\n--- Tool protocol (L2 mode) ---\n' +
212
+ 'You have read-only tools to ground your output:\n' +
213
+ ' - read_principles: read the core axioms (T-01..T-10) + already-internalized principles. Call BEFORE proposing candidates.\n' +
214
+ ' - read_artifact: read a predecessor pipeline artifact by artifactId or sourceTaskId to verify the evidence chain.\n' +
215
+ ' - submit_output: submit your final DreamerOutputV1. You MUST call this exactly once with a complete object; the loop stops after you call it.\n' +
216
+ 'Do not emit your final answer as free text — call submit_output.';
217
+ const prompts = [
218
+ { role: 'user', content: messageContent + toolInstruction, timestamp: Date.now() },
219
+ ];
220
+ // Telemetry accumulator shared across all L2 attempts (PRI-420 retry loop).
221
+ const toolsInvoked = {};
222
+ let totalRetryCount = 0;
223
+ let totalTurnCount = 0;
224
+ const emitLoopStarted = () => {
225
+ this.eventEmitter.emitTelemetry({
226
+ eventType: 'dreamer_l2_turn',
227
+ traceId: taskId,
228
+ timestamp: new Date().toISOString(),
229
+ sessionId: 'l2-adapter',
230
+ agentId: 'dreamer-l2',
231
+ payload: { runId, phase: 'loop_started', maxTurns, totalBudgetMs, maxEmptyRetries },
232
+ });
233
+ };
234
+ /**
235
+ * PRI-420: run a single agentLoop attempt with fresh state (EP-05: each retry uses fresh
236
+ * outputCapture/turnCount, never stale loop state).
237
+ * Returns a result with a `status` discriminator: 'ok' (output extracted), 'empty'
238
+ * (no output — triggers retry/fallback), or 'error' (loop threw).
239
+ */
240
+ const runSingleAttempt = async () => {
241
+ // Fresh capture + turn counter per attempt (EP-05 loop-state freshness).
242
+ const outputCapture = { output: null };
243
+ let turnCount = 0;
244
+ const toolContext = {
245
+ artifactReader: this.deps.artifactReader,
246
+ principleReader: this.deps.principleReader,
247
+ outputCapture,
248
+ onToolExecution: (info) => {
249
+ toolsInvoked[info.toolName] = (toolsInvoked[info.toolName] ?? 0) + 1;
250
+ this.eventEmitter.emitTelemetry({
251
+ eventType: 'dreamer_l2_turn',
252
+ traceId: taskId,
253
+ timestamp: new Date().toISOString(),
254
+ sessionId: 'l2-adapter',
255
+ agentId: 'dreamer-l2',
256
+ payload: { runId, toolName: info.toolName, ok: info.ok, error: info.error, turn: turnCount },
257
+ });
258
+ },
259
+ };
260
+ const tools = buildDreamerL2Tools(toolContext);
261
+ const agentContext = {
262
+ systemPrompt: '',
263
+ messages: prompts,
264
+ tools,
265
+ };
266
+ const loopConfig = {
267
+ model: resolveL2Model(this.config.provider, this.config.model, this.config.baseUrl),
268
+ apiKey,
269
+ convertToLlm: (msgs) => msgs.map((m) => {
270
+ if (m.role === 'user' || m.role === 'assistant' || m.role === 'toolResult') {
271
+ return m;
272
+ }
273
+ throw new PDRuntimeError('output_invalid', `L2 convertToLlm encountered an unsupported message role: ${String(m.role)}`);
274
+ }),
275
+ beforeToolCall: async (ctx) => {
276
+ if (!DREAMER_L2_TOOL_WHITELIST.has(ctx.toolCall.name)) {
277
+ return { block: true, reason: `tool '${ctx.toolCall.name}' is not in the dreamer L2 whitelist` };
278
+ }
279
+ return undefined;
280
+ },
281
+ shouldStopAfterTurn: () => {
282
+ turnCount += 1;
283
+ return outputCapture.output !== null || turnCount >= maxTurns;
284
+ },
285
+ };
286
+ let transcript;
287
+ try {
288
+ transcript = await runAgentLoop(prompts, agentContext, loopConfig, async (event) => { void event; }, abortController.signal);
289
+ }
290
+ catch (err) {
291
+ const reason = err instanceof Error ? err.message : String(err);
292
+ return { status: 'error', reason, timedOut: abortController.signal.aborted };
293
+ }
294
+ totalTurnCount += turnCount;
295
+ // Extract output: primary = submit_output capture; secondary = last text-bearing assistant message.
296
+ if (outputCapture.output !== null) {
297
+ return { status: 'ok', output: outputCapture.output, usedTextFallback: false };
298
+ }
299
+ const fallbackText = extractLastAssistantText(transcript);
300
+ const extracted = fallbackText ? extractJsonObject(fallbackText) : null;
301
+ if (extracted) {
302
+ return { status: 'ok', output: extracted, usedTextFallback: true };
303
+ }
304
+ return { status: 'empty' };
305
+ };
306
+ emitLoopStarted();
307
+ // PRI-420: retry loop — attempt the agent loop up to 1 + maxEmptyRetries times.
308
+ // Each retry uses fresh state (EP-05). Empty responses (no submit_output, no parseable
309
+ // text) trigger a retry; the model API returns content=[] ~57% of the time on long prompts.
310
+ let l2Result = null;
311
+ let lastError = null;
312
+ const maxAttempts = 1 + maxEmptyRetries;
313
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
314
+ if (attempt > 0) {
315
+ totalRetryCount += 1;
316
+ this.eventEmitter.emitTelemetry({
317
+ eventType: 'dreamer_l2_turn',
318
+ traceId: taskId,
319
+ timestamp: new Date().toISOString(),
320
+ sessionId: 'l2-adapter',
321
+ agentId: 'dreamer-l2',
322
+ payload: { runId, phase: 'empty_response_retry', attempt },
323
+ });
324
+ }
325
+ l2Result = await runSingleAttempt();
326
+ if (l2Result.status === 'ok') {
327
+ break; // Success — output extracted.
328
+ }
329
+ if (l2Result.status === 'error') {
330
+ // Loop threw (timeout or execution error). Stop retrying — retrying a timeout wastes budget.
331
+ lastError = { reason: l2Result.reason, timedOut: l2Result.timedOut };
332
+ break;
333
+ }
334
+ // status === 'empty' → retry if attempts remain (loop continues).
335
+ }
336
+ clearTimeout(budgetTimer);
337
+ this.abortControllers.delete(runId);
338
+ // Handle the L2 result.
339
+ if (l2Result?.status === 'ok') {
340
+ // L2 succeeded (possibly after retries).
341
+ runState.status = 'succeeded';
342
+ runState.endedAt = new Date().toISOString();
343
+ runState.output = { runId, payload: l2Result.output };
344
+ this.emitComplete({ taskId, runId, turnCount: totalTurnCount, toolsInvoked, usedFallback: l2Result.usedTextFallback, timedOut: false, retryCount: totalRetryCount });
345
+ return { runId, runtimeKind: 'pi-ai-l2', startedAt };
346
+ }
347
+ // L2 failed (empty response on all attempts, or a throw). Try L1 fallback if enabled.
348
+ const failureReason = lastError ? lastError.reason : 'L2 loop produced empty response on all attempts (no submit_output, no parseable JSON)';
349
+ const failureTimedOut = lastError ? lastError.timedOut : false;
350
+ if (l2FallbackToL1) {
351
+ this.eventEmitter.emitTelemetry({
352
+ eventType: 'dreamer_l2_fallback_to_l1',
353
+ traceId: taskId,
354
+ timestamp: new Date().toISOString(),
355
+ sessionId: 'l2-adapter',
356
+ agentId: 'dreamer-l2',
357
+ payload: { runId, reason: failureReason, retryCount: totalRetryCount, timedOut: failureTimedOut },
358
+ });
359
+ // L1 one-shot fallback: same prompt, single completeSimple call, JSON extraction.
360
+ try {
361
+ const l1Output = await this.runL1Fallback(messageContent, apiKey);
362
+ runState.status = 'succeeded';
363
+ runState.endedAt = new Date().toISOString();
364
+ runState.output = { runId, payload: l1Output };
365
+ this.emitComplete({ taskId, runId, turnCount: totalTurnCount, toolsInvoked, usedFallback: true, timedOut: false, retryCount: totalRetryCount });
366
+ return { runId, runtimeKind: 'pi-ai-l2', startedAt };
367
+ }
368
+ catch (l1Err) {
369
+ // Both L2 and L1 failed — fail loud with both reasons (R9: observable degradation).
370
+ const l1Reason = l1Err instanceof Error ? l1Err.message : String(l1Err);
371
+ runState.status = 'failed';
372
+ runState.reason = `L2 failed (${failureReason}); L1 fallback also failed (${l1Reason})`;
373
+ runState.endedAt = new Date().toISOString();
374
+ this.emitComplete({ taskId, runId, turnCount: totalTurnCount, toolsInvoked, usedFallback: false, timedOut: failureTimedOut, retryCount: totalRetryCount });
375
+ throw new PDRuntimeError('execution_failed', `L2 dreamer failed and L1 fallback also failed. L2: ${failureReason}. L1: ${l1Reason}`, { nextAction: 'check model availability and API key; review telemetry for retry/fallback details' });
376
+ }
377
+ }
378
+ // No fallback — fail loud (R9).
379
+ runState.status = failureTimedOut ? 'timed_out' : 'failed';
380
+ runState.reason = failureReason;
381
+ runState.endedAt = new Date().toISOString();
382
+ this.emitComplete({ taskId, runId, turnCount: totalTurnCount, toolsInvoked, usedFallback: false, timedOut: failureTimedOut, retryCount: totalRetryCount });
383
+ throw new PDRuntimeError(failureTimedOut ? 'timeout' : 'output_invalid', `L2 dreamer failed after ${totalRetryCount} retries: ${failureReason}`, { nextAction: failureTimedOut ? 'increase totalBudgetMs or use a faster model' : 'check model tool-use support or enable l2FallbackToL1' });
384
+ }
385
+ /**
386
+ * PRI-420: L1 one-shot fallback. Runs a single completeSimple call with the same prompt
387
+ * (without tool instructions) and extracts JSON from the response. This is the safety net
388
+ * when all L2 attempts fail — it ensures the dreamer still produces output.
389
+ */
390
+ async runL1Fallback(messageContent, apiKey) {
391
+ const model = resolveL2Model(this.config.provider, this.config.model, this.config.baseUrl);
392
+ const userMessage = { role: 'user', content: messageContent, timestamp: Date.now() };
393
+ const context = { messages: [userMessage] };
394
+ const response = await completeSimple(model, context, { apiKey, signal: AbortSignal.timeout(120_000) });
395
+ // Extract the text content from the response and parse JSON.
396
+ let text = null;
397
+ if (typeof response.content === 'string') {
398
+ text = response.content;
399
+ }
400
+ else if (Array.isArray(response.content)) {
401
+ const textPart = response.content.find((c) => typeof c === 'object' && c !== null && Object.hasOwn(c, 'type') && Reflect.get(c, 'type') === 'text');
402
+ text = textPart?.text ?? null;
403
+ }
404
+ if (!text) {
405
+ throw new Error('L1 fallback response had no text content');
406
+ }
407
+ const extracted = extractJsonObject(text);
408
+ if (!extracted) {
409
+ throw new Error('L1 fallback response had no parseable JSON');
410
+ }
411
+ return extracted;
412
+ }
413
+ async pollRun(runId) {
414
+ const state = this.runs.get(runId);
415
+ if (!state) {
416
+ return { runId, status: 'failed', reason: 'unknown runId' };
417
+ }
418
+ // L2RunState.status values ('succeeded'|'failed'|'timed_out') are already valid RunExecutionStatus.
419
+ return {
420
+ runId,
421
+ status: state.status,
422
+ startedAt: state.startedAt,
423
+ endedAt: state.endedAt,
424
+ reason: state.reason,
425
+ };
426
+ }
427
+ async cancelRun(runId) {
428
+ const controller = this.abortControllers.get(runId);
429
+ if (controller) {
430
+ controller.abort();
431
+ }
432
+ }
433
+ async fetchOutput(runId) {
434
+ const state = this.runs.get(runId);
435
+ return state?.output ?? null;
436
+ }
437
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this -- required by PDRuntimeAdapter interface
438
+ async fetchArtifacts(_runId) {
439
+ // L2 produces no separate runtime artifacts; output is in fetchOutput.
440
+ return [];
441
+ }
442
+ /**
443
+ * Bound the runs Map to MAX_RETAINED_RUNS to prevent unbounded memory growth in
444
+ * long-running services (the auto-consumer wakes every 120s). Evicts the oldest
445
+ * entries by insertion order (Map preserves it). Called at the start of each run.
446
+ */
447
+ evictOldRuns() {
448
+ if (this.runs.size <= MAX_RETAINED_RUNS)
449
+ return;
450
+ const excess = this.runs.size - MAX_RETAINED_RUNS;
451
+ let evicted = 0;
452
+ for (const runId of this.runs.keys()) {
453
+ if (evicted >= excess)
454
+ break;
455
+ this.runs.delete(runId);
456
+ evicted++;
457
+ }
458
+ }
459
+ emitComplete(opts) {
460
+ this.eventEmitter.emitTelemetry({
461
+ eventType: 'dreamer_l2_complete',
462
+ traceId: opts.taskId,
463
+ timestamp: new Date().toISOString(),
464
+ sessionId: 'l2-adapter',
465
+ agentId: 'dreamer-l2',
466
+ payload: {
467
+ runId: opts.runId,
468
+ turnCount: opts.turnCount,
469
+ toolsInvoked: opts.toolsInvoked,
470
+ usedFallback: opts.usedFallback,
471
+ timedOut: opts.timedOut,
472
+ retryCount: opts.retryCount,
473
+ outputPreview: safeStringifyPreview(this.runs.get(opts.runId)?.output?.payload, 300),
474
+ },
475
+ });
476
+ }
477
+ }
478
+ //# sourceMappingURL=l2-agent-loop-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"l2-agent-loop-adapter.js","sourceRoot":"","sources":["../../../src/runtime-v2/adapter/l2-agent-loop-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG/E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAYnE,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAK1B,MAAM,iCAAiC,CAAC;AAkCzC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB,EAAE,OAAe,EAAE,OAAgB;IAChF,MAAM,cAAc,GAAG,YAAY,EAAE,CAAC;IACtC,IAAI,cAAc,CAAC,QAAQ,CAAC,QAAyB,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACnE,0GAA0G;QAC1G,OAAO,QAAQ,CAAC,QAAyB,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,cAAc,CACtB,qBAAqB,EACrB,aAAa,QAAQ,mEAAmE,CACzF,CAA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rategy?: OutputPathStrategy;
39
39
  /** Maximum repair attempts for structured output repair loop (PRI-271 A1). Default: 3. */
40
40
  maxRepairAttempts?: number;
41
+ /**
42
+ * Maximum completion tokens for LLM response (BUG-007a).
43
+ * Prevents reasoning models from spending entire budget on thinking tokens.
44
+ * Default: 4096. Set to 0 or undefined to omit (use model default).
45
+ */
46
+ maxTokens?: number;
41
47
  /** Internal override for the retry delay backoff, primarily for fast unit testing. */
42
48
  _testBackoffDelayMs?: number;
43
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pi-ai-runtime-adapter.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/adapter/pi-ai-runtime-adapter.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAOnE,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAEhC,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAE1F,6DAA6D;AAC7D,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,kBAAkB,GAAG,uBAAuB,CAAC;AAEzF;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,0FAA0F;IAC1F,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mFAAmF;IACnF,Y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';
20
20
  import { extractJsonObject } from './json-extractor.js';
21
21
  import { DiagnosticianOutputV1Schema } from '../diagnostician-output.js';
22
+ import { DiagRootCauseOutputV1Schema } from '../diagnostician/diag-rootcause-output.js';
23
+ import { DiagDistillerOutputV1Schema } from '../diagnostician/diag-distiller-output.js';
22
24
  import { DreamerOutputV1Schema } from '../internalization/dreamer-output.js';
23
25
  import { PhilosopherOutputV1Schema } from '../internalization/philosopher-output.js';
24
26
  import { ScribeOutputV1Schema } from '../internalization/scribe-output.js';
25
- import { ArtificerOutputV1Schema } from '../internalization/artificer-output.js';
27
+ import { ArtificerRuleOutputSchema } from '../internalization/artificer-output.js';
26
28
  import { EvaluatorOutputV1Schema } from '../internalization/evaluator-output.js';
27
29
  import { RolloutReviewerOutputV1Schema } from '../internalization/rollout-reviewer-output.js';
28
30
  import { TrainerOutputV1Schema } from '../internalization/trainer-output.js';
@@ -169,7 +171,14 @@ function classifyFailure(err, signal) {
169
171
  * stopReason:'aborted' → timeout
170
172
  * stopReason:'error' + timeout/abort in errorMessage → timeout
171
173
  * stopReason:'error' + other → execution_failed
172
- * no text content block → output_invalid
174
+ * stopReason:'length' + no extractable content → output_invalid (truncated)
175
+ * no text or thinking content block → output_invalid
176
+ *
177
+ * Reasoning-model fallback (BUG-007a):
178
+ * When all content blocks have empty text (common with reasoning models that
179
+ * spend the entire token budget on thinking), extract JSON from ThinkingContent
180
+ * blocks. The thinking text is treated as untrusted (EP-01) and must go through
181
+ * the same extractJsonObject → schema validation path as normal text.
173
182
  */
174
183
  function extractAssistantTextOrThrow(response, signal) {
175
184
  // Handle resolved-error responses from pi-ai
@@ -187,17 +196,31 @@ function extractAssistantTextOrThrow(response, signal) {
187
196
  }
188
197
  // Find text content (may be mixed with thinking content from reasoning-enabled models)
189
198
  const textContent = response.content.find(c => c.type === 'text' && c.text && c.text.trim().length > 0);
190
- if (!textContent || textContent.type !== 'text' || !textContent.text) {
191
- throw new PDRuntimeError('output_invalid', `No text content in LLM response. Content types: ${response.content.map(c => c.type).join(', ')}`);
199
+ if (textContent && textContent.type === 'text' && textContent.text) {
200
+ return textContent.text;
201
+ }
202
+ // BUG-007a: Reasoning-model fallback — extract from ThinkingContent blocks
203
+ // When reasoning models spend all token budget on thinking, content is empty
204
+ // but thinking (reasoning_content) may contain the structured output.
205
+ // EP-01: thinking field is untrusted LLM output — validate type before use.
206
+ const thinkingBlock = response.content.find(c => c.type === 'thinking' && typeof c.thinking === 'string' && c.thinking.trim().length > 0);
207
+ if (thinkingBlock && thinkingBlock.type === 'thinking' && typeof thinkingBlock.thinking === 'string' && thinkingBlock.thinking.trim().length > 0) {
208
+ return thinkingBlock.thinking;
209
+ }
210
+ // BUG-007b: finish_reason=length with no extractable content → fail-loud (EP-03)
211
+ if (response.stopReason === 'length') {
212
+ throw new PDRuntimeError('output_invalid', 'LLM response truncated (finish_reason=length); no extractable content', { nextAction: 'reduce input size or increase maxTokens in .pd/config.yaml' });
192
213
  }
193
- return textContent.text;
214
+ throw new PDRuntimeError('output_invalid', `No text or reasoning content in LLM response. Content types: ${response.content.map(c => c.type).join(', ')}`, { nextAction: 'check if the model supports structured output or increase maxTokens' });
194
215
  }
195
216
  const OUTPUT_SCHEMA_REGISTRY = new Map([
196
217
  ['diagnostician-output-v1', DiagnosticianOutputV1Schema],
218
+ ['diag-rootcause-output-v1', DiagRootCauseOutputV1Schema],
219
+ ['diag-distiller-output-v1', DiagDistillerOutputV1Schema],
197
220
  ['dreamer-output-v1', DreamerOutputV1Schema],
198
221
  ['philosopher-output-v1', PhilosopherOutputV1Schema],
199
222
  ['scribe-output-v1', ScribeOutputV1Schema],
200
- ['artificer-output-v1', ArtificerOutputV1Schema],
223
+ ['artificer-rule-output-v2', ArtificerRuleOutputSchema],
201
224
  ['evaluator-output-v1', EvaluatorOutputV1Schema],
202
225
  ['rollout-reviewer-output-v1', RolloutReviewerOutputV1Schema],
203
226
  ['trainer-output-v1', TrainerOutputV1Schema],
@@ -688,7 +711,6 @@ export class PiAiRuntimeAdapter {
688
711
  * calling, the response contains ToolCall content blocks with pre-parsed
689
712
  * arguments that we validate against the schema.
690
713
  */
691
- // eslint-disable-next-line @typescript-eslint/class-methods-use-this -- stateless helper; kept as private method for cohesion
692
714
  async tryToolCallPath(params) {
693
715
  try {
694
716
  const toolContext = {
@@ -700,6 +722,7 @@ export class PiAiRuntimeAdapter {
700
722
  apiKey: params.apiKey,
701
723
  timeoutMs: params.effectiveTimeoutMs,
702
724
  maxRetries: 0,
725
+ maxTokens: this.config.maxTokens ?? 4096,
703
726
  onPayload: (payload) => {
704
727
  if (typeof payload === 'object' && payload !== null) {
705
728
  const p = payload;
@@ -747,7 +770,6 @@ export class PiAiRuntimeAdapter {
747
770
  * Injects `response_format: { type: 'json_object' }` via onPayload
748
771
  * to force the provider to output valid JSON. Then parses and validates.
749
772
  */
750
- // eslint-disable-next-line @typescript-eslint/class-methods-use-this -- stateless helper; kept as private method for cohesion
751
773
  async tryJsonModePath(params) {
752
774
  try {
753
775
  const completeOptions = {
@@ -755,6 +777,7 @@ export class PiAiRuntimeAdapter {
755
777
  apiKey: params.apiKey,
756
778
  timeoutMs: params.effectiveTimeoutMs,
757
779
  maxRetries: 0,
780
+ maxTokens: this.config.maxTokens ?? 4096,
758
781
  onPayload: (payload) => {
759
782
  if (typeof payload === 'object' && payload !== null) {
760
783
  const p = payload;
@@ -826,7 +849,6 @@ export class PiAiRuntimeAdapter {
826
849
  * call immediately timing out when the original call consumed most of the
827
850
  * original timeout budget (e.g., 5min original → 4m50s elapsed → 10s left).
828
851
  */
829
- // eslint-disable-next-line @typescript-eslint/class-methods-use-this -- REPAIR_TIMEOUT_MS is a constant; this method is intentionally stateless
830
852
  async repairLLMCall(model, prompt, options) {
831
853
  const REPAIR_TIMEOUT_MS = 60_000;
832
854
  const repairSignal = AbortSignal.timeout(REPAIR_TIMEOUT_MS);
@@ -841,6 +863,7 @@ export class PiAiRuntimeAdapter {
841
863
  apiKey: options.apiKey,
842
864
  timeoutMs: REPAIR_TIMEOUT_MS,
843
865
  maxRetries: 0,
866
+ maxTokens: this.config.maxTokens ?? 4096,
844
867
  });
845
868
  // extractAssistantTextOrThrow throws:
846
869
  // - output_invalid: no text content in response
@@ -897,6 +920,7 @@ export class PiAiRuntimeAdapter {
897
920
  apiKey: options.apiKey,
898
921
  timeoutMs: currentTimeoutMs,
899
922
  maxRetries: 0, // disable pi-ai built-in retry to avoid double-retry
923
+ maxTokens: this.config.maxTokens ?? 4096, // BUG-007a: prevent reasoning models from exhausting budget
900
924
  };
901
925
  if (this.config.reasoning !== undefined && this.config.reasoning !== false) {
902
926
  completeOptions.reasoning = this.config.reasoning;