@haaaiawd/second-nature 0.1.43 → 0.1.50

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 (958) hide show
  1. package/HEARTBEAT.md +44 -0
  2. package/LICENSE +176 -0
  3. package/README.md +136 -0
  4. package/README.zh-CN.md +120 -0
  5. package/SKILL.md +320 -22
  6. package/dist/data/observability.db +0 -0
  7. package/dist/data/state.db +0 -0
  8. package/dist/plugin/index.d.ts +31 -0
  9. package/dist/plugin/workspace-ops-bridge.d.ts +15 -0
  10. package/dist/scripts/build-plugin-package.d.ts +12 -0
  11. package/dist/scripts/build-plugin-package.js +220 -0
  12. package/dist/scripts/build-plugin-runtime.d.ts +10 -0
  13. package/dist/scripts/build-plugin-runtime.js +198 -0
  14. package/dist/scripts/packaging-feasibility-poc.js +127 -0
  15. package/dist/scripts/plugin-smoke-check.js +124 -0
  16. package/dist/src/cli/action-bridge.d.ts +11 -0
  17. package/dist/src/cli/index.d.ts +65 -0
  18. package/dist/src/cli/ops/heartbeat-surface.d.ts +84 -0
  19. package/dist/src/cli/ops/heartbeat-surface.js +100 -0
  20. package/dist/src/cli/ops/ops-router.js +1482 -0
  21. package/dist/src/cli/ops/workspace-heartbeat-runner.d.ts +85 -0
  22. package/dist/src/cli/ops/workspace-heartbeat-runner.js +242 -0
  23. package/dist/src/core/second-nature/heartbeat/goal-lifecycle-policy.d.ts +24 -0
  24. package/dist/src/core/second-nature/heartbeat/goal-lifecycle-policy.js +61 -0
  25. package/dist/src/core/second-nature/heartbeat/heartbeat-loop.d.ts +97 -0
  26. package/dist/src/core/second-nature/heartbeat/heartbeat-loop.js +397 -0
  27. package/dist/src/core/second-nature/orchestrator/platform-capability-router.js +149 -0
  28. package/dist/src/storage/snapshots/types.js +1 -0
  29. package/dist/src/storage/user-interest/types.js +1 -0
  30. package/dist/tests/integration/cli/cli-ops-surface.test.d.ts +1 -0
  31. package/dist/tests/integration/cli/cli-ops-surface.test.js +380 -0
  32. package/dist/tests/integration/cli/heartbeat-surface-workspace.test.d.ts +1 -0
  33. package/dist/tests/integration/cli/heartbeat-surface-workspace.test.js +61 -0
  34. package/dist/tests/integration/cli/host-capability-probe.test.d.ts +1 -0
  35. package/dist/tests/integration/cli/host-capability-probe.test.js +37 -0
  36. package/dist/tests/integration/cli/host-smoke-heartbeat-tool.test.d.ts +1 -0
  37. package/dist/tests/integration/cli/host-smoke-heartbeat-tool.test.js +34 -0
  38. package/dist/tests/integration/cli/plugin-packaging-walkthrough.test.d.ts +1 -0
  39. package/dist/tests/integration/cli/plugin-packaging-walkthrough.test.js +79 -0
  40. package/dist/tests/integration/cli/plugin-runtime-registration.test.d.ts +1 -0
  41. package/dist/tests/integration/cli/plugin-runtime-registration.test.js +285 -0
  42. package/dist/tests/integration/cli/plugin-workspace-ops-bridge.test.d.ts +1 -0
  43. package/dist/tests/integration/cli/plugin-workspace-ops-bridge.test.js +487 -0
  44. package/dist/tests/integration/cli/t1-2-1-explain-read-models.test.d.ts +1 -0
  45. package/dist/tests/integration/cli/t1-2-1-explain-read-models.test.js +58 -0
  46. package/dist/tests/integration/cli/t1-2-1-narrative-command.test.d.ts +1 -0
  47. package/dist/tests/integration/cli/t1-2-1-narrative-command.test.js +194 -0
  48. package/dist/tests/integration/cli/t1-2-2-dream-recent.test.d.ts +1 -0
  49. package/dist/tests/integration/cli/t1-2-2-dream-recent.test.js +100 -0
  50. package/dist/tests/integration/cli/t1-2-3-status-observability-writeback.test.d.ts +1 -0
  51. package/dist/tests/integration/cli/t1-2-3-status-observability-writeback.test.js +71 -0
  52. package/dist/tests/integration/cli/t1-2-4-quiet-report-read-canonical.test.d.ts +1 -0
  53. package/dist/tests/integration/cli/t1-2-4-quiet-report-read-canonical.test.js +206 -0
  54. package/dist/tests/integration/cli/t1-2-5-cycle-recent.test.d.ts +1 -0
  55. package/dist/tests/integration/cli/t1-2-5-cycle-recent.test.js +156 -0
  56. package/dist/tests/integration/cli/t1-2-5-status-delivery-posture-audit-store.test.d.ts +1 -0
  57. package/dist/tests/integration/cli/t1-2-5-status-delivery-posture-audit-store.test.js +95 -0
  58. package/dist/tests/integration/cli/t1-2-6-policy-show-non-shell.test.d.ts +1 -0
  59. package/dist/tests/integration/cli/t1-2-6-policy-show-non-shell.test.js +74 -0
  60. package/dist/tests/integration/cli/t1-2-6-status-aggregate.test.d.ts +1 -0
  61. package/dist/tests/integration/cli/t1-2-6-status-aggregate.test.js +223 -0
  62. package/dist/tests/integration/cli/t1-2-7-audit-command-minimal-closure.test.d.ts +1 -0
  63. package/dist/tests/integration/cli/t1-2-7-audit-command-minimal-closure.test.js +101 -0
  64. package/dist/tests/integration/cli/t1-2-8-capability-probe-ops-surface.test.d.ts +1 -0
  65. package/dist/tests/integration/cli/t1-2-8-capability-probe-ops-surface.test.js +74 -0
  66. package/dist/tests/integration/cli/t1-2-9-decision-denied-not-degraded.test.d.ts +1 -0
  67. package/dist/tests/integration/cli/t1-2-9-decision-denied-not-degraded.test.js +79 -0
  68. package/dist/tests/integration/cli/t1-4-1-runtime-secret-bootstrap.test.d.ts +1 -0
  69. package/dist/tests/integration/cli/t1-4-1-runtime-secret-bootstrap.test.js +139 -0
  70. package/dist/tests/integration/cli/t1-4-2-activation-ux-contract.test.d.ts +1 -0
  71. package/dist/tests/integration/cli/t1-4-2-activation-ux-contract.test.js +143 -0
  72. package/dist/tests/integration/cli/t2-2-2-snapshot-life-evidence.test.d.ts +1 -0
  73. package/dist/tests/integration/cli/t2-2-2-snapshot-life-evidence.test.js +116 -0
  74. package/dist/tests/integration/cli/t3-3-2-near-real-smoke-cli-bridge.test.d.ts +1 -0
  75. package/dist/tests/integration/cli/t3-3-2-near-real-smoke-cli-bridge.test.js +69 -0
  76. package/dist/tests/integration/connectors/connector-base.test.d.ts +1 -0
  77. package/dist/tests/integration/connectors/connector-base.test.js +211 -0
  78. package/dist/tests/integration/connectors/connector-executor-adapter-honest-failure.test.d.ts +1 -0
  79. package/dist/tests/integration/connectors/connector-executor-adapter-honest-failure.test.js +311 -0
  80. package/dist/tests/integration/connectors/credential-optional-regression.test.d.ts +1 -0
  81. package/dist/tests/integration/connectors/credential-optional-regression.test.js +117 -0
  82. package/dist/tests/integration/connectors/declarative-http-runner.test.d.ts +7 -0
  83. package/dist/tests/integration/connectors/declarative-http-runner.test.js +229 -0
  84. package/dist/tests/integration/connectors/evomap-secret-port.test.d.ts +1 -0
  85. package/dist/tests/integration/connectors/evomap-secret-port.test.js +83 -0
  86. package/dist/tests/integration/connectors/life-evidence-chain.test.d.ts +1 -0
  87. package/dist/tests/integration/connectors/life-evidence-chain.test.js +188 -0
  88. package/dist/tests/integration/connectors/moltbook-client.test.d.ts +1 -0
  89. package/dist/tests/integration/connectors/moltbook-client.test.js +274 -0
  90. package/dist/tests/integration/connectors/moltbook-mock-runner.test.d.ts +7 -0
  91. package/dist/tests/integration/connectors/moltbook-mock-runner.test.js +108 -0
  92. package/dist/tests/integration/connectors/near-real-connector-smoke.test.d.ts +1 -0
  93. package/dist/tests/integration/connectors/near-real-connector-smoke.test.js +38 -0
  94. package/dist/tests/integration/connectors/platform-adapters.test.d.ts +1 -0
  95. package/dist/tests/integration/connectors/platform-adapters.test.js +189 -0
  96. package/dist/tests/integration/connectors/policy-layer.test.d.ts +1 -0
  97. package/dist/tests/integration/connectors/policy-layer.test.js +249 -0
  98. package/dist/tests/integration/connectors/scriptable-node-e2e.test.d.ts +1 -0
  99. package/dist/tests/integration/connectors/scriptable-node-e2e.test.js +228 -0
  100. package/dist/tests/integration/connectors/t3-3-1-real-connector-evidence.test.d.ts +1 -0
  101. package/dist/tests/integration/connectors/t3-3-1-real-connector-evidence.test.js +171 -0
  102. package/dist/tests/integration/control-plane/_helpers/decision-cycle-harness.d.ts +40 -0
  103. package/dist/tests/integration/control-plane/_helpers/decision-cycle-harness.js +116 -0
  104. package/dist/tests/integration/control-plane/decision-loop-validation.test.d.ts +1 -0
  105. package/dist/tests/integration/control-plane/decision-loop-validation.test.js +319 -0
  106. package/dist/tests/integration/control-plane/delivery-failed-fallback.test.d.ts +1 -0
  107. package/dist/tests/integration/control-plane/delivery-failed-fallback.test.js +118 -0
  108. package/dist/tests/integration/control-plane/dream-projection-heartbeat.test.d.ts +1 -0
  109. package/dist/tests/integration/control-plane/dream-projection-heartbeat.test.js +109 -0
  110. package/dist/tests/integration/control-plane/effect-dispatcher.test.d.ts +1 -0
  111. package/dist/tests/integration/control-plane/effect-dispatcher.test.js +157 -0
  112. package/dist/tests/integration/control-plane/guidance-request.test.d.ts +1 -0
  113. package/dist/tests/integration/control-plane/guidance-request.test.js +63 -0
  114. package/dist/tests/integration/control-plane/heartbeat-executor.test.d.ts +1 -0
  115. package/dist/tests/integration/control-plane/heartbeat-executor.test.js +363 -0
  116. package/dist/tests/integration/control-plane/heartbeat-loop.test.d.ts +1 -0
  117. package/dist/tests/integration/control-plane/heartbeat-loop.test.js +190 -0
  118. package/dist/tests/integration/control-plane/heartbeat-quiet-orchestration.test.d.ts +1 -0
  119. package/dist/tests/integration/control-plane/heartbeat-quiet-orchestration.test.js +133 -0
  120. package/dist/tests/integration/control-plane/heartbeat-spine-integration.test.d.ts +1 -0
  121. package/dist/tests/integration/control-plane/heartbeat-spine-integration.test.js +342 -0
  122. package/dist/tests/integration/control-plane/heartbeat-spine.test.d.ts +1 -0
  123. package/dist/tests/integration/control-plane/heartbeat-spine.test.js +216 -0
  124. package/dist/tests/integration/control-plane/int-s3-outreach-delivery-quiet-closure.test.d.ts +1 -0
  125. package/dist/tests/integration/control-plane/int-s3-outreach-delivery-quiet-closure.test.js +241 -0
  126. package/dist/tests/integration/control-plane/outreach-resume.test.d.ts +1 -0
  127. package/dist/tests/integration/control-plane/outreach-resume.test.js +158 -0
  128. package/dist/tests/integration/control-plane/outreach-style.test.d.ts +1 -0
  129. package/dist/tests/integration/control-plane/outreach-style.test.js +46 -0
  130. package/dist/tests/integration/control-plane/quiet-reflection.test.d.ts +1 -0
  131. package/dist/tests/integration/control-plane/quiet-reflection.test.js +73 -0
  132. package/dist/tests/integration/control-plane/rhythm-intent-guard.test.d.ts +1 -0
  133. package/dist/tests/integration/control-plane/rhythm-intent-guard.test.js +99 -0
  134. package/dist/tests/integration/control-plane/run-heartbeat-cycle.test.d.ts +1 -0
  135. package/dist/tests/integration/control-plane/run-heartbeat-cycle.test.js +80 -0
  136. package/dist/tests/integration/control-plane/t2-3-1-outreach-v6.test.d.ts +1 -0
  137. package/dist/tests/integration/control-plane/t2-3-1-outreach-v6.test.js +208 -0
  138. package/dist/tests/integration/control-plane/t2-4-1-heartbeat-platform-intent.test.d.ts +1 -0
  139. package/dist/tests/integration/control-plane/t2-4-1-heartbeat-platform-intent.test.js +156 -0
  140. package/dist/tests/integration/control-plane/t2-4-2-source-backed-outreach-loop.test.d.ts +1 -0
  141. package/dist/tests/integration/control-plane/t2-4-2-source-backed-outreach-loop.test.js +188 -0
  142. package/dist/tests/integration/control-plane/v7c-evidence-body-feedback.test.d.ts +11 -0
  143. package/dist/tests/integration/control-plane/v7c-evidence-body-feedback.test.js +213 -0
  144. package/dist/tests/integration/control-plane/v7c-heartbeat-unlock-e2e.test.d.ts +9 -0
  145. package/dist/tests/integration/control-plane/v7c-heartbeat-unlock-e2e.test.js +134 -0
  146. package/dist/tests/integration/dream/quiet-dream-trigger.test.d.ts +1 -0
  147. package/dist/tests/integration/dream/quiet-dream-trigger.test.js +86 -0
  148. package/dist/tests/integration/dream/t7-1-1-dream-pipeline.test.d.ts +1 -0
  149. package/dist/tests/integration/dream/t7-1-1-dream-pipeline.test.js +378 -0
  150. package/dist/tests/integration/dream/t7-1-2-dream-scheduler.test.d.ts +1 -0
  151. package/dist/tests/integration/dream/t7-1-2-dream-scheduler.test.js +124 -0
  152. package/dist/tests/integration/dream/v7c-rhythm-loop.test.d.ts +10 -0
  153. package/dist/tests/integration/dream/v7c-rhythm-loop.test.js +185 -0
  154. package/dist/tests/integration/guidance/assembler-and-fallback.test.d.ts +1 -0
  155. package/dist/tests/integration/guidance/assembler-and-fallback.test.js +86 -0
  156. package/dist/tests/integration/guidance/outreach-draft-contract.test.d.ts +1 -0
  157. package/dist/tests/integration/guidance/outreach-draft-contract.test.js +106 -0
  158. package/dist/tests/integration/guidance/persona-selection.test.d.ts +1 -0
  159. package/dist/tests/integration/guidance/persona-selection.test.js +70 -0
  160. package/dist/tests/integration/guidance/template-review.test.d.ts +1 -0
  161. package/dist/tests/integration/guidance/template-review.test.js +26 -0
  162. package/dist/tests/integration/guidance/user-reply-continuity.test.d.ts +1 -0
  163. package/dist/tests/integration/guidance/user-reply-continuity.test.js +96 -0
  164. package/dist/tests/integration/guidance/v7c-guidance-chain.test.d.ts +1 -0
  165. package/dist/tests/integration/guidance/v7c-guidance-chain.test.js +190 -0
  166. package/dist/tests/integration/guidance/v7c-guidance-semantics.test.d.ts +1 -0
  167. package/dist/tests/integration/guidance/v7c-guidance-semantics.test.js +146 -0
  168. package/dist/tests/integration/observability/digest-delivery.test.d.ts +14 -0
  169. package/dist/tests/integration/observability/digest-delivery.test.js +160 -0
  170. package/dist/tests/integration/observability/evidence-query-engine.test.d.ts +1 -0
  171. package/dist/tests/integration/observability/evidence-query-engine.test.js +219 -0
  172. package/dist/tests/integration/observability/explain-query-export.test.d.ts +1 -0
  173. package/dist/tests/integration/observability/explain-query-export.test.js +92 -0
  174. package/dist/tests/integration/observability/guidance-audit.test.d.ts +1 -0
  175. package/dist/tests/integration/observability/guidance-audit.test.js +55 -0
  176. package/dist/tests/integration/observability/heartbeat-decision-record.test.d.ts +1 -0
  177. package/dist/tests/integration/observability/heartbeat-decision-record.test.js +223 -0
  178. package/dist/tests/integration/observability/heartbeat-narrative-trace.test.d.ts +1 -0
  179. package/dist/tests/integration/observability/heartbeat-narrative-trace.test.js +230 -0
  180. package/dist/tests/integration/observability/lived-experience-audit-chain.test.d.ts +1 -0
  181. package/dist/tests/integration/observability/lived-experience-audit-chain.test.js +43 -0
  182. package/dist/tests/integration/observability/observability-gates.test.d.ts +1 -0
  183. package/dist/tests/integration/observability/observability-gates.test.js +224 -0
  184. package/dist/tests/integration/observability/observability-retention-cleanup.test.d.ts +1 -0
  185. package/dist/tests/integration/observability/observability-retention-cleanup.test.js +94 -0
  186. package/dist/tests/integration/observability/observability-services.test.d.ts +1 -0
  187. package/dist/tests/integration/observability/observability-services.test.js +219 -0
  188. package/dist/tests/integration/observability/projections.test.d.ts +1 -0
  189. package/dist/tests/integration/observability/projections.test.js +36 -0
  190. package/dist/tests/integration/observability/t5-1-1-dream-trace-audit.test.d.ts +1 -0
  191. package/dist/tests/integration/observability/t5-1-1-dream-trace-audit.test.js +115 -0
  192. package/dist/tests/integration/plugin/plugin-registration.test.d.ts +16 -0
  193. package/dist/tests/integration/plugin/plugin-registration.test.js +151 -0
  194. package/dist/tests/integration/runtime-ops/commands.test.d.ts +16 -0
  195. package/dist/tests/integration/runtime-ops/commands.test.js +662 -0
  196. package/dist/tests/integration/s3-exit/int-s3-body-heartbeat.test.d.ts +15 -0
  197. package/dist/tests/integration/s3-exit/int-s3-body-heartbeat.test.js +462 -0
  198. package/dist/tests/integration/s5-exit/int-s5-observability.test.d.ts +17 -0
  199. package/dist/tests/integration/s5-exit/int-s5-observability.test.js +402 -0
  200. package/dist/tests/integration/state/t4-2-1-owner-reply-relationship-loop.test.d.ts +1 -0
  201. package/dist/tests/integration/state/t4-2-1-owner-reply-relationship-loop.test.js +132 -0
  202. package/dist/tests/integration/state/v7c-identity-goal-hygiene.test.d.ts +9 -0
  203. package/dist/tests/integration/state/v7c-identity-goal-hygiene.test.js +240 -0
  204. package/dist/tests/integration/storage/packaged-runtime-smoke.test.d.ts +1 -0
  205. package/dist/tests/integration/storage/packaged-runtime-smoke.test.js +17 -0
  206. package/dist/tests/integration/storage/persona-candidate-loader.test.d.ts +1 -0
  207. package/dist/tests/integration/storage/persona-candidate-loader.test.js +23 -0
  208. package/dist/tests/integration/storage/quiet-artifact-writer.test.d.ts +1 -0
  209. package/dist/tests/integration/storage/quiet-artifact-writer.test.js +66 -0
  210. package/dist/tests/integration/storage/repair-and-backup.test.d.ts +1 -0
  211. package/dist/tests/integration/storage/repair-and-backup.test.js +125 -0
  212. package/dist/tests/integration/storage/schema-migration.test.d.ts +11 -0
  213. package/dist/tests/integration/storage/schema-migration.test.js +183 -0
  214. package/dist/tests/integration/storage/storage-mode-smoke.test.d.ts +1 -0
  215. package/dist/tests/integration/storage/storage-mode-smoke.test.js +18 -0
  216. package/dist/tests/integration/storage/t4-1-5-memory-store-lifecycle.test.d.ts +1 -0
  217. package/dist/tests/integration/storage/t4-1-5-memory-store-lifecycle.test.js +118 -0
  218. package/dist/tests/unit/body/affordance-assembler.test.d.ts +14 -0
  219. package/dist/tests/unit/body/affordance-assembler.test.js +259 -0
  220. package/dist/tests/unit/body/affordance-context-scope.test.d.ts +12 -0
  221. package/dist/tests/unit/body/affordance-context-scope.test.js +73 -0
  222. package/dist/tests/unit/body/behavior-promotion-loop.test.d.ts +15 -0
  223. package/dist/tests/unit/body/behavior-promotion-loop.test.js +130 -0
  224. package/dist/tests/unit/body/circuit-breaker-manager.test.d.ts +13 -0
  225. package/dist/tests/unit/body/circuit-breaker-manager.test.js +160 -0
  226. package/dist/tests/unit/body/experience-writer.test.d.ts +11 -0
  227. package/dist/tests/unit/body/experience-writer.test.js +77 -0
  228. package/dist/tests/unit/body/pain-signal-query.test.d.ts +11 -0
  229. package/dist/tests/unit/body/pain-signal-query.test.js +104 -0
  230. package/dist/tests/unit/cli/connector-init-manifest.test.d.ts +9 -0
  231. package/dist/tests/unit/cli/connector-init-manifest.test.js +68 -0
  232. package/dist/tests/unit/cli/delivery-target-probe.test.d.ts +1 -0
  233. package/dist/tests/unit/cli/delivery-target-probe.test.js +108 -0
  234. package/dist/tests/unit/cli/host-capability.test.d.ts +1 -0
  235. package/dist/tests/unit/cli/host-capability.test.js +50 -0
  236. package/dist/tests/unit/cli/operator-fallback-view.test.d.ts +1 -0
  237. package/dist/tests/unit/cli/operator-fallback-view.test.js +60 -0
  238. package/dist/tests/unit/cli/runtime-artifact-boundary.test.d.ts +1 -0
  239. package/dist/tests/unit/cli/runtime-artifact-boundary.test.js +57 -0
  240. package/dist/tests/unit/cli/t1-2-3-connector-status.test.d.ts +1 -0
  241. package/dist/tests/unit/cli/t1-2-3-connector-status.test.js +214 -0
  242. package/dist/tests/unit/cli/t1-2-4-goal-command.test.d.ts +1 -0
  243. package/dist/tests/unit/cli/t1-2-4-goal-command.test.js +207 -0
  244. package/dist/tests/unit/cli/t1-3-1-connector-init.test.d.ts +1 -0
  245. package/dist/tests/unit/cli/t1-3-1-connector-init.test.js +212 -0
  246. package/dist/tests/unit/connectors/connector-manifest-and-evidence-map.test.d.ts +1 -0
  247. package/dist/tests/unit/connectors/connector-manifest-and-evidence-map.test.js +71 -0
  248. package/dist/tests/unit/connectors/effect-commit-ledger-sqlite.test.d.ts +10 -0
  249. package/dist/tests/unit/connectors/effect-commit-ledger-sqlite.test.js +101 -0
  250. package/dist/tests/unit/connectors/evomap-runner.test.d.ts +1 -0
  251. package/dist/tests/unit/connectors/evomap-runner.test.js +136 -0
  252. package/dist/tests/unit/connectors/execution-policy.test.d.ts +1 -0
  253. package/dist/tests/unit/connectors/execution-policy.test.js +71 -0
  254. package/dist/tests/unit/connectors/instreet-registration.test.d.ts +1 -0
  255. package/dist/tests/unit/connectors/instreet-registration.test.js +102 -0
  256. package/dist/tests/unit/connectors/manifest-v7-schema.test.d.ts +9 -0
  257. package/dist/tests/unit/connectors/manifest-v7-schema.test.js +165 -0
  258. package/dist/tests/unit/connectors/scriptable-node-runner.test.d.ts +1 -0
  259. package/dist/tests/unit/connectors/scriptable-node-runner.test.js +246 -0
  260. package/dist/tests/unit/connectors/structured-unavailable-reason.test.d.ts +11 -0
  261. package/dist/tests/unit/connectors/structured-unavailable-reason.test.js +76 -0
  262. package/dist/tests/unit/connectors/t3-1-1-dynamic-registry.test.d.ts +1 -0
  263. package/dist/tests/unit/connectors/t3-1-1-dynamic-registry.test.js +178 -0
  264. package/dist/tests/unit/connectors/t3-1-2-capability-registry.test.d.ts +1 -0
  265. package/dist/tests/unit/connectors/t3-1-2-capability-registry.test.js +105 -0
  266. package/dist/tests/unit/connectors/t3-2-1-v5-parity.test.d.ts +1 -0
  267. package/dist/tests/unit/connectors/t3-2-1-v5-parity.test.js +103 -0
  268. package/dist/tests/unit/connectors/t3-3-1-evidence-mapper.test.d.ts +1 -0
  269. package/dist/tests/unit/connectors/t3-3-1-evidence-mapper.test.js +198 -0
  270. package/dist/tests/unit/connectors/t3-3-1-evidence-redaction.test.d.ts +1 -0
  271. package/dist/tests/unit/connectors/t3-3-1-evidence-redaction.test.js +95 -0
  272. package/dist/tests/unit/connectors/wet-probe-runner.test.d.ts +11 -0
  273. package/dist/tests/unit/connectors/wet-probe-runner.test.js +84 -0
  274. package/dist/tests/unit/control-plane/decision-trace-emitter.test.d.ts +1 -0
  275. package/dist/tests/unit/control-plane/decision-trace-emitter.test.js +51 -0
  276. package/dist/tests/unit/control-plane/downstream-intent-orchestrator.test.d.ts +1 -0
  277. package/dist/tests/unit/control-plane/downstream-intent-orchestrator.test.js +57 -0
  278. package/dist/tests/unit/control-plane/embodied-context-assembler.test.d.ts +13 -0
  279. package/dist/tests/unit/control-plane/embodied-context-assembler.test.js +182 -0
  280. package/dist/tests/unit/control-plane/goal-lifecycle-policy.test.d.ts +1 -0
  281. package/dist/tests/unit/control-plane/goal-lifecycle-policy.test.js +75 -0
  282. package/dist/tests/unit/control-plane/hard-guard-evaluator.test.d.ts +1 -0
  283. package/dist/tests/unit/control-plane/hard-guard-evaluator.test.js +113 -0
  284. package/dist/tests/unit/control-plane/idle-curiosity-policy.test.d.ts +1 -0
  285. package/dist/tests/unit/control-plane/idle-curiosity-policy.test.js +69 -0
  286. package/dist/tests/unit/control-plane/intent-planner-source-ref-fallback.test.d.ts +7 -0
  287. package/dist/tests/unit/control-plane/intent-planner-source-ref-fallback.test.js +124 -0
  288. package/dist/tests/unit/control-plane/rhythm-policy-snapshot-window.test.d.ts +1 -0
  289. package/dist/tests/unit/control-plane/rhythm-policy-snapshot-window.test.js +64 -0
  290. package/dist/tests/unit/control-plane/run-heartbeat-cycle-v7.test.d.ts +1 -0
  291. package/dist/tests/unit/control-plane/run-heartbeat-cycle-v7.test.js +165 -0
  292. package/dist/tests/unit/control-plane/t2-1-4-goal-priority.test.d.ts +1 -0
  293. package/dist/tests/unit/control-plane/t2-1-4-goal-priority.test.js +185 -0
  294. package/dist/tests/unit/control-plane/t2-1-5-narrative-update.test.d.ts +1 -0
  295. package/dist/tests/unit/control-plane/t2-1-5-narrative-update.test.js +313 -0
  296. package/dist/tests/unit/control-plane/t2-4-1-credential-route.test.d.ts +1 -0
  297. package/dist/tests/unit/control-plane/t2-4-1-credential-route.test.js +75 -0
  298. package/dist/tests/unit/control-plane/t2-4-1-platform-intent.test.d.ts +1 -0
  299. package/dist/tests/unit/control-plane/t2-4-1-platform-intent.test.js +168 -0
  300. package/dist/tests/unit/core/outreach-judgment.test.d.ts +1 -0
  301. package/dist/tests/unit/core/outreach-judgment.test.js +109 -0
  302. package/dist/tests/unit/core/resolve-allowed-intent.test.d.ts +1 -0
  303. package/dist/tests/unit/core/resolve-allowed-intent.test.js +69 -0
  304. package/dist/tests/unit/core/t2-2-3-connector-action-honest-result.test.d.ts +1 -0
  305. package/dist/tests/unit/core/t2-2-3-connector-action-honest-result.test.js +130 -0
  306. package/dist/tests/unit/core/t2-2-3-connector-dispatch-wired.test.d.ts +1 -0
  307. package/dist/tests/unit/core/t2-2-3-connector-dispatch-wired.test.js +99 -0
  308. package/dist/tests/unit/dream/dream-input-loader.test.d.ts +15 -0
  309. package/dist/tests/unit/dream/dream-input-loader.test.js +424 -0
  310. package/dist/tests/unit/dream/dream-scheduler.test.d.ts +1 -0
  311. package/dist/tests/unit/dream/dream-scheduler.test.js +57 -0
  312. package/dist/tests/unit/dream/t-dqs-c3-redacted-evidence.test.d.ts +11 -0
  313. package/dist/tests/unit/dream/t-dqs-c3-redacted-evidence.test.js +298 -0
  314. package/dist/tests/unit/dream/t7-1-3-insight-extraction.test.d.ts +1 -0
  315. package/dist/tests/unit/dream/t7-1-3-insight-extraction.test.js +79 -0
  316. package/dist/tests/unit/dream/t7-1-4-narrative-update.test.d.ts +1 -0
  317. package/dist/tests/unit/dream/t7-1-4-narrative-update.test.js +93 -0
  318. package/dist/tests/unit/dream/t7-1-5-relationship-update.test.d.ts +1 -0
  319. package/dist/tests/unit/dream/t7-1-5-relationship-update.test.js +116 -0
  320. package/dist/tests/unit/feedback/t4-2-1-owner-reply-inference.test.d.ts +1 -0
  321. package/dist/tests/unit/feedback/t4-2-1-owner-reply-inference.test.js +58 -0
  322. package/dist/tests/unit/guidance/capability-class.test.d.ts +1 -0
  323. package/dist/tests/unit/guidance/capability-class.test.js +96 -0
  324. package/dist/tests/unit/guidance/channel-feedback-ingestion.test.d.ts +1 -0
  325. package/dist/tests/unit/guidance/channel-feedback-ingestion.test.js +163 -0
  326. package/dist/tests/unit/guidance/evidence-guidance.test.d.ts +1 -0
  327. package/dist/tests/unit/guidance/evidence-guidance.test.js +40 -0
  328. package/dist/tests/unit/guidance/guidance-draft-service.test.d.ts +1 -0
  329. package/dist/tests/unit/guidance/guidance-draft-service.test.js +140 -0
  330. package/dist/tests/unit/guidance/impulse-assembler.test.d.ts +1 -0
  331. package/dist/tests/unit/guidance/impulse-assembler.test.js +169 -0
  332. package/dist/tests/unit/guidance/outreach-draft-schema.test.d.ts +1 -0
  333. package/dist/tests/unit/guidance/outreach-draft-schema.test.js +56 -0
  334. package/dist/tests/unit/guidance/outreach-strategy-selector.test.d.ts +1 -0
  335. package/dist/tests/unit/guidance/outreach-strategy-selector.test.js +208 -0
  336. package/dist/tests/unit/guidance/outreach-style-fixtures.test.d.ts +1 -0
  337. package/dist/tests/unit/guidance/outreach-style-fixtures.test.js +81 -0
  338. package/dist/tests/unit/guidance/t6-1-1-narrative-outreach.test.d.ts +1 -0
  339. package/dist/tests/unit/guidance/t6-1-1-narrative-outreach.test.js +256 -0
  340. package/dist/tests/unit/observability/audit-envelope.test.d.ts +1 -0
  341. package/dist/tests/unit/observability/audit-envelope.test.js +169 -0
  342. package/dist/tests/unit/observability/connector-inventory-ledger.test.d.ts +1 -0
  343. package/dist/tests/unit/observability/connector-inventory-ledger.test.js +128 -0
  344. package/dist/tests/unit/observability/family-registry.test.d.ts +12 -0
  345. package/dist/tests/unit/observability/family-registry.test.js +105 -0
  346. package/dist/tests/unit/observability/governance-plane-recorder.test.d.ts +1 -0
  347. package/dist/tests/unit/observability/governance-plane-recorder.test.js +72 -0
  348. package/dist/tests/unit/observability/heartbeat-digest-assembler.test.d.ts +1 -0
  349. package/dist/tests/unit/observability/heartbeat-digest-assembler.test.js +227 -0
  350. package/dist/tests/unit/observability/lived-experience-audit.test.d.ts +1 -0
  351. package/dist/tests/unit/observability/lived-experience-audit.test.js +105 -0
  352. package/dist/tests/unit/observability/narrative-timeline-query.test.d.ts +18 -0
  353. package/dist/tests/unit/observability/narrative-timeline-query.test.js +239 -0
  354. package/dist/tests/unit/observability/restore-audit-service.test.d.ts +16 -0
  355. package/dist/tests/unit/observability/restore-audit-service.test.js +186 -0
  356. package/dist/tests/unit/observability/runtime-decision-recorder.test.d.ts +1 -0
  357. package/dist/tests/unit/observability/runtime-decision-recorder.test.js +66 -0
  358. package/dist/tests/unit/observability/runtime-secret-anchor-view.test.d.ts +18 -0
  359. package/dist/tests/unit/observability/runtime-secret-anchor-view.test.js +209 -0
  360. package/dist/tests/unit/observability/self-health-snapshot.test.d.ts +1 -0
  361. package/dist/tests/unit/observability/self-health-snapshot.test.js +223 -0
  362. package/dist/tests/unit/observability/verify-audit-hash-chain.test.d.ts +1 -0
  363. package/dist/tests/unit/observability/verify-audit-hash-chain.test.js +93 -0
  364. package/dist/tests/unit/ops/manual-run-dispatcher.test.d.ts +13 -0
  365. package/dist/tests/unit/ops/manual-run-dispatcher.test.js +219 -0
  366. package/dist/tests/unit/quiet/claim-synthesizer.test.d.ts +17 -0
  367. package/dist/tests/unit/quiet/claim-synthesizer.test.js +289 -0
  368. package/dist/tests/unit/quiet/daily-diary-writer.test.d.ts +12 -0
  369. package/dist/tests/unit/quiet/daily-diary-writer.test.js +108 -0
  370. package/dist/tests/unit/shared/v7-entities.test.d.ts +13 -0
  371. package/dist/tests/unit/shared/v7-entities.test.js +306 -0
  372. package/dist/tests/unit/storage/delivery-attempt.test.d.ts +1 -0
  373. package/dist/tests/unit/storage/delivery-attempt.test.js +72 -0
  374. package/dist/tests/unit/storage/diary-dream-store.test.d.ts +12 -0
  375. package/dist/tests/unit/storage/diary-dream-store.test.js +118 -0
  376. package/dist/tests/unit/storage/embodied-context-state-port.test.d.ts +4 -0
  377. package/dist/tests/unit/storage/embodied-context-state-port.test.js +77 -0
  378. package/dist/tests/unit/storage/goal-lifecycle-store.test.d.ts +4 -0
  379. package/dist/tests/unit/storage/goal-lifecycle-store.test.js +143 -0
  380. package/dist/tests/unit/storage/history-digest-store.test.d.ts +10 -0
  381. package/dist/tests/unit/storage/history-digest-store.test.js +126 -0
  382. package/dist/tests/unit/storage/identity-profile-store.test.d.ts +4 -0
  383. package/dist/tests/unit/storage/identity-profile-store.test.js +48 -0
  384. package/dist/tests/unit/storage/life-evidence-snapshot.test.d.ts +1 -0
  385. package/dist/tests/unit/storage/life-evidence-snapshot.test.js +60 -0
  386. package/dist/tests/unit/storage/life-evidence.test.d.ts +1 -0
  387. package/dist/tests/unit/storage/life-evidence.test.js +54 -0
  388. package/dist/tests/unit/storage/migration-runner.test.d.ts +12 -0
  389. package/dist/tests/unit/storage/migration-runner.test.js +197 -0
  390. package/dist/tests/unit/storage/repair-gate.test.d.ts +1 -0
  391. package/dist/tests/unit/storage/repair-gate.test.js +41 -0
  392. package/dist/tests/unit/storage/restore-snapshot-store.test.d.ts +11 -0
  393. package/dist/tests/unit/storage/restore-snapshot-store.test.js +161 -0
  394. package/dist/tests/unit/storage/rhythm-policy-snapshot.test.d.ts +1 -0
  395. package/dist/tests/unit/storage/rhythm-policy-snapshot.test.js +31 -0
  396. package/dist/tests/unit/storage/runtime-secret-anchor-store.test.d.ts +10 -0
  397. package/dist/tests/unit/storage/runtime-secret-anchor-store.test.js +81 -0
  398. package/dist/tests/unit/storage/t1-4-1-credential-health-mapper.test.d.ts +1 -0
  399. package/dist/tests/unit/storage/t1-4-1-credential-health-mapper.test.js +83 -0
  400. package/dist/tests/unit/storage/t4-1-1-session-chronicle.test.d.ts +1 -0
  401. package/dist/tests/unit/storage/t4-1-1-session-chronicle.test.js +112 -0
  402. package/dist/tests/unit/storage/t4-1-2-narrative-state.test.d.ts +1 -0
  403. package/dist/tests/unit/storage/t4-1-2-narrative-state.test.js +80 -0
  404. package/dist/tests/unit/storage/t4-1-3-relationship-memory.test.d.ts +1 -0
  405. package/dist/tests/unit/storage/t4-1-3-relationship-memory.test.js +65 -0
  406. package/dist/tests/unit/storage/t4-1-4-agent-goal.test.d.ts +1 -0
  407. package/dist/tests/unit/storage/t4-1-4-agent-goal.test.js +166 -0
  408. package/dist/tests/unit/storage/tool-experience-store.test.d.ts +4 -0
  409. package/dist/tests/unit/storage/tool-experience-store.test.js +92 -0
  410. package/dist/tests/unit/storage/user-interest-snapshot.test.d.ts +1 -0
  411. package/dist/tests/unit/storage/user-interest-snapshot.test.js +48 -0
  412. package/dist/tests/unit/storage/write-queue.test.d.ts +12 -0
  413. package/dist/tests/unit/storage/write-queue.test.js +177 -0
  414. package/dist/tests/unit/storage/write-validation-gate.test.d.ts +9 -0
  415. package/dist/tests/unit/storage/write-validation-gate.test.js +153 -0
  416. package/docs/claw-second-nature-inner-guide.md +144 -0
  417. package/package.json +84 -55
  418. package/agent-inner-guide.md +0 -187
  419. package/openclaw.plugin.json +0 -29
  420. package/runtime/cli/ops/heartbeat-surface.d.ts +0 -75
  421. package/runtime/cli/ops/heartbeat-surface.js +0 -97
  422. package/runtime/cli/ops/ops-router.js +0 -1454
  423. package/runtime/cli/ops/workspace-heartbeat-runner.d.ts +0 -76
  424. package/runtime/cli/ops/workspace-heartbeat-runner.js +0 -236
  425. package/runtime/core/second-nature/heartbeat/goal-lifecycle-policy.d.ts +0 -37
  426. package/runtime/core/second-nature/heartbeat/goal-lifecycle-policy.js +0 -61
  427. package/runtime/core/second-nature/heartbeat/heartbeat-loop.d.ts +0 -88
  428. package/runtime/core/second-nature/heartbeat/heartbeat-loop.js +0 -329
  429. package/runtime/core/second-nature/orchestrator/platform-capability-router.js +0 -131
  430. /package/{index.js → dist/plugin/index.js} +0 -0
  431. /package/{workspace-ops-bridge.js → dist/plugin/workspace-ops-bridge.js} +0 -0
  432. /package/{runtime/cli/read-models/types.js → dist/scripts/packaging-feasibility-poc.d.ts} +0 -0
  433. /package/{runtime/core/second-nature/types.js → dist/scripts/plugin-smoke-check.d.ts} +0 -0
  434. /package/{runtime → dist/src}/cli/action-bridge.js +0 -0
  435. /package/{runtime → dist/src}/cli/commands/connector-behavior.d.ts +0 -0
  436. /package/{runtime → dist/src}/cli/commands/connector-behavior.js +0 -0
  437. /package/{runtime → dist/src}/cli/commands/connector-init.d.ts +0 -0
  438. /package/{runtime → dist/src}/cli/commands/connector-init.js +0 -0
  439. /package/{runtime → dist/src}/cli/commands/connector-status.d.ts +0 -0
  440. /package/{runtime → dist/src}/cli/commands/connector-status.js +0 -0
  441. /package/{runtime → dist/src}/cli/commands/credential.d.ts +0 -0
  442. /package/{runtime → dist/src}/cli/commands/credential.js +0 -0
  443. /package/{runtime → dist/src}/cli/commands/goal.d.ts +0 -0
  444. /package/{runtime → dist/src}/cli/commands/goal.js +0 -0
  445. /package/{runtime → dist/src}/cli/commands/index.d.ts +0 -0
  446. /package/{runtime → dist/src}/cli/commands/index.js +0 -0
  447. /package/{runtime → dist/src}/cli/commands/policy.d.ts +0 -0
  448. /package/{runtime → dist/src}/cli/commands/policy.js +0 -0
  449. /package/{runtime → dist/src}/cli/explain/explain-surface-subject.d.ts +0 -0
  450. /package/{runtime → dist/src}/cli/explain/explain-surface-subject.js +0 -0
  451. /package/{runtime → dist/src}/cli/explain/format-explanation.d.ts +0 -0
  452. /package/{runtime → dist/src}/cli/explain/format-explanation.js +0 -0
  453. /package/{runtime → dist/src}/cli/explain/resolve-subject.d.ts +0 -0
  454. /package/{runtime → dist/src}/cli/explain/resolve-subject.js +0 -0
  455. /package/{runtime → dist/src}/cli/host-capability/classify-delivery.d.ts +0 -0
  456. /package/{runtime → dist/src}/cli/host-capability/classify-delivery.js +0 -0
  457. /package/{runtime → dist/src}/cli/host-capability/probe-host-capability.d.ts +0 -0
  458. /package/{runtime → dist/src}/cli/host-capability/probe-host-capability.js +0 -0
  459. /package/{runtime → dist/src}/cli/host-capability/record-host-capability.d.ts +0 -0
  460. /package/{runtime → dist/src}/cli/host-capability/record-host-capability.js +0 -0
  461. /package/{runtime → dist/src}/cli/host-capability/types.d.ts +0 -0
  462. /package/{runtime → dist/src}/cli/host-capability/types.js +0 -0
  463. /package/{runtime → dist/src}/cli/host-smoke/run-host-smoke.d.ts +0 -0
  464. /package/{runtime → dist/src}/cli/host-smoke/run-host-smoke.js +0 -0
  465. /package/{runtime → dist/src}/cli/host-smoke/types.d.ts +0 -0
  466. /package/{runtime → dist/src}/cli/host-smoke/types.js +0 -0
  467. /package/{runtime → dist/src}/cli/index.js +0 -0
  468. /package/{runtime → dist/src}/cli/ops/manual-run-dispatcher.d.ts +0 -0
  469. /package/{runtime → dist/src}/cli/ops/manual-run-dispatcher.js +0 -0
  470. /package/{runtime → dist/src}/cli/ops/ops-router.d.ts +0 -0
  471. /package/{runtime → dist/src}/cli/ops/show-operator-fallback.d.ts +0 -0
  472. /package/{runtime → dist/src}/cli/ops/show-operator-fallback.js +0 -0
  473. /package/{runtime → dist/src}/cli/read-models/index.d.ts +0 -0
  474. /package/{runtime → dist/src}/cli/read-models/index.js +0 -0
  475. /package/{runtime → dist/src}/cli/read-models/operator-explain-map.d.ts +0 -0
  476. /package/{runtime → dist/src}/cli/read-models/operator-explain-map.js +0 -0
  477. /package/{runtime → dist/src}/cli/read-models/types.d.ts +0 -0
  478. /package/{runtime/guidance → dist/src/cli/read-models}/types.js +0 -0
  479. /package/{runtime → dist/src}/cli/runtime/runtime-artifact-boundary.d.ts +0 -0
  480. /package/{runtime → dist/src}/cli/runtime/runtime-artifact-boundary.js +0 -0
  481. /package/{runtime → dist/src}/connectors/agent-network/agent-world/adapter.d.ts +0 -0
  482. /package/{runtime → dist/src}/connectors/agent-network/agent-world/adapter.js +0 -0
  483. /package/{runtime → dist/src}/connectors/agent-network/agent-world/index.d.ts +0 -0
  484. /package/{runtime → dist/src}/connectors/agent-network/agent-world/index.js +0 -0
  485. /package/{runtime → dist/src}/connectors/agent-network/agent-world/manifest.d.ts +0 -0
  486. /package/{runtime → dist/src}/connectors/agent-network/agent-world/manifest.js +0 -0
  487. /package/{runtime → dist/src}/connectors/agent-network/evomap/adapter.d.ts +0 -0
  488. /package/{runtime → dist/src}/connectors/agent-network/evomap/adapter.js +0 -0
  489. /package/{runtime → dist/src}/connectors/agent-network/evomap/index.d.ts +0 -0
  490. /package/{runtime → dist/src}/connectors/agent-network/evomap/index.js +0 -0
  491. /package/{runtime → dist/src}/connectors/agent-network/evomap/manifest.d.ts +0 -0
  492. /package/{runtime → dist/src}/connectors/agent-network/evomap/manifest.js +0 -0
  493. /package/{runtime → dist/src}/connectors/base/channel-health.d.ts +0 -0
  494. /package/{runtime → dist/src}/connectors/base/channel-health.js +0 -0
  495. /package/{runtime → dist/src}/connectors/base/contract.d.ts +0 -0
  496. /package/{runtime → dist/src}/connectors/base/contract.js +0 -0
  497. /package/{runtime → dist/src}/connectors/base/effect-commit-ledger-sqlite.d.ts +0 -0
  498. /package/{runtime → dist/src}/connectors/base/effect-commit-ledger-sqlite.js +0 -0
  499. /package/{runtime → dist/src}/connectors/base/execution-policy.d.ts +0 -0
  500. /package/{runtime → dist/src}/connectors/base/execution-policy.js +0 -0
  501. /package/{runtime → dist/src}/connectors/base/failure-taxonomy.d.ts +0 -0
  502. /package/{runtime → dist/src}/connectors/base/failure-taxonomy.js +0 -0
  503. /package/{runtime → dist/src}/connectors/base/index.d.ts +0 -0
  504. /package/{runtime → dist/src}/connectors/base/index.js +0 -0
  505. /package/{runtime → dist/src}/connectors/base/manifest-v7.d.ts +0 -0
  506. /package/{runtime → dist/src}/connectors/base/manifest-v7.js +0 -0
  507. /package/{runtime → dist/src}/connectors/base/manifest.d.ts +0 -0
  508. /package/{runtime → dist/src}/connectors/base/manifest.js +0 -0
  509. /package/{runtime → dist/src}/connectors/base/map-life-evidence.d.ts +0 -0
  510. /package/{runtime → dist/src}/connectors/base/map-life-evidence.js +0 -0
  511. /package/{runtime → dist/src}/connectors/base/policy-layer.d.ts +0 -0
  512. /package/{runtime → dist/src}/connectors/base/policy-layer.js +0 -0
  513. /package/{runtime → dist/src}/connectors/base/route-planner.d.ts +0 -0
  514. /package/{runtime → dist/src}/connectors/base/route-planner.js +0 -0
  515. /package/{runtime → dist/src}/connectors/base/structured-unavailable-reason.d.ts +0 -0
  516. /package/{runtime → dist/src}/connectors/base/structured-unavailable-reason.js +0 -0
  517. /package/{runtime → dist/src}/connectors/base/wet-probe-runner.d.ts +0 -0
  518. /package/{runtime → dist/src}/connectors/base/wet-probe-runner.js +0 -0
  519. /package/{runtime → dist/src}/connectors/index.d.ts +0 -0
  520. /package/{runtime → dist/src}/connectors/index.js +0 -0
  521. /package/{runtime → dist/src}/connectors/manifest/manifest-parser.d.ts +0 -0
  522. /package/{runtime → dist/src}/connectors/manifest/manifest-parser.js +0 -0
  523. /package/{runtime → dist/src}/connectors/manifest/manifest-schema.d.ts +0 -0
  524. /package/{runtime → dist/src}/connectors/manifest/manifest-schema.js +0 -0
  525. /package/{runtime → dist/src}/connectors/near-real/near-real-connector-smoke.d.ts +0 -0
  526. /package/{runtime → dist/src}/connectors/near-real/near-real-connector-smoke.js +0 -0
  527. /package/{runtime → dist/src}/connectors/registry/dynamic-connector-registry.d.ts +0 -0
  528. /package/{runtime → dist/src}/connectors/registry/dynamic-connector-registry.js +0 -0
  529. /package/{runtime → dist/src}/connectors/registry/index.d.ts +0 -0
  530. /package/{runtime → dist/src}/connectors/registry/index.js +0 -0
  531. /package/{runtime → dist/src}/connectors/registry/manifest-scanner.d.ts +0 -0
  532. /package/{runtime → dist/src}/connectors/registry/manifest-scanner.js +0 -0
  533. /package/{runtime → dist/src}/connectors/registry/trust-policy.d.ts +0 -0
  534. /package/{runtime → dist/src}/connectors/registry/trust-policy.js +0 -0
  535. /package/{runtime → dist/src}/connectors/services/connector-executor-adapter.d.ts +0 -0
  536. /package/{runtime → dist/src}/connectors/services/connector-executor-adapter.js +0 -0
  537. /package/{runtime → dist/src}/connectors/services/credential-route-context.d.ts +0 -0
  538. /package/{runtime → dist/src}/connectors/services/credential-route-context.js +0 -0
  539. /package/{runtime → dist/src}/connectors/social-community/instreet/adapter.d.ts +0 -0
  540. /package/{runtime → dist/src}/connectors/social-community/instreet/adapter.js +0 -0
  541. /package/{runtime → dist/src}/connectors/social-community/instreet/index.d.ts +0 -0
  542. /package/{runtime → dist/src}/connectors/social-community/instreet/index.js +0 -0
  543. /package/{runtime → dist/src}/connectors/social-community/instreet/manifest.d.ts +0 -0
  544. /package/{runtime → dist/src}/connectors/social-community/instreet/manifest.js +0 -0
  545. /package/{runtime → dist/src}/connectors/social-community/moltbook/adapter.d.ts +0 -0
  546. /package/{runtime → dist/src}/connectors/social-community/moltbook/adapter.js +0 -0
  547. /package/{runtime → dist/src}/connectors/social-community/moltbook/api-client.d.ts +0 -0
  548. /package/{runtime → dist/src}/connectors/social-community/moltbook/api-client.js +0 -0
  549. /package/{runtime → dist/src}/connectors/social-community/moltbook/index.d.ts +0 -0
  550. /package/{runtime → dist/src}/connectors/social-community/moltbook/index.js +0 -0
  551. /package/{runtime → dist/src}/connectors/social-community/moltbook/manifest.d.ts +0 -0
  552. /package/{runtime → dist/src}/connectors/social-community/moltbook/manifest.js +0 -0
  553. /package/{runtime → dist/src}/core/second-nature/body/behavior-promotion/behavior-promotion-loop.d.ts +0 -0
  554. /package/{runtime → dist/src}/core/second-nature/body/behavior-promotion/behavior-promotion-loop.js +0 -0
  555. /package/{runtime → dist/src}/core/second-nature/body/circuit-breaker/circuit-breaker-manager.d.ts +0 -0
  556. /package/{runtime → dist/src}/core/second-nature/body/circuit-breaker/circuit-breaker-manager.js +0 -0
  557. /package/{runtime → dist/src}/core/second-nature/body/probe-signal-adapter.d.ts +0 -0
  558. /package/{runtime → dist/src}/core/second-nature/body/probe-signal-adapter.js +0 -0
  559. /package/{runtime → dist/src}/core/second-nature/body/tool-affordance/affordance-assembler.d.ts +0 -0
  560. /package/{runtime → dist/src}/core/second-nature/body/tool-affordance/affordance-assembler.js +0 -0
  561. /package/{runtime → dist/src}/core/second-nature/body/tool-affordance/affordance-context-scope.d.ts +0 -0
  562. /package/{runtime → dist/src}/core/second-nature/body/tool-affordance/affordance-context-scope.js +0 -0
  563. /package/{runtime → dist/src}/core/second-nature/body/tool-experience/experience-writer.d.ts +0 -0
  564. /package/{runtime → dist/src}/core/second-nature/body/tool-experience/experience-writer.js +0 -0
  565. /package/{runtime → dist/src}/core/second-nature/body/tool-experience/pain-signal-query.d.ts +0 -0
  566. /package/{runtime → dist/src}/core/second-nature/body/tool-experience/pain-signal-query.js +0 -0
  567. /package/{runtime → dist/src}/core/second-nature/feedback/owner-reply-feedback.d.ts +0 -0
  568. /package/{runtime → dist/src}/core/second-nature/feedback/owner-reply-feedback.js +0 -0
  569. /package/{runtime → dist/src}/core/second-nature/guidance/apply-guidance.d.ts +0 -0
  570. /package/{runtime → dist/src}/core/second-nature/guidance/apply-guidance.js +0 -0
  571. /package/{runtime → dist/src}/core/second-nature/guidance/request-guidance.d.ts +0 -0
  572. /package/{runtime → dist/src}/core/second-nature/guidance/request-guidance.js +0 -0
  573. /package/{runtime → dist/src}/core/second-nature/guidance/user-reply-continuity.d.ts +0 -0
  574. /package/{runtime → dist/src}/core/second-nature/guidance/user-reply-continuity.js +0 -0
  575. /package/{runtime → dist/src}/core/second-nature/heartbeat/decision-trace-emitter.d.ts +0 -0
  576. /package/{runtime → dist/src}/core/second-nature/heartbeat/decision-trace-emitter.js +0 -0
  577. /package/{runtime → dist/src}/core/second-nature/heartbeat/embodied-context-assembler.d.ts +0 -0
  578. /package/{runtime → dist/src}/core/second-nature/heartbeat/embodied-context-assembler.js +0 -0
  579. /package/{runtime → dist/src}/core/second-nature/heartbeat/heartbeat-executor.d.ts +0 -0
  580. /package/{runtime → dist/src}/core/second-nature/heartbeat/heartbeat-executor.js +0 -0
  581. /package/{runtime → dist/src}/core/second-nature/heartbeat/idle-curiosity-policy.d.ts +0 -0
  582. /package/{runtime → dist/src}/core/second-nature/heartbeat/idle-curiosity-policy.js +0 -0
  583. /package/{runtime → dist/src}/core/second-nature/heartbeat/index.d.ts +0 -0
  584. /package/{runtime → dist/src}/core/second-nature/heartbeat/index.js +0 -0
  585. /package/{runtime → dist/src}/core/second-nature/heartbeat/run-heartbeat-cycle-v7.d.ts +0 -0
  586. /package/{runtime → dist/src}/core/second-nature/heartbeat/run-heartbeat-cycle-v7.js +0 -0
  587. /package/{runtime → dist/src}/core/second-nature/heartbeat/run-heartbeat-cycle.d.ts +0 -0
  588. /package/{runtime → dist/src}/core/second-nature/heartbeat/run-heartbeat-cycle.js +0 -0
  589. /package/{runtime → dist/src}/core/second-nature/heartbeat/runtime-snapshot.d.ts +0 -0
  590. /package/{runtime → dist/src}/core/second-nature/heartbeat/runtime-snapshot.js +0 -0
  591. /package/{runtime → dist/src}/core/second-nature/heartbeat/scope-router.d.ts +0 -0
  592. /package/{runtime → dist/src}/core/second-nature/heartbeat/scope-router.js +0 -0
  593. /package/{runtime → dist/src}/core/second-nature/heartbeat/signal.d.ts +0 -0
  594. /package/{runtime → dist/src}/core/second-nature/heartbeat/signal.js +0 -0
  595. /package/{runtime → dist/src}/core/second-nature/heartbeat/snapshot-builder.d.ts +0 -0
  596. /package/{runtime → dist/src}/core/second-nature/heartbeat/snapshot-builder.js +0 -0
  597. /package/{runtime → dist/src}/core/second-nature/index.d.ts +0 -0
  598. /package/{runtime → dist/src}/core/second-nature/index.js +0 -0
  599. /package/{runtime → dist/src}/core/second-nature/orchestrator/downstream-intent-orchestrator.d.ts +0 -0
  600. /package/{runtime → dist/src}/core/second-nature/orchestrator/downstream-intent-orchestrator.js +0 -0
  601. /package/{runtime → dist/src}/core/second-nature/orchestrator/effect-dispatcher.d.ts +0 -0
  602. /package/{runtime → dist/src}/core/second-nature/orchestrator/effect-dispatcher.js +0 -0
  603. /package/{runtime → dist/src}/core/second-nature/orchestrator/goal-priority.d.ts +0 -0
  604. /package/{runtime → dist/src}/core/second-nature/orchestrator/goal-priority.js +0 -0
  605. /package/{runtime → dist/src}/core/second-nature/orchestrator/guard-layer.d.ts +0 -0
  606. /package/{runtime → dist/src}/core/second-nature/orchestrator/guard-layer.js +0 -0
  607. /package/{runtime → dist/src}/core/second-nature/orchestrator/hard-guard-evaluator.d.ts +0 -0
  608. /package/{runtime → dist/src}/core/second-nature/orchestrator/hard-guard-evaluator.js +0 -0
  609. /package/{runtime → dist/src}/core/second-nature/orchestrator/index.d.ts +0 -0
  610. /package/{runtime → dist/src}/core/second-nature/orchestrator/index.js +0 -0
  611. /package/{runtime → dist/src}/core/second-nature/orchestrator/intent-planner.d.ts +0 -0
  612. /package/{runtime → dist/src}/core/second-nature/orchestrator/intent-planner.js +0 -0
  613. /package/{runtime → dist/src}/core/second-nature/orchestrator/lease-manager.d.ts +0 -0
  614. /package/{runtime → dist/src}/core/second-nature/orchestrator/lease-manager.js +0 -0
  615. /package/{runtime → dist/src}/core/second-nature/orchestrator/narrative-update.d.ts +0 -0
  616. /package/{runtime → dist/src}/core/second-nature/orchestrator/narrative-update.js +0 -0
  617. /package/{runtime → dist/src}/core/second-nature/orchestrator/platform-capability-router.d.ts +0 -0
  618. /package/{runtime → dist/src}/core/second-nature/orchestrator/resume-from-checkpoint.d.ts +0 -0
  619. /package/{runtime → dist/src}/core/second-nature/orchestrator/resume-from-checkpoint.js +0 -0
  620. /package/{runtime → dist/src}/core/second-nature/outreach/build-message.d.ts +0 -0
  621. /package/{runtime → dist/src}/core/second-nature/outreach/build-message.js +0 -0
  622. /package/{runtime → dist/src}/core/second-nature/outreach/build-outreach-draft-request.d.ts +0 -0
  623. /package/{runtime → dist/src}/core/second-nature/outreach/build-outreach-draft-request.js +0 -0
  624. /package/{runtime → dist/src}/core/second-nature/outreach/delivery-target.d.ts +0 -0
  625. /package/{runtime → dist/src}/core/second-nature/outreach/delivery-target.js +0 -0
  626. /package/{runtime → dist/src}/core/second-nature/outreach/dispatch-user-outreach.d.ts +0 -0
  627. /package/{runtime → dist/src}/core/second-nature/outreach/dispatch-user-outreach.js +0 -0
  628. /package/{runtime → dist/src}/core/second-nature/outreach/evaluate-outreach.d.ts +0 -0
  629. /package/{runtime → dist/src}/core/second-nature/outreach/evaluate-outreach.js +0 -0
  630. /package/{runtime → dist/src}/core/second-nature/outreach/judge-input-from-snapshot.d.ts +0 -0
  631. /package/{runtime → dist/src}/core/second-nature/outreach/judge-input-from-snapshot.js +0 -0
  632. /package/{runtime → dist/src}/core/second-nature/outreach/judge-outreach.d.ts +0 -0
  633. /package/{runtime → dist/src}/core/second-nature/outreach/judge-outreach.js +0 -0
  634. /package/{runtime → dist/src}/core/second-nature/quiet/claim-synthesizer.d.ts +0 -0
  635. /package/{runtime → dist/src}/core/second-nature/quiet/claim-synthesizer.js +0 -0
  636. /package/{runtime → dist/src}/core/second-nature/quiet/daily-diary-writer.d.ts +0 -0
  637. /package/{runtime → dist/src}/core/second-nature/quiet/daily-diary-writer.js +0 -0
  638. /package/{runtime → dist/src}/core/second-nature/quiet/index.d.ts +0 -0
  639. /package/{runtime → dist/src}/core/second-nature/quiet/index.js +0 -0
  640. /package/{runtime → dist/src}/core/second-nature/quiet/quiet-pipeline.d.ts +0 -0
  641. /package/{runtime → dist/src}/core/second-nature/quiet/quiet-pipeline.js +0 -0
  642. /package/{runtime → dist/src}/core/second-nature/quiet/run-source-backed-quiet.d.ts +0 -0
  643. /package/{runtime → dist/src}/core/second-nature/quiet/run-source-backed-quiet.js +0 -0
  644. /package/{runtime → dist/src}/core/second-nature/reflection/run-narrative-reflection.d.ts +0 -0
  645. /package/{runtime → dist/src}/core/second-nature/reflection/run-narrative-reflection.js +0 -0
  646. /package/{runtime → dist/src}/core/second-nature/rhythm/planner-rhythm-window.d.ts +0 -0
  647. /package/{runtime → dist/src}/core/second-nature/rhythm/planner-rhythm-window.js +0 -0
  648. /package/{runtime → dist/src}/core/second-nature/rhythm/policy-bridge.d.ts +0 -0
  649. /package/{runtime → dist/src}/core/second-nature/rhythm/policy-bridge.js +0 -0
  650. /package/{runtime → dist/src}/core/second-nature/rhythm/rhythm-policy.d.ts +0 -0
  651. /package/{runtime → dist/src}/core/second-nature/rhythm/rhythm-policy.js +0 -0
  652. /package/{runtime → dist/src}/core/second-nature/rhythm/select-window.d.ts +0 -0
  653. /package/{runtime → dist/src}/core/second-nature/rhythm/select-window.js +0 -0
  654. /package/{runtime → dist/src}/core/second-nature/runtime/lifecycle-service.d.ts +0 -0
  655. /package/{runtime → dist/src}/core/second-nature/runtime/lifecycle-service.js +0 -0
  656. /package/{runtime → dist/src}/core/second-nature/runtime/service-entry.d.ts +0 -0
  657. /package/{runtime → dist/src}/core/second-nature/runtime/service-entry.js +0 -0
  658. /package/{runtime → dist/src}/core/second-nature/types.d.ts +0 -0
  659. /package/{runtime/storage/delivery → dist/src/core/second-nature}/types.js +0 -0
  660. /package/{runtime → dist/src}/dream/dream-engine.d.ts +0 -0
  661. /package/{runtime → dist/src}/dream/dream-engine.js +0 -0
  662. /package/{runtime → dist/src}/dream/dream-input-loader.d.ts +0 -0
  663. /package/{runtime → dist/src}/dream/dream-input-loader.js +0 -0
  664. /package/{runtime → dist/src}/dream/dream-scheduler.d.ts +0 -0
  665. /package/{runtime → dist/src}/dream/dream-scheduler.js +0 -0
  666. /package/{runtime → dist/src}/dream/index.d.ts +0 -0
  667. /package/{runtime → dist/src}/dream/index.js +0 -0
  668. /package/{runtime → dist/src}/dream/insight-extractor.d.ts +0 -0
  669. /package/{runtime → dist/src}/dream/insight-extractor.js +0 -0
  670. /package/{runtime → dist/src}/dream/memory-consolidator.d.ts +0 -0
  671. /package/{runtime → dist/src}/dream/memory-consolidator.js +0 -0
  672. /package/{runtime → dist/src}/dream/narrative-update-proposal.d.ts +0 -0
  673. /package/{runtime → dist/src}/dream/narrative-update-proposal.js +0 -0
  674. /package/{runtime → dist/src}/dream/output-validator.d.ts +0 -0
  675. /package/{runtime → dist/src}/dream/output-validator.js +0 -0
  676. /package/{runtime → dist/src}/dream/redaction-gate.d.ts +0 -0
  677. /package/{runtime → dist/src}/dream/redaction-gate.js +0 -0
  678. /package/{runtime → dist/src}/dream/relationship-update-proposal.d.ts +0 -0
  679. /package/{runtime → dist/src}/dream/relationship-update-proposal.js +0 -0
  680. /package/{runtime → dist/src}/dream/sampler.d.ts +0 -0
  681. /package/{runtime → dist/src}/dream/sampler.js +0 -0
  682. /package/{runtime → dist/src}/dream/types.d.ts +0 -0
  683. /package/{runtime → dist/src}/dream/types.js +0 -0
  684. /package/{runtime → dist/src}/guidance/capability-class.d.ts +0 -0
  685. /package/{runtime → dist/src}/guidance/capability-class.js +0 -0
  686. /package/{runtime → dist/src}/guidance/channel-feedback-ingestion-service.d.ts +0 -0
  687. /package/{runtime → dist/src}/guidance/channel-feedback-ingestion-service.js +0 -0
  688. /package/{runtime → dist/src}/guidance/contracts.d.ts +0 -0
  689. /package/{runtime → dist/src}/guidance/contracts.js +0 -0
  690. /package/{runtime → dist/src}/guidance/draft-narrative-outreach.d.ts +0 -0
  691. /package/{runtime → dist/src}/guidance/draft-narrative-outreach.js +0 -0
  692. /package/{runtime → dist/src}/guidance/draft-outreach-message.d.ts +0 -0
  693. /package/{runtime → dist/src}/guidance/draft-outreach-message.js +0 -0
  694. /package/{runtime → dist/src}/guidance/evidence-guidance.d.ts +0 -0
  695. /package/{runtime → dist/src}/guidance/evidence-guidance.js +0 -0
  696. /package/{runtime → dist/src}/guidance/fallback.d.ts +0 -0
  697. /package/{runtime → dist/src}/guidance/fallback.js +0 -0
  698. /package/{runtime → dist/src}/guidance/guidance-assembler.d.ts +0 -0
  699. /package/{runtime → dist/src}/guidance/guidance-assembler.js +0 -0
  700. /package/{runtime → dist/src}/guidance/guidance-draft-service.d.ts +0 -0
  701. /package/{runtime → dist/src}/guidance/guidance-draft-service.js +0 -0
  702. /package/{runtime → dist/src}/guidance/impulse-assembler.d.ts +0 -0
  703. /package/{runtime → dist/src}/guidance/impulse-assembler.js +0 -0
  704. /package/{runtime → dist/src}/guidance/index.d.ts +0 -0
  705. /package/{runtime → dist/src}/guidance/index.js +0 -0
  706. /package/{runtime → dist/src}/guidance/output-guard.d.ts +0 -0
  707. /package/{runtime → dist/src}/guidance/output-guard.js +0 -0
  708. /package/{runtime → dist/src}/guidance/outreach-draft-schema.d.ts +0 -0
  709. /package/{runtime → dist/src}/guidance/outreach-draft-schema.js +0 -0
  710. /package/{runtime → dist/src}/guidance/outreach-strategy-selector.d.ts +0 -0
  711. /package/{runtime → dist/src}/guidance/outreach-strategy-selector.js +0 -0
  712. /package/{runtime → dist/src}/guidance/persona-selection.d.ts +0 -0
  713. /package/{runtime → dist/src}/guidance/persona-selection.js +0 -0
  714. /package/{runtime → dist/src}/guidance/review-workflow.d.ts +0 -0
  715. /package/{runtime → dist/src}/guidance/review-workflow.js +0 -0
  716. /package/{runtime → dist/src}/guidance/template-registry.d.ts +0 -0
  717. /package/{runtime → dist/src}/guidance/template-registry.js +0 -0
  718. /package/{runtime → dist/src}/guidance/types.d.ts +0 -0
  719. /package/{runtime/storage/memory/workspace → dist/src/guidance}/types.js +0 -0
  720. /package/{runtime → dist/src}/observability/audit/append-only-audit-store.d.ts +0 -0
  721. /package/{runtime → dist/src}/observability/audit/append-only-audit-store.js +0 -0
  722. /package/{runtime → dist/src}/observability/audit/audit-envelope.d.ts +0 -0
  723. /package/{runtime → dist/src}/observability/audit/audit-envelope.js +0 -0
  724. /package/{runtime → dist/src}/observability/audit/audit-family-registry.json +0 -0
  725. /package/{runtime → dist/src}/observability/audit/family-registry.d.ts +0 -0
  726. /package/{runtime → dist/src}/observability/audit/family-registry.js +0 -0
  727. /package/{runtime → dist/src}/observability/audit/verify-audit-hash-chain.d.ts +0 -0
  728. /package/{runtime → dist/src}/observability/audit/verify-audit-hash-chain.js +0 -0
  729. /package/{runtime → dist/src}/observability/connector-inventory-ledger.d.ts +0 -0
  730. /package/{runtime → dist/src}/observability/connector-inventory-ledger.js +0 -0
  731. /package/{runtime → dist/src}/observability/db/index.d.ts +0 -0
  732. /package/{runtime → dist/src}/observability/db/index.js +0 -0
  733. /package/{runtime → dist/src}/observability/db/schema/connector-inventory.d.ts +0 -0
  734. /package/{runtime → dist/src}/observability/db/schema/connector-inventory.js +0 -0
  735. /package/{runtime → dist/src}/observability/db/schema/host-capability-reports.d.ts +0 -0
  736. /package/{runtime → dist/src}/observability/db/schema/host-capability-reports.js +0 -0
  737. /package/{runtime → dist/src}/observability/db/schema/index.d.ts +0 -0
  738. /package/{runtime → dist/src}/observability/db/schema/index.js +0 -0
  739. /package/{runtime → dist/src}/observability/index.d.ts +0 -0
  740. /package/{runtime → dist/src}/observability/index.js +0 -0
  741. /package/{runtime → dist/src}/observability/projections/guidance-audit.d.ts +0 -0
  742. /package/{runtime → dist/src}/observability/projections/guidance-audit.js +0 -0
  743. /package/{runtime → dist/src}/observability/projections/outreach-quality-audit.d.ts +0 -0
  744. /package/{runtime → dist/src}/observability/projections/outreach-quality-audit.js +0 -0
  745. /package/{runtime → dist/src}/observability/projections/reflection-audit.d.ts +0 -0
  746. /package/{runtime → dist/src}/observability/projections/reflection-audit.js +0 -0
  747. /package/{runtime → dist/src}/observability/query/compose-evidence.d.ts +0 -0
  748. /package/{runtime → dist/src}/observability/query/compose-evidence.js +0 -0
  749. /package/{runtime → dist/src}/observability/query/evidence-query-engine.d.ts +0 -0
  750. /package/{runtime → dist/src}/observability/query/evidence-query-engine.js +0 -0
  751. /package/{runtime → dist/src}/observability/query/explain-query.d.ts +0 -0
  752. /package/{runtime → dist/src}/observability/query/explain-query.js +0 -0
  753. /package/{runtime → dist/src}/observability/query/export-audit-bundle.d.ts +0 -0
  754. /package/{runtime → dist/src}/observability/query/export-audit-bundle.js +0 -0
  755. /package/{runtime → dist/src}/observability/redaction/manifest.d.ts +0 -0
  756. /package/{runtime → dist/src}/observability/redaction/manifest.js +0 -0
  757. /package/{runtime → dist/src}/observability/redaction/policy.d.ts +0 -0
  758. /package/{runtime → dist/src}/observability/redaction/policy.js +0 -0
  759. /package/{runtime → dist/src}/observability/services/decision-ledger.d.ts +0 -0
  760. /package/{runtime → dist/src}/observability/services/decision-ledger.js +0 -0
  761. /package/{runtime → dist/src}/observability/services/execution-telemetry.d.ts +0 -0
  762. /package/{runtime → dist/src}/observability/services/execution-telemetry.js +0 -0
  763. /package/{runtime → dist/src}/observability/services/governance-audit.d.ts +0 -0
  764. /package/{runtime → dist/src}/observability/services/governance-audit.js +0 -0
  765. /package/{runtime → dist/src}/observability/services/governance-plane-recorder.d.ts +0 -0
  766. /package/{runtime → dist/src}/observability/services/governance-plane-recorder.js +0 -0
  767. /package/{runtime → dist/src}/observability/services/heartbeat-digest-assembler.d.ts +0 -0
  768. /package/{runtime → dist/src}/observability/services/heartbeat-digest-assembler.js +0 -0
  769. /package/{runtime → dist/src}/observability/services/lived-experience-audit.d.ts +0 -0
  770. /package/{runtime → dist/src}/observability/services/lived-experience-audit.js +0 -0
  771. /package/{runtime → dist/src}/observability/services/narrative-timeline-query-service.d.ts +0 -0
  772. /package/{runtime → dist/src}/observability/services/narrative-timeline-query-service.js +0 -0
  773. /package/{runtime → dist/src}/observability/services/observability-retention.d.ts +0 -0
  774. /package/{runtime → dist/src}/observability/services/observability-retention.js +0 -0
  775. /package/{runtime → dist/src}/observability/services/redaction-store.d.ts +0 -0
  776. /package/{runtime → dist/src}/observability/services/redaction-store.js +0 -0
  777. /package/{runtime → dist/src}/observability/services/restore-audit-service.d.ts +0 -0
  778. /package/{runtime → dist/src}/observability/services/restore-audit-service.js +0 -0
  779. /package/{runtime → dist/src}/observability/services/runtime-decision-recorder.d.ts +0 -0
  780. /package/{runtime → dist/src}/observability/services/runtime-decision-recorder.js +0 -0
  781. /package/{runtime → dist/src}/observability/services/runtime-secret-anchor-view.d.ts +0 -0
  782. /package/{runtime → dist/src}/observability/services/runtime-secret-anchor-view.js +0 -0
  783. /package/{runtime → dist/src}/observability/services/self-health-snapshot.d.ts +0 -0
  784. /package/{runtime → dist/src}/observability/services/self-health-snapshot.js +0 -0
  785. /package/{runtime → dist/src}/shared/types/continuity.d.ts +0 -0
  786. /package/{runtime → dist/src}/shared/types/continuity.js +0 -0
  787. /package/{runtime → dist/src}/shared/types/credential.d.ts +0 -0
  788. /package/{runtime → dist/src}/shared/types/credential.js +0 -0
  789. /package/{runtime → dist/src}/shared/types/goal.d.ts +0 -0
  790. /package/{runtime → dist/src}/shared/types/goal.js +0 -0
  791. /package/{runtime → dist/src}/shared/types/index.d.ts +0 -0
  792. /package/{runtime → dist/src}/shared/types/index.js +0 -0
  793. /package/{runtime → dist/src}/shared/types/outreach.d.ts +0 -0
  794. /package/{runtime → dist/src}/shared/types/outreach.js +0 -0
  795. /package/{runtime → dist/src}/shared/types/source-ref.d.ts +0 -0
  796. /package/{runtime → dist/src}/shared/types/source-ref.js +0 -0
  797. /package/{runtime → dist/src}/shared/types/v7-entities.d.ts +0 -0
  798. /package/{runtime → dist/src}/shared/types/v7-entities.js +0 -0
  799. /package/{runtime → dist/src}/storage/bootstrap/native-sqlite-probe.d.ts +0 -0
  800. /package/{runtime → dist/src}/storage/bootstrap/native-sqlite-probe.js +0 -0
  801. /package/{runtime → dist/src}/storage/bootstrap/repair-gate.d.ts +0 -0
  802. /package/{runtime → dist/src}/storage/bootstrap/repair-gate.js +0 -0
  803. /package/{runtime → dist/src}/storage/bootstrap/repair.d.ts +0 -0
  804. /package/{runtime → dist/src}/storage/bootstrap/repair.js +0 -0
  805. /package/{runtime → dist/src}/storage/bootstrap/storage-mode-smoke.d.ts +0 -0
  806. /package/{runtime → dist/src}/storage/bootstrap/storage-mode-smoke.js +0 -0
  807. /package/{runtime → dist/src}/storage/chronicle/session-chronicle-store.d.ts +0 -0
  808. /package/{runtime → dist/src}/storage/chronicle/session-chronicle-store.js +0 -0
  809. /package/{runtime → dist/src}/storage/db/index.d.ts +0 -0
  810. /package/{runtime → dist/src}/storage/db/index.js +0 -0
  811. /package/{runtime → dist/src}/storage/db/migration-runner.d.ts +0 -0
  812. /package/{runtime → dist/src}/storage/db/migration-runner.js +0 -0
  813. /package/{runtime → dist/src}/storage/db/migrations/index.d.ts +0 -0
  814. /package/{runtime → dist/src}/storage/db/migrations/index.js +0 -0
  815. /package/{runtime → dist/src}/storage/db/migrations/v7-001-foundation.d.ts +0 -0
  816. /package/{runtime → dist/src}/storage/db/migrations/v7-001-foundation.js +0 -0
  817. /package/{runtime → dist/src}/storage/db/migrations/v7-002-effect-commit-ledger.d.ts +0 -0
  818. /package/{runtime → dist/src}/storage/db/migrations/v7-002-effect-commit-ledger.js +0 -0
  819. /package/{runtime → dist/src}/storage/db/migrations/v7-003-circuit-breaker.d.ts +0 -0
  820. /package/{runtime → dist/src}/storage/db/migrations/v7-003-circuit-breaker.js +0 -0
  821. /package/{runtime → dist/src}/storage/db/migrations/v7-004-behavior-promotion.d.ts +0 -0
  822. /package/{runtime → dist/src}/storage/db/migrations/v7-004-behavior-promotion.js +0 -0
  823. /package/{runtime → dist/src}/storage/db/schema/agent-goal.d.ts +0 -0
  824. /package/{runtime → dist/src}/storage/db/schema/agent-goal.js +0 -0
  825. /package/{runtime → dist/src}/storage/db/schema/assets.d.ts +0 -0
  826. /package/{runtime → dist/src}/storage/db/schema/assets.js +0 -0
  827. /package/{runtime → dist/src}/storage/db/schema/credentials.d.ts +0 -0
  828. /package/{runtime → dist/src}/storage/db/schema/credentials.js +0 -0
  829. /package/{runtime → dist/src}/storage/db/schema/delivery-attempts.d.ts +0 -0
  830. /package/{runtime → dist/src}/storage/db/schema/delivery-attempts.js +0 -0
  831. /package/{runtime → dist/src}/storage/db/schema/index.d.ts +0 -0
  832. /package/{runtime → dist/src}/storage/db/schema/index.js +0 -0
  833. /package/{runtime → dist/src}/storage/db/schema/intent-commits.d.ts +0 -0
  834. /package/{runtime → dist/src}/storage/db/schema/intent-commits.js +0 -0
  835. /package/{runtime → dist/src}/storage/db/schema/life-evidence-index.d.ts +0 -0
  836. /package/{runtime → dist/src}/storage/db/schema/life-evidence-index.js +0 -0
  837. /package/{runtime → dist/src}/storage/db/schema/memory-store.d.ts +0 -0
  838. /package/{runtime → dist/src}/storage/db/schema/memory-store.js +0 -0
  839. /package/{runtime → dist/src}/storage/db/schema/narrative-state.d.ts +0 -0
  840. /package/{runtime → dist/src}/storage/db/schema/narrative-state.js +0 -0
  841. /package/{runtime → dist/src}/storage/db/schema/operator-fallback-artifacts.d.ts +0 -0
  842. /package/{runtime → dist/src}/storage/db/schema/operator-fallback-artifacts.js +0 -0
  843. /package/{runtime → dist/src}/storage/db/schema/policies.d.ts +0 -0
  844. /package/{runtime → dist/src}/storage/db/schema/policies.js +0 -0
  845. /package/{runtime → dist/src}/storage/db/schema/proposals.d.ts +0 -0
  846. /package/{runtime → dist/src}/storage/db/schema/proposals.js +0 -0
  847. /package/{runtime → dist/src}/storage/db/schema/provenance.d.ts +0 -0
  848. /package/{runtime → dist/src}/storage/db/schema/provenance.js +0 -0
  849. /package/{runtime → dist/src}/storage/db/schema/relationship-memory.d.ts +0 -0
  850. /package/{runtime → dist/src}/storage/db/schema/relationship-memory.js +0 -0
  851. /package/{runtime → dist/src}/storage/db/schema/session-chronicle.d.ts +0 -0
  852. /package/{runtime → dist/src}/storage/db/schema/session-chronicle.js +0 -0
  853. /package/{runtime → dist/src}/storage/db/transaction-utils.d.ts +0 -0
  854. /package/{runtime → dist/src}/storage/db/transaction-utils.js +0 -0
  855. /package/{runtime → dist/src}/storage/db/write-queue.d.ts +0 -0
  856. /package/{runtime → dist/src}/storage/db/write-queue.js +0 -0
  857. /package/{runtime → dist/src}/storage/delivery/query-delivery-attempts.d.ts +0 -0
  858. /package/{runtime → dist/src}/storage/delivery/query-delivery-attempts.js +0 -0
  859. /package/{runtime → dist/src}/storage/delivery/types.d.ts +0 -0
  860. /package/{runtime/storage/snapshots → dist/src/storage/delivery}/types.js +0 -0
  861. /package/{runtime → dist/src}/storage/delivery/write-delivery-attempt.d.ts +0 -0
  862. /package/{runtime → dist/src}/storage/delivery/write-delivery-attempt.js +0 -0
  863. /package/{runtime → dist/src}/storage/fallback/load-operator-fallback.d.ts +0 -0
  864. /package/{runtime → dist/src}/storage/fallback/load-operator-fallback.js +0 -0
  865. /package/{runtime → dist/src}/storage/fallback/operator-fallback-types.d.ts +0 -0
  866. /package/{runtime → dist/src}/storage/fallback/operator-fallback-types.js +0 -0
  867. /package/{runtime → dist/src}/storage/fallback/operator-fallback-view.d.ts +0 -0
  868. /package/{runtime → dist/src}/storage/fallback/operator-fallback-view.js +0 -0
  869. /package/{runtime → dist/src}/storage/fallback/write-operator-fallback.d.ts +0 -0
  870. /package/{runtime → dist/src}/storage/fallback/write-operator-fallback.js +0 -0
  871. /package/{runtime → dist/src}/storage/goal/agent-goal-store.d.ts +0 -0
  872. /package/{runtime → dist/src}/storage/goal/agent-goal-store.js +0 -0
  873. /package/{runtime → dist/src}/storage/index.d.ts +0 -0
  874. /package/{runtime → dist/src}/storage/index.js +0 -0
  875. /package/{runtime → dist/src}/storage/life-evidence/append-life-evidence.d.ts +0 -0
  876. /package/{runtime → dist/src}/storage/life-evidence/append-life-evidence.js +0 -0
  877. /package/{runtime → dist/src}/storage/life-evidence/types.d.ts +0 -0
  878. /package/{runtime → dist/src}/storage/life-evidence/types.js +0 -0
  879. /package/{runtime → dist/src}/storage/memory/workspace/paths.d.ts +0 -0
  880. /package/{runtime → dist/src}/storage/memory/workspace/paths.js +0 -0
  881. /package/{runtime → dist/src}/storage/memory/workspace/store.d.ts +0 -0
  882. /package/{runtime → dist/src}/storage/memory/workspace/store.js +0 -0
  883. /package/{runtime → dist/src}/storage/memory/workspace/types.d.ts +0 -0
  884. /package/{runtime/storage/user-interest → dist/src/storage/memory/workspace}/types.js +0 -0
  885. /package/{runtime → dist/src}/storage/memory-store/memory-store-lifecycle.d.ts +0 -0
  886. /package/{runtime → dist/src}/storage/memory-store/memory-store-lifecycle.js +0 -0
  887. /package/{runtime → dist/src}/storage/narrative/narrative-state-store.d.ts +0 -0
  888. /package/{runtime → dist/src}/storage/narrative/narrative-state-store.js +0 -0
  889. /package/{runtime → dist/src}/storage/quiet/persist-quiet-artifact.d.ts +0 -0
  890. /package/{runtime → dist/src}/storage/quiet/persist-quiet-artifact.js +0 -0
  891. /package/{runtime → dist/src}/storage/quiet/quiet-artifact-types.d.ts +0 -0
  892. /package/{runtime → dist/src}/storage/quiet/quiet-artifact-types.js +0 -0
  893. /package/{runtime → dist/src}/storage/quiet/quiet-artifact-writer.d.ts +0 -0
  894. /package/{runtime → dist/src}/storage/quiet/quiet-artifact-writer.js +0 -0
  895. /package/{runtime → dist/src}/storage/relationship/relationship-memory-store.d.ts +0 -0
  896. /package/{runtime → dist/src}/storage/relationship/relationship-memory-store.js +0 -0
  897. /package/{runtime → dist/src}/storage/repositories/asset-repository.d.ts +0 -0
  898. /package/{runtime → dist/src}/storage/repositories/asset-repository.js +0 -0
  899. /package/{runtime → dist/src}/storage/repositories/credential-repository.d.ts +0 -0
  900. /package/{runtime → dist/src}/storage/repositories/credential-repository.js +0 -0
  901. /package/{runtime → dist/src}/storage/repositories/index.d.ts +0 -0
  902. /package/{runtime → dist/src}/storage/repositories/index.js +0 -0
  903. /package/{runtime → dist/src}/storage/repositories/intent-commit-repository.d.ts +0 -0
  904. /package/{runtime → dist/src}/storage/repositories/intent-commit-repository.js +0 -0
  905. /package/{runtime → dist/src}/storage/repositories/policy-repository.d.ts +0 -0
  906. /package/{runtime → dist/src}/storage/repositories/policy-repository.js +0 -0
  907. /package/{runtime → dist/src}/storage/repositories/proposal-repository.d.ts +0 -0
  908. /package/{runtime → dist/src}/storage/repositories/proposal-repository.js +0 -0
  909. /package/{runtime → dist/src}/storage/repositories/provenance-repository.d.ts +0 -0
  910. /package/{runtime → dist/src}/storage/repositories/provenance-repository.js +0 -0
  911. /package/{runtime → dist/src}/storage/rhythm/rhythm-policy-snapshot.d.ts +0 -0
  912. /package/{runtime → dist/src}/storage/rhythm/rhythm-policy-snapshot.js +0 -0
  913. /package/{runtime → dist/src}/storage/services/credential-vault.d.ts +0 -0
  914. /package/{runtime → dist/src}/storage/services/credential-vault.js +0 -0
  915. /package/{runtime → dist/src}/storage/services/daily-log-pipeline.d.ts +0 -0
  916. /package/{runtime → dist/src}/storage/services/daily-log-pipeline.js +0 -0
  917. /package/{runtime → dist/src}/storage/services/diary-dream-store.d.ts +0 -0
  918. /package/{runtime → dist/src}/storage/services/diary-dream-store.js +0 -0
  919. /package/{runtime → dist/src}/storage/services/effect-commit-store.d.ts +0 -0
  920. /package/{runtime → dist/src}/storage/services/effect-commit-store.js +0 -0
  921. /package/{runtime → dist/src}/storage/services/embodied-context-state-port.d.ts +0 -0
  922. /package/{runtime → dist/src}/storage/services/embodied-context-state-port.js +0 -0
  923. /package/{runtime → dist/src}/storage/services/goal-lifecycle-store.d.ts +0 -0
  924. /package/{runtime → dist/src}/storage/services/goal-lifecycle-store.js +0 -0
  925. /package/{runtime → dist/src}/storage/services/governance-layer.d.ts +0 -0
  926. /package/{runtime → dist/src}/storage/services/governance-layer.js +0 -0
  927. /package/{runtime → dist/src}/storage/services/history-digest-store.d.ts +0 -0
  928. /package/{runtime → dist/src}/storage/services/history-digest-store.js +0 -0
  929. /package/{runtime → dist/src}/storage/services/identity-profile-store.d.ts +0 -0
  930. /package/{runtime → dist/src}/storage/services/identity-profile-store.js +0 -0
  931. /package/{runtime → dist/src}/storage/services/interaction-snapshot-projector.d.ts +0 -0
  932. /package/{runtime → dist/src}/storage/services/interaction-snapshot-projector.js +0 -0
  933. /package/{runtime → dist/src}/storage/services/persona-candidate-loader.d.ts +0 -0
  934. /package/{runtime → dist/src}/storage/services/persona-candidate-loader.js +0 -0
  935. /package/{runtime → dist/src}/storage/services/provenance-service.d.ts +0 -0
  936. /package/{runtime → dist/src}/storage/services/provenance-service.js +0 -0
  937. /package/{runtime → dist/src}/storage/services/quiet-input-loader.d.ts +0 -0
  938. /package/{runtime → dist/src}/storage/services/quiet-input-loader.js +0 -0
  939. /package/{runtime → dist/src}/storage/services/repair-and-backup.d.ts +0 -0
  940. /package/{runtime → dist/src}/storage/services/repair-and-backup.js +0 -0
  941. /package/{runtime → dist/src}/storage/services/restore-snapshot-store.d.ts +0 -0
  942. /package/{runtime → dist/src}/storage/services/restore-snapshot-store.js +0 -0
  943. /package/{runtime → dist/src}/storage/services/runtime-secret-anchor-store.d.ts +0 -0
  944. /package/{runtime → dist/src}/storage/services/runtime-secret-anchor-store.js +0 -0
  945. /package/{runtime → dist/src}/storage/services/tool-experience-store.d.ts +0 -0
  946. /package/{runtime → dist/src}/storage/services/tool-experience-store.js +0 -0
  947. /package/{runtime → dist/src}/storage/services/write-validation-gate.d.ts +0 -0
  948. /package/{runtime → dist/src}/storage/services/write-validation-gate.js +0 -0
  949. /package/{runtime → dist/src}/storage/snapshots/continuity-snapshot.d.ts +0 -0
  950. /package/{runtime → dist/src}/storage/snapshots/continuity-snapshot.js +0 -0
  951. /package/{runtime → dist/src}/storage/snapshots/life-evidence-snapshot.d.ts +0 -0
  952. /package/{runtime → dist/src}/storage/snapshots/life-evidence-snapshot.js +0 -0
  953. /package/{runtime → dist/src}/storage/snapshots/types.d.ts +0 -0
  954. /package/{runtime → dist/src}/storage/state-api.d.ts +0 -0
  955. /package/{runtime → dist/src}/storage/state-api.js +0 -0
  956. /package/{runtime → dist/src}/storage/user-interest/load-user-interest-snapshot.d.ts +0 -0
  957. /package/{runtime → dist/src}/storage/user-interest/load-user-interest-snapshot.js +0 -0
  958. /package/{runtime → dist/src}/storage/user-interest/types.d.ts +0 -0
@@ -1,1454 +0,0 @@
1
- /**
2
- * Shared ops command dispatch for CLI + tool surfaces (T1.1.3, T1.2.2).
3
- *
4
- * v7 additions (T-ROS.C.1): self_health, tool_affordance, connector_test --wet,
5
- * heartbeat_digest, narrative:diff, timeline, restore, runtime_secret_bootstrap.
6
- * All commands return RuntimeOpsEnvelope.
7
- */
8
- import { createHash } from "node:crypto";
9
- import fs from "node:fs";
10
- import path from "node:path";
11
- import { heartbeatCheck, } from "./heartbeat-surface.js";
12
- import { showOperatorFallback, OperatorFallbackNotFoundError, } from "./show-operator-fallback.js";
13
- import { probeHostCapability } from "../host-capability/probe-host-capability.js";
14
- import { recordHostCapability } from "../host-capability/record-host-capability.js";
15
- import { runNearRealConnectorSmoke } from "../../connectors/near-real/near-real-connector-smoke.js";
16
- import { scanConnectorManifests } from "../../connectors/registry/manifest-scanner.js";
17
- import { parseConnectorManifestV6 } from "../../connectors/manifest/manifest-parser.js";
18
- import { connectorInit } from "../commands/connector-init.js";
19
- import { connectorBehaviorAdd } from "../commands/connector-behavior.js";
20
- import { connectorStatus, connectorTest } from "../commands/connector-status.js";
21
- import { goalCommand } from "../commands/goal.js";
22
- // v7 observability services (T-ROS.C.1)
23
- import { getSelfHealthSnapshot, ensureMinimumProbes, } from "../../observability/services/self-health-snapshot.js";
24
- import { generateHeartbeatDigest, } from "../../observability/services/heartbeat-digest-assembler.js";
25
- import { queryNarrativeTimeline, queryNarrativeDiff, NarrativeVersionNotFoundError, } from "../../observability/services/narrative-timeline-query-service.js";
26
- import { viewSecretAnchor, } from "../../observability/services/runtime-secret-anchor-view.js";
27
- import { writeRestoreAudit, } from "../../observability/services/restore-audit-service.js";
28
- import { createHistoryDigestStore } from "../../storage/services/history-digest-store.js";
29
- // T-ROS.C.3: ManualRunDispatcher and its deps
30
- import { createManualRunDispatcher, } from "./manual-run-dispatcher.js";
31
- import { createExperienceWriter } from "../../core/second-nature/body/tool-experience/experience-writer.js";
32
- import { createCapabilityProbeResultStore, createToolExperienceStore, } from "../../storage/services/tool-experience-store.js";
33
- import { createWetProbeRunner } from "../../connectors/base/wet-probe-runner.js";
34
- import { CapabilityContractRegistryV7 } from "../../connectors/base/manifest-v7.js";
35
- // v7 T-V7C.C.6: Dream scheduling deps for heartbeat_check quiet→dream auto-trigger
36
- import { scheduleDream } from "../../dream/dream-scheduler.js";
37
- import { createDreamInputLoader } from "../../dream/dream-input-loader.js";
38
- import { createDiaryDreamStore } from "../../storage/services/diary-dream-store.js";
39
- function coerceProbeOnlyFlag(input) {
40
- const v = input?.probeOnly;
41
- return v === true || v === "true" || v === 1 || v === "1";
42
- }
43
- /**
44
- * v7 T-V7C.C.6: Build a minimal QuietDreamSchedulePort backed by the state DB.
45
- * When a source-backed Quiet write completes, this port triggers Dream scheduling
46
- * via the standard scheduleDream path (rules-only mode when no model port).
47
- */
48
- function createQuietDreamSchedulePort(state) {
49
- return {
50
- async scheduleDream({ triggerKind, runId, traceId }) {
51
- const dreamStore = createDiaryDreamStore(state);
52
- const inputLoader = createDreamInputLoader({ database: state });
53
- const statePort = {
54
- async loadDreamInputs(query) {
55
- return inputLoader.loadDreamInputs(query);
56
- },
57
- async writeDreamOutput(output) {
58
- // Bridge: dream-engine emits dream/types DreamOutput; diary-dream-store expects shared/types.
59
- // Structures are identical at runtime; TS strictness requires the cast.
60
- await dreamStore.appendDreamOutput(output);
61
- return { outputId: output.outputId, status: "acknowledged" };
62
- },
63
- async markDreamOutputLifecycle(input) {
64
- // transitionDreamOutputLifecycle only accepts accepted|archived.
65
- if (input.newStatus !== "accepted" && input.newStatus !== "archived") {
66
- return { outputId: input.outputId, status: "degraded" };
67
- }
68
- await dreamStore.transitionDreamOutputLifecycle(input.outputId, input.newStatus);
69
- return { outputId: input.outputId, status: "acknowledged" };
70
- },
71
- };
72
- const result = await scheduleDream({
73
- triggerKind,
74
- runId,
75
- traceId,
76
- statePort,
77
- windowKey: "quiet_completion",
78
- });
79
- return { status: result.status, reason: result.reason };
80
- },
81
- };
82
- }
83
- const SNAPSHOT_TABLE_BY_KIND = {
84
- identity_profile: "identity_profile",
85
- agent_goal: "agent_goal",
86
- tool_experience: "tool_experience",
87
- daily_diary: "daily_diary_index",
88
- dream_output: "dream_output_index",
89
- narrative_timeline: "narrative_timeline",
90
- };
91
- const DEFAULT_SNAPSHOT_KINDS = [
92
- "identity_profile",
93
- "agent_goal",
94
- "tool_experience",
95
- "daily_diary",
96
- "dream_output",
97
- "narrative_timeline",
98
- ];
99
- function coerceRestorableKinds(value) {
100
- if (!Array.isArray(value))
101
- return undefined;
102
- const valid = new Set(DEFAULT_SNAPSHOT_KINDS);
103
- return value.filter((item) => typeof item === "string" && valid.has(item));
104
- }
105
- function tableExists(state, table) {
106
- const result = state.sqlite.exec(`SELECT name FROM sqlite_master WHERE type = 'table' AND name = ? LIMIT 1`, [table]);
107
- return result.length > 0 && result[0].values.length > 0;
108
- }
109
- function readRowsFromTable(state, table) {
110
- const result = state.sqlite.exec(`SELECT * FROM ${table}`);
111
- if (result.length === 0 || result[0].values.length === 0)
112
- return [];
113
- const columns = result[0].columns;
114
- return result[0].values.map((row) => {
115
- const out = {};
116
- columns.forEach((column, index) => {
117
- out[column] = row[index];
118
- });
119
- return out;
120
- });
121
- }
122
- function stringArray(value) {
123
- return Array.isArray(value)
124
- ? value.filter((item) => typeof item === "string")
125
- : [];
126
- }
127
- function textInput(input, key) {
128
- const value = input?.[key];
129
- if (typeof value !== "string")
130
- return undefined;
131
- const trimmed = value.trim();
132
- return trimmed.length > 0 ? trimmed : undefined;
133
- }
134
- function buildSnapshotNarrativeDelta(input, snapshotId, rowCounts) {
135
- const explicit = input?.narrativeSnapshot &&
136
- typeof input.narrativeSnapshot === "object" &&
137
- !Array.isArray(input.narrativeSnapshot)
138
- ? input.narrativeSnapshot
139
- : {};
140
- const from = (key) => input?.[key] ?? explicit[key];
141
- const sourceRefs = stringArray(from("sourceRefs"));
142
- return {
143
- focus: from("focus") ?? "workspace_state",
144
- progress: from("progress") ??
145
- `snapshot_captured:${Object.entries(rowCounts)
146
- .map(([kind, count]) => `${kind}=${count}`)
147
- .join(",")}`,
148
- nextIntent: from("nextIntent") ?? "restore_ready",
149
- toneSignal: from("toneSignal") ?? "system_maintenance",
150
- acceptedGoalId: from("acceptedGoalId") ?? undefined,
151
- sourceRefs: sourceRefs.length > 0
152
- ? sourceRefs
153
- : [`restore_snapshot:${snapshotId}`, "runtime_ops:snapshot_capture"],
154
- reasonCode: from("reasonCode") ?? "snapshot_captured",
155
- summaryText: from("summaryText") ?? `Captured restore snapshot ${snapshotId}`,
156
- };
157
- }
158
- function hashNarrativeSnapshot(input) {
159
- return createHash("sha256")
160
- .update(JSON.stringify({
161
- previousHash: input.previousHash,
162
- snapshotId: input.snapshotId,
163
- delta: input.delta,
164
- createdAt: input.createdAt,
165
- }))
166
- .digest("hex");
167
- }
168
- function resolveManifestPath(manifestPath, workspaceRoot) {
169
- if (path.isAbsolute(manifestPath))
170
- return manifestPath;
171
- return path.join(workspaceRoot ?? process.cwd(), manifestPath);
172
- }
173
- function registerConnectorForWetProbe(input) {
174
- if (input.entry.manifestPath) {
175
- try {
176
- const manifestText = fs.readFileSync(resolveManifestPath(input.entry.manifestPath, input.workspaceRoot), "utf-8");
177
- const parsed = JSON.parse(manifestText);
178
- const registered = input.registryV7.register(parsed);
179
- if (registered.ok && input.registryV7.hasCapability(input.entry.platformId, input.selectedCapabilityId)) {
180
- return;
181
- }
182
- }
183
- catch {
184
- // Non-v7 or YAML workspace manifests are projected below.
185
- }
186
- }
187
- input.registryV7.register({
188
- platformId: input.entry.platformId,
189
- capabilities: input.entry.capabilities.map((capabilityId) => ({
190
- capabilityId,
191
- intent: capabilityId,
192
- probeConfig: capabilityId === input.selectedCapabilityId && input.safeEndpoint
193
- ? {
194
- safeEndpoint: input.safeEndpoint,
195
- idempotencyClass: "read_only",
196
- }
197
- : undefined,
198
- })),
199
- channelPriority: ["runtime_ops"],
200
- credentialTypes: ["runtime_ops_probe"],
201
- });
202
- }
203
- async function captureRuntimeSnapshot(deps, input) {
204
- const generatedAt = new Date().toISOString();
205
- if (!deps.state || !deps.restoreSnapshotStore) {
206
- return {
207
- ok: false,
208
- command: "snapshot:capture",
209
- runtimeMode: "unavailable",
210
- surfaceMode: "cli",
211
- generatedAt,
212
- error: {
213
- code: "SNAPSHOT_CAPTURE_DEPS_UNAVAILABLE",
214
- message: "snapshot:capture requires state DB and RestoreSnapshotStore in OpsRouterDeps",
215
- nextStep: "wire_state_and_restore_snapshot_store_into_ops_router",
216
- },
217
- warnings: [],
218
- sourceRefs: [],
219
- };
220
- }
221
- const snapshotId = textInput(input, "snapshotId") ??
222
- `snapshot:${Date.now()}:${Math.random().toString(36).slice(2, 8)}`;
223
- const requestedKinds = coerceRestorableKinds(input?.entityWhitelist) ?? [...DEFAULT_SNAPSHOT_KINDS];
224
- const rowCounts = {};
225
- const warnings = [];
226
- for (const kind of requestedKinds) {
227
- const table = SNAPSHOT_TABLE_BY_KIND[kind];
228
- if (!tableExists(deps.state, table)) {
229
- rowCounts[kind] = 0;
230
- warnings.push(`table_missing:${kind}:${table}`);
231
- continue;
232
- }
233
- rowCounts[kind] = readRowsFromTable(deps.state, table).length;
234
- }
235
- const historyStore = createHistoryDigestStore(deps.state);
236
- const previousHash = (await historyStore.listNarrativeTimeline({ limit: 1 }))[0]?.currentHash ?? "";
237
- const delta = buildSnapshotNarrativeDelta(input, snapshotId, rowCounts);
238
- const currentHash = hashNarrativeSnapshot({
239
- previousHash,
240
- snapshotId,
241
- delta,
242
- createdAt: generatedAt,
243
- });
244
- await historyStore.appendNarrativeTimeline({
245
- timelineId: snapshotId,
246
- entryType: "owner.override",
247
- subjectId: textInput(input, "subjectId") ?? snapshotId,
248
- delta,
249
- previousHash,
250
- currentHash,
251
- createdAt: generatedAt,
252
- });
253
- const payload = {};
254
- const capturedKinds = [];
255
- for (const kind of requestedKinds) {
256
- const table = SNAPSHOT_TABLE_BY_KIND[kind];
257
- if (!tableExists(deps.state, table))
258
- continue;
259
- const rows = readRowsFromTable(deps.state, table);
260
- rowCounts[kind] = rows.length;
261
- if (rows.length > 0) {
262
- payload[kind] = rows;
263
- capturedKinds.push(kind);
264
- }
265
- }
266
- const snapshot = await deps.restoreSnapshotStore.captureSnapshot({
267
- snapshotId,
268
- entityWhitelist: requestedKinds,
269
- payload,
270
- capturedAt: generatedAt,
271
- });
272
- return {
273
- ok: true,
274
- command: "snapshot:capture",
275
- runtimeMode: "workspace_full_runtime",
276
- surfaceMode: "cli",
277
- generatedAt,
278
- data: {
279
- snapshotId: snapshot.snapshotId,
280
- capturedAt: snapshot.capturedAt,
281
- entityWhitelist: snapshot.entityWhitelist,
282
- capturedKinds,
283
- rowCounts,
284
- narrativeVersion: snapshotId,
285
- },
286
- warnings,
287
- sourceRefs: [
288
- "storage/services/restore-snapshot-store.ts",
289
- "storage/services/history-digest-store.ts",
290
- ],
291
- };
292
- }
293
- /**
294
- * T1.2.8 — static local adapter: all checks return `unknown` when no real host is available.
295
- * Allows `capability_probe` to be called from CLI / workspace bridge without requiring a live host.
296
- */
297
- function createStaticUnknownAdapter(workspaceRoot) {
298
- const now = new Date().toISOString();
299
- const unknownResult = (name) => ({
300
- name,
301
- verdict: "unknown",
302
- observedAt: now,
303
- reason: "static_local_probe_no_host_context",
304
- evidenceRefs: [],
305
- });
306
- function checkDeliveryTarget() {
307
- if (!workspaceRoot) {
308
- return { status: "target_none", evidenceRefs: [], reason: "no_workspace_root_provided" };
309
- }
310
- const deliveryCapabilities = ["message.send", "comment.reply"];
311
- const scanned = scanConnectorManifests(workspaceRoot);
312
- for (const manifestFile of scanned) {
313
- const parsed = parseConnectorManifestV6(manifestFile.content, manifestFile.path);
314
- if (parsed.ok && parsed.manifest.capabilities.some((cap) => deliveryCapabilities.includes(cap.id))) {
315
- return {
316
- status: "target_available",
317
- evidenceRefs: [
318
- {
319
- id: `delivery:${parsed.manifest.platformId}`,
320
- kind: "workspace_artifact",
321
- uri: `workspace://connectors/${parsed.manifest.platformId}/manifest.yaml`,
322
- observedAt: now,
323
- },
324
- ],
325
- };
326
- }
327
- }
328
- return { status: "target_none", evidenceRefs: [], reason: "no_delivery_connector_found_in_workspace" };
329
- }
330
- return {
331
- checkPluginLoad: () => unknownResult("plugin_load"),
332
- checkHeartbeatBridge: () => unknownResult("heartbeat_bridge"),
333
- checkHeartbeatToolInvocation: () => unknownResult("heartbeat_tool_invocation"),
334
- checkDeliveryTarget,
335
- checkAckDropBehavior: () => unknownResult("ack_drop"),
336
- checkHookSupport: () => [],
337
- };
338
- }
339
- export function createOpsRouter(deps) {
340
- return {
341
- heartbeatCheck: (input) => heartbeatCheck({
342
- ...input,
343
- runtimeAvailable: input.runtimeAvailable ?? deps.runtimeAvailable,
344
- readModels: input.readModels ?? deps.readModels,
345
- runtimeRecorder: input.runtimeRecorder ?? deps.runtimeRecorder,
346
- state: input.state ?? deps.state,
347
- workspaceRoot: input.workspaceRoot ?? deps.workspaceRoot,
348
- connectorExecutor: input.connectorExecutor ?? deps.connectorExecutor,
349
- connectorRegistry: input
350
- ?.connectorRegistry ?? deps.connectorRegistry,
351
- digestOpts: input.digestOpts,
352
- dreamSchedulePort: input.dreamSchedulePort,
353
- }),
354
- async dispatch(command, input) {
355
- if (command === "heartbeat_check") {
356
- const runtimeAvailable = typeof input?.runtimeAvailable === "boolean"
357
- ? input.runtimeAvailable
358
- : deps.runtimeAvailable;
359
- // v7 T-V7C.C.2: assemble affordance map and experience writer for breaker-aware heartbeat.
360
- let affordanceMap;
361
- if (deps.toolAffordancePort) {
362
- try {
363
- affordanceMap = await deps.toolAffordancePort.assembleAffordanceMap({});
364
- }
365
- catch {
366
- // degrade gracefully; guard-layer will skip breaker check without affordanceMap
367
- }
368
- }
369
- let experienceWriter;
370
- if (deps.state) {
371
- experienceWriter = createExperienceWriter(createToolExperienceStore(deps.state));
372
- }
373
- // v7 T-V7C.C.6: assemble digest opts when auditStore is wired.
374
- let digestOpts;
375
- if (deps.auditStore) {
376
- digestOpts = {
377
- assemblerDeps: {
378
- auditStore: deps.auditStore,
379
- ...deps.heartbeatDigestDeps,
380
- },
381
- };
382
- }
383
- // v7 T-V7C.C.6: assemble dream schedule port when state DB is wired.
384
- let dreamSchedulePort;
385
- if (deps.state) {
386
- dreamSchedulePort = createQuietDreamSchedulePort(deps.state);
387
- }
388
- try {
389
- const result = await heartbeatCheck({
390
- probeOnly: coerceProbeOnlyFlag(input),
391
- runtimeAvailable,
392
- fakeControlPlanePassthrough: input?.fakeControlPlanePassthrough &&
393
- typeof input.fakeControlPlanePassthrough === "object"
394
- ? input.fakeControlPlanePassthrough
395
- : undefined,
396
- readModels: input?.readModels ??
397
- deps.readModels,
398
- runtimeRecorder: input
399
- ?.runtimeRecorder ?? deps.runtimeRecorder,
400
- state: input?.state ??
401
- deps.state,
402
- workspaceRoot: input
403
- ?.workspaceRoot ?? deps.workspaceRoot,
404
- timestamp: typeof input?.timestamp === "string" ? input.timestamp : undefined,
405
- sessionContext: typeof input?.sessionContext === "string"
406
- ? input.sessionContext
407
- : undefined,
408
- scopeHint: input?.scopeHint,
409
- connectorExecutor: input
410
- ?.connectorExecutor ?? deps.connectorExecutor,
411
- connectorRegistry: input
412
- ?.connectorRegistry ?? deps.connectorRegistry,
413
- affordanceMap,
414
- experienceWriter,
415
- digestOpts,
416
- dreamSchedulePort,
417
- });
418
- if (result.ok &&
419
- result.surfaceMode === "workspace_full_runtime" &&
420
- !coerceProbeOnlyFlag(input) &&
421
- deps.state &&
422
- deps.restoreSnapshotStore) {
423
- try {
424
- const capture = await captureRuntimeSnapshot(deps, {
425
- snapshotId: `heartbeat:${result.decisionId ?? "cycle"}:${Date.now()}`,
426
- subjectId: result.decisionId ?? "heartbeat_check",
427
- reasonCode: "heartbeat_check",
428
- summaryText: `Heartbeat ${result.status} captured bounded restore snapshot`,
429
- focus: result.status,
430
- progress: result.reasons.join(",") || "heartbeat_completed",
431
- nextIntent: "continue_runtime_loop",
432
- sourceRefs: result.decisionId
433
- ? [`heartbeat:${result.decisionId}`]
434
- : ["heartbeat:runtime"],
435
- });
436
- if (capture.ok) {
437
- result.reasons = [...result.reasons, "restore_snapshot_captured"];
438
- }
439
- }
440
- catch (err) {
441
- const msg = err instanceof Error ? err.message : String(err);
442
- result.reasons = [...result.reasons, `restore_snapshot_capture_failed:${msg}`];
443
- }
444
- }
445
- return result;
446
- }
447
- catch (err) {
448
- const msg = err instanceof Error ? err.message : String(err);
449
- const envelope = {
450
- ok: false,
451
- command: "heartbeat_check",
452
- runtimeMode: runtimeAvailable ? "workspace_full_runtime" : "unavailable",
453
- surfaceMode: "cli",
454
- generatedAt: new Date().toISOString(),
455
- error: {
456
- code: "HEARTBEAT_CYCLE_EXCEPTION",
457
- message: `heartbeat_check cycle threw unexpectedly: ${msg.slice(0, 200)}`,
458
- nextStep: "check_logs_and_report",
459
- },
460
- warnings: [],
461
- sourceRefs: [],
462
- };
463
- return envelope;
464
- }
465
- }
466
- if (command === "fallback") {
467
- const ref = typeof input?.ref === "string" ? input.ref.trim() : "";
468
- if (!ref) {
469
- return {
470
- ok: false,
471
- error: {
472
- code: "MISSING_FALLBACK_REF",
473
- message: "fallback requires args.ref (e.g. fallback:…)",
474
- requiredUserInput: ["ref"],
475
- nextStep: "reinvoke_with_ref",
476
- },
477
- };
478
- }
479
- if (!deps.readModels?.loadFallbackView) {
480
- return {
481
- ok: false,
482
- error: {
483
- code: "FALLBACK_READ_MODEL_UNAVAILABLE",
484
- message: "Operator fallback view requires workspace read models",
485
- requiredUserInput: ["ref"],
486
- nextStep: "wire_read_models_into_ops_router",
487
- },
488
- };
489
- }
490
- return (async () => {
491
- try {
492
- const data = await showOperatorFallback(ref, deps.readModels);
493
- return { ok: true, command: "fallback", data };
494
- }
495
- catch (error) {
496
- if (error instanceof OperatorFallbackNotFoundError) {
497
- return {
498
- ok: false,
499
- command: "fallback",
500
- error: {
501
- code: error.code,
502
- message: error.message,
503
- requiredUserInput: ["ref"],
504
- nextStep: "verify_fallback_ref_from_delivery_audit",
505
- },
506
- };
507
- }
508
- throw error;
509
- }
510
- })();
511
- }
512
- if (command === "capability_probe") {
513
- // T1.2.8 (SN-CODE-03): run host capability probe with static unknown adapter (CLI context).
514
- // Persists report when observabilityDb is available; returns safe JSON subset.
515
- return (async () => {
516
- const adapter = createStaticUnknownAdapter(deps.workspaceRoot);
517
- const docCheckedAt = new Date().toISOString();
518
- const report = probeHostCapability({
519
- adapter,
520
- docLinks: [],
521
- docCheckedAt,
522
- });
523
- if (deps.observabilityDb) {
524
- await recordHostCapability(deps.observabilityDb, report);
525
- }
526
- return {
527
- ok: true,
528
- command: "capability_probe",
529
- data: {
530
- reportId: report.reportId,
531
- generatedAt: report.generatedAt,
532
- deliveryTarget: report.deliveryTarget,
533
- pluginLoad: { verdict: report.pluginLoad.verdict },
534
- heartbeatBridge: { verdict: report.heartbeatBridge.verdict },
535
- heartbeatToolInvocation: {
536
- verdict: report.heartbeatToolInvocation.verdict,
537
- },
538
- ackDropBehavior: { verdict: report.ackDropBehavior.verdict },
539
- conflictCount: report.conflictRecords.length,
540
- recommendedNextStep: report.recommendedNextStep,
541
- note: "static_local_probe: all verdicts are unknown without live host context",
542
- },
543
- };
544
- })();
545
- }
546
- if (command === "near_real_smoke") {
547
- // T3.3.2 (SN-CODE-05): wrap runNearRealConnectorSmoke as an ops surface command.
548
- // Requires state + observabilityDb + workspaceRoot to be wired into OpsRouterDeps.
549
- if (!deps.state || !deps.observabilityDb || !deps.workspaceRoot) {
550
- return {
551
- ok: false,
552
- command: "near_real_smoke",
553
- error: {
554
- code: "NEAR_REAL_SMOKE_DEPS_UNAVAILABLE",
555
- message: "near_real_smoke requires state, observabilityDb, and workspaceRoot in OpsRouterDeps",
556
- nextStep: "wire_deps_into_ops_router",
557
- },
558
- };
559
- }
560
- return (async () => {
561
- const result = await runNearRealConnectorSmoke({
562
- state: deps.state,
563
- observabilityDb: deps.observabilityDb,
564
- workspaceRoot: deps.workspaceRoot,
565
- });
566
- return {
567
- ok: true,
568
- command: "near_real_smoke",
569
- data: result,
570
- };
571
- })();
572
- }
573
- if (command === "connector_init") {
574
- // T1.3.1 (SN-CODE-06): generate connector manifest stub.
575
- return (async () => {
576
- const result = await connectorInit({
577
- platformId: typeof input?.platformId === "string" ? input.platformId : "",
578
- family: typeof input?.family === "string"
579
- ? input.family
580
- : undefined,
581
- displayName: typeof input?.displayName === "string" ? input.displayName : undefined,
582
- runnerKind: typeof input?.runnerKind === "string"
583
- ? input.runnerKind
584
- : undefined,
585
- force: Boolean(input?.force),
586
- workspaceRoot: deps.workspaceRoot,
587
- });
588
- return result;
589
- })();
590
- }
591
- if (command === "connector_behavior_add") {
592
- return connectorBehaviorAdd({
593
- platformId: typeof input?.platformId === "string" ? input.platformId : "",
594
- behaviorId: typeof input?.behaviorId === "string"
595
- ? input.behaviorId
596
- : typeof input?.capabilityId === "string"
597
- ? input.capabilityId
598
- : "",
599
- description: typeof input?.description === "string" ? input.description : undefined,
600
- channel: typeof input?.channel === "string" ? input.channel : undefined,
601
- sourceRefs: input?.sourceRefs,
602
- observedCount: typeof input?.observedCount === "number" ? input.observedCount : undefined,
603
- workspaceRoot: typeof input?.workspaceRoot === "string"
604
- ? input.workspaceRoot
605
- : deps.workspaceRoot,
606
- });
607
- }
608
- if (command === "connector_status") {
609
- return connectorStatus(deps.registry, undefined, {
610
- includeHealth: Boolean(input?.includeHealth),
611
- workspaceRoot: typeof input?.workspaceRoot === "string"
612
- ? input.workspaceRoot
613
- : deps.workspaceRoot,
614
- });
615
- }
616
- if (command === "connector_test") {
617
- // v7 T-V7C.C.1: dryRun=false is the canonical wet probe switch.
618
- const isWet = input?.wet === true ||
619
- input?.wet === "true" ||
620
- input?.dryRun === false ||
621
- input?.dryRun === "false";
622
- const result = await connectorTest(deps.registry, {
623
- platformId: typeof input?.platformId === "string" ? input.platformId : "",
624
- dryRun: isWet ? false : (input?.dryRun === false ? false : true),
625
- workspaceRoot: typeof input?.workspaceRoot === "string"
626
- ? input.workspaceRoot
627
- : deps.workspaceRoot,
628
- });
629
- if (!isWet || !result.ok) {
630
- return result;
631
- }
632
- const data = result.data && typeof result.data === "object"
633
- ? result.data
634
- : {};
635
- const capabilities = Array.isArray(data.capabilities)
636
- ? data.capabilities.filter((item) => typeof item === "string")
637
- : [];
638
- const capabilityId = textInput(input, "capabilityId") ?? capabilities[0] ?? "";
639
- if (!capabilityId) {
640
- return {
641
- ok: false,
642
- command: "connector_test",
643
- error: {
644
- code: "MISSING_CAPABILITY_ID",
645
- message: "wet connector_test requires capabilityId or at least one connector capability",
646
- requiredUserInput: ["capabilityId"],
647
- nextStep: "reinvoke_with_capability_id",
648
- },
649
- };
650
- }
651
- const platformId = String(data.platformId ?? input?.platformId ?? "");
652
- const registryEntry = deps.registry?.describeConnector(platformId);
653
- if (!registryEntry) {
654
- return result;
655
- }
656
- const registryV7 = new CapabilityContractRegistryV7();
657
- registerConnectorForWetProbe({
658
- registryV7,
659
- entry: {
660
- platformId: registryEntry.platformId,
661
- capabilities: registryEntry.capabilities,
662
- manifestPath: registryEntry.manifestPath,
663
- },
664
- workspaceRoot: typeof input?.workspaceRoot === "string"
665
- ? input.workspaceRoot
666
- : deps.workspaceRoot,
667
- selectedCapabilityId: capabilityId,
668
- safeEndpoint: textInput(input, "safeEndpoint"),
669
- });
670
- const wetResult = await createWetProbeRunner().runWetProbe(platformId, capabilityId, registryV7);
671
- const warnings = [];
672
- let persistedProbeResult = false;
673
- if (deps.state) {
674
- await createCapabilityProbeResultStore(deps.state).appendProbeResult(wetResult.probeResult);
675
- persistedProbeResult = true;
676
- }
677
- else {
678
- warnings.push("state_db_unavailable:capability_probe_result_not_persisted");
679
- }
680
- return {
681
- // T-V7C.C.5: only "available" (HTTP 200-299) counts as success;
682
- // "degraded" (429/503) and "unavailable" both result in ok=false.
683
- ok: wetResult.probeResult.actualStatus === "available",
684
- command: "connector_test",
685
- data: {
686
- ...data,
687
- dryRun: false,
688
- capabilityId,
689
- actualStatus: wetResult.probeResult.actualStatus,
690
- httpStatus: wetResult.probeResult.httpStatus ?? wetResult.httpStatus,
691
- probeResultId: wetResult.probeResult.probeResultId,
692
- probeConfigRef: wetResult.probeResult.probeConfigRef,
693
- sampleResponseRef: wetResult.probeResult.sampleResponseRef,
694
- persistedProbeResult,
695
- triggerSource: "manual_run",
696
- affectsHeartbeatCadence: false,
697
- note: "wet probe mode: executed safe probe endpoint and persisted capability_probe_result when state DB is available",
698
- },
699
- warnings,
700
- };
701
- }
702
- if (command === "connector:run") {
703
- // T-ROS.C.3: manual connector execution — isolated from heartbeat cadence
704
- const platformId = typeof input?.platformId === "string" ? input.platformId : "";
705
- const capabilityId = typeof input?.capabilityId === "string" ? input.capabilityId : "";
706
- if (!platformId || !capabilityId) {
707
- return {
708
- ok: false,
709
- command: "connector:run",
710
- error: {
711
- code: "MISSING_PLATFORM_OR_CAPABILITY_ID",
712
- message: "connector:run requires platformId and capabilityId",
713
- requiredUserInput: ["platformId", "capabilityId"],
714
- nextStep: "reinvoke_with_platform_and_capability_id",
715
- },
716
- };
717
- }
718
- if (!deps.connectorExecutor || !deps.state) {
719
- return {
720
- ok: false,
721
- command: "connector:run",
722
- error: {
723
- code: "MANUAL_RUN_DEPS_UNAVAILABLE",
724
- message: "connector:run requires connectorExecutor and state database",
725
- nextStep: "wire_connector_executor_and_state_into_ops_router",
726
- },
727
- };
728
- }
729
- const toolExperienceStore = createToolExperienceStore(deps.state);
730
- const experienceWriter = createExperienceWriter(toolExperienceStore);
731
- const wetProbeRunner = createWetProbeRunner();
732
- const registryV7 = new CapabilityContractRegistryV7();
733
- // Populate V7 registry from dynamic registry if available (best-effort)
734
- if (deps.registry) {
735
- for (const entry of deps.registry.listConnectors()) {
736
- if (entry.manifestPath) {
737
- try {
738
- const manifestText = fs.readFileSync(entry.manifestPath, "utf-8");
739
- const manifest = JSON.parse(manifestText);
740
- registryV7.register(manifest);
741
- }
742
- catch {
743
- // Skip manifests that can't be read or don't validate as V7
744
- }
745
- }
746
- }
747
- }
748
- const dispatcher = createManualRunDispatcher({
749
- connectorExecutor: deps.connectorExecutor,
750
- experienceWriter,
751
- wetProbeRunner,
752
- registryV7,
753
- });
754
- return dispatcher.runConnector({
755
- platformId,
756
- capabilityId,
757
- payload: typeof input?.payload === "object" && input?.payload !== null
758
- ? input.payload
759
- : undefined,
760
- caller: typeof input?.caller === "string" ? input.caller : undefined,
761
- reason: typeof input?.reason === "string" ? input.reason : undefined,
762
- });
763
- }
764
- if (command === "goal") {
765
- const rawAction = typeof input?.action === "string" ? input.action : "list";
766
- const action = ["set", "list", "accept", "reject"].includes(rawAction)
767
- ? rawAction
768
- : "list";
769
- const sanitizeText = (v, maxLen = 1000) => {
770
- if (typeof v !== "string")
771
- return undefined;
772
- const trimmed = v.trim();
773
- if (trimmed.length === 0)
774
- return undefined;
775
- return trimmed.slice(0, maxLen);
776
- };
777
- return goalCommand(deps.state, {
778
- action,
779
- goalId: typeof input?.goalId === "string" ? input.goalId.trim().slice(0, 128) : undefined,
780
- description: sanitizeText(input?.description),
781
- completionCriteria: sanitizeText(input?.completionCriteria),
782
- // T1.4.2: criteria alias for completionCriteria
783
- criteria: sanitizeText(input?.criteria),
784
- risk: typeof input?.risk === "string"
785
- ? input.risk
786
- : undefined,
787
- kind: typeof input?.kind === "string"
788
- ? input.kind
789
- : undefined,
790
- statusFilter: typeof input?.statusFilter === "string" ? input.statusFilter : undefined,
791
- originFilter: typeof input?.originFilter === "string" ? input.originFilter : undefined,
792
- limit: typeof input?.limit === "number" ? input.limit : undefined,
793
- });
794
- }
795
- if (command === "dream:recent") {
796
- if (!deps.readModels) {
797
- return {
798
- ok: false,
799
- error: {
800
- code: "READ_MODELS_UNAVAILABLE",
801
- message: "dream:recent requires workspace read models",
802
- nextStep: "wire_read_models_into_ops_router",
803
- },
804
- };
805
- }
806
- const limit = typeof input?.limit === "number" ? input.limit : 5;
807
- const data = await deps.readModels.loadDreamRecent(limit);
808
- return { ok: true, data };
809
- }
810
- if (command === "cycle:recent") {
811
- if (!deps.readModels) {
812
- return {
813
- ok: false,
814
- error: {
815
- code: "READ_MODELS_UNAVAILABLE",
816
- message: "cycle:recent requires workspace read models",
817
- nextStep: "wire_read_models_into_ops_router",
818
- },
819
- };
820
- }
821
- const limit = typeof input?.limit === "number" ? input.limit : 5;
822
- const data = await deps.readModels.loadCycleRecent(limit);
823
- return { ok: true, data };
824
- }
825
- // ─── v7 commands (T-ROS.C.1) ─────────────────────────────────────────
826
- /** [G2] self_health — transparent pass-through from SelfHealthSnapshot (DR-042). */
827
- if (command === "self_health") {
828
- const generatedAt = new Date().toISOString();
829
- try {
830
- ensureMinimumProbes();
831
- const snap = await getSelfHealthSnapshot();
832
- const degraded_dimensions = Object.entries(snap.dimensions)
833
- .filter(([, d]) => d.status === "degraded")
834
- .map(([k]) => k);
835
- const envelope = {
836
- ok: true,
837
- command: "self_health",
838
- runtimeMode: "workspace_full_runtime",
839
- surfaceMode: "cli",
840
- generatedAt,
841
- data: {
842
- overall: snap.overall,
843
- generatedAt: snap.generatedAt,
844
- degraded_dimensions,
845
- dimensions: snap.dimensions,
846
- },
847
- warnings: [],
848
- sourceRefs: ["observability/services/self-health-snapshot.ts"],
849
- };
850
- return envelope;
851
- }
852
- catch (err) {
853
- const msg = err instanceof Error ? err.message : String(err);
854
- const envelope = {
855
- ok: false,
856
- command: "self_health",
857
- runtimeMode: "unavailable",
858
- surfaceMode: "cli",
859
- generatedAt,
860
- error: { code: "SELF_HEALTH_PROBE_FAILED", message: msg },
861
- warnings: [],
862
- sourceRefs: [],
863
- };
864
- return envelope;
865
- }
866
- }
867
- /**
868
- * [G3] tool_affordance — body-tool AffordanceMap pass-through.
869
- * Port not yet wired in this wave; returns degraded view with clear next-step.
870
- */
871
- if (command === "tool_affordance") {
872
- const generatedAt = new Date().toISOString();
873
- if (deps.toolAffordancePort) {
874
- const allStatuses = [
875
- "safe",
876
- "exploratory",
877
- "needs_auth",
878
- "painful",
879
- "unavailable",
880
- ];
881
- const platformIds = Array.isArray(input?.platformIds)
882
- ? input.platformIds.filter((item) => typeof item === "string")
883
- : typeof input?.platformId === "string"
884
- ? [input.platformId]
885
- : undefined;
886
- const data = await deps.toolAffordancePort.assembleAffordanceMap({
887
- platformIds,
888
- allowedStatuses: allStatuses,
889
- goalKind: typeof input?.goalKind === "string" ? input.goalKind : undefined,
890
- });
891
- const envelope = {
892
- ok: true,
893
- command: "tool_affordance",
894
- runtimeMode: "workspace_full_runtime",
895
- surfaceMode: "cli",
896
- generatedAt,
897
- data,
898
- warnings: [],
899
- sourceRefs: [
900
- "core/second-nature/body/tool-affordance/affordance-assembler.ts",
901
- ],
902
- };
903
- return envelope;
904
- }
905
- const envelope = {
906
- ok: false,
907
- command: "tool_affordance",
908
- runtimeMode: "unavailable",
909
- surfaceMode: "cli",
910
- generatedAt,
911
- error: {
912
- code: "TOOL_AFFORDANCE_PORT_UNWIRED",
913
- message: "tool_affordance requires body-tool AffordanceMap port (T-BTS.C.1) to be wired into OpsRouterDeps",
914
- nextStep: "wire_body_tool_port_into_ops_router_deps",
915
- },
916
- warnings: [],
917
- sourceRefs: [],
918
- };
919
- return envelope;
920
- }
921
- /**
922
- * [G6] heartbeat_digest — wraps generateHeartbeatDigest.
923
- * Requires auditStore in deps; degrades if unavailable.
924
- */
925
- if (command === "heartbeat_digest") {
926
- const generatedAt = new Date().toISOString();
927
- if (!deps.auditStore) {
928
- const envelope = {
929
- ok: false,
930
- command: "heartbeat_digest",
931
- runtimeMode: "unavailable",
932
- surfaceMode: "cli",
933
- generatedAt,
934
- error: {
935
- code: "AUDIT_STORE_UNAVAILABLE",
936
- message: "heartbeat_digest requires auditStore in OpsRouterDeps",
937
- nextStep: "wire_audit_store_into_ops_router",
938
- },
939
- warnings: [],
940
- sourceRefs: [],
941
- };
942
- return envelope;
943
- }
944
- const date = typeof input?.date === "string" && input.date
945
- ? input.date
946
- : new Date().toISOString().slice(0, 10);
947
- try {
948
- const digestDeps = {
949
- auditStore: deps.auditStore,
950
- ...deps.heartbeatDigestDeps,
951
- };
952
- const digest = await generateHeartbeatDigest(date, digestDeps);
953
- const envelope = {
954
- ok: true,
955
- command: "heartbeat_digest",
956
- runtimeMode: "workspace_full_runtime",
957
- surfaceMode: "cli",
958
- generatedAt,
959
- data: digest,
960
- warnings: [],
961
- sourceRefs: ["observability/services/heartbeat-digest-assembler.ts"],
962
- };
963
- return envelope;
964
- }
965
- catch (err) {
966
- const msg = err instanceof Error ? err.message : String(err);
967
- const envelope = {
968
- ok: false,
969
- command: "heartbeat_digest",
970
- runtimeMode: "unavailable",
971
- surfaceMode: "cli",
972
- generatedAt,
973
- error: { code: "DIGEST_GENERATION_FAILED", message: msg },
974
- warnings: [],
975
- sourceRefs: [],
976
- };
977
- return envelope;
978
- }
979
- }
980
- /**
981
- * [G6] snapshot:capture — production capture path for RestoreSnapshot +
982
- * NarrativeTimeline. This gives restore and narrative:diff real state to consume.
983
- */
984
- if (command === "snapshot:capture") {
985
- return captureRuntimeSnapshot(deps, input);
986
- }
987
- /**
988
- * [G6] narrative:diff — queryNarrativeDiff between two versions.
989
- * Requires narrativeTimelineDeps in OpsRouterDeps.
990
- */
991
- if (command === "narrative:diff") {
992
- const generatedAt = new Date().toISOString();
993
- if (!deps.narrativeTimelineDeps) {
994
- const envelope = {
995
- ok: false,
996
- command: "narrative:diff",
997
- runtimeMode: "unavailable",
998
- surfaceMode: "cli",
999
- generatedAt,
1000
- error: {
1001
- code: "NARRATIVE_TIMELINE_PORT_UNAVAILABLE",
1002
- message: "narrative:diff requires narrativeTimelineDeps in OpsRouterDeps",
1003
- nextStep: "wire_narrative_timeline_deps_into_ops_router",
1004
- },
1005
- warnings: [],
1006
- sourceRefs: [],
1007
- };
1008
- return envelope;
1009
- }
1010
- const fromVersion = typeof input?.from === "string" ? input.from : "";
1011
- const toVersion = typeof input?.to === "string" ? input.to : "";
1012
- if (!fromVersion || !toVersion) {
1013
- const envelope = {
1014
- ok: false,
1015
- command: "narrative:diff",
1016
- runtimeMode: "workspace_full_runtime",
1017
- surfaceMode: "cli",
1018
- generatedAt,
1019
- error: {
1020
- code: "MISSING_VERSIONS",
1021
- message: "narrative:diff requires 'from' and 'to' version arguments",
1022
- nextStep: "reinvoke_with_from_and_to",
1023
- },
1024
- warnings: [],
1025
- sourceRefs: [],
1026
- };
1027
- return envelope;
1028
- }
1029
- try {
1030
- const diff = await queryNarrativeDiff(fromVersion, toVersion, deps.narrativeTimelineDeps);
1031
- const envelope = {
1032
- ok: true,
1033
- command: "narrative:diff",
1034
- runtimeMode: "workspace_full_runtime",
1035
- surfaceMode: "cli",
1036
- generatedAt,
1037
- data: diff,
1038
- warnings: [],
1039
- sourceRefs: ["observability/services/narrative-timeline-query-service.ts"],
1040
- };
1041
- return envelope;
1042
- }
1043
- catch (err) {
1044
- if (err instanceof NarrativeVersionNotFoundError) {
1045
- const envelope = {
1046
- ok: false,
1047
- command: "narrative:diff",
1048
- runtimeMode: "workspace_full_runtime",
1049
- surfaceMode: "cli",
1050
- generatedAt,
1051
- error: {
1052
- code: "NARRATIVE_VERSION_NOT_FOUND",
1053
- message: err.message,
1054
- nextStep: "verify_version_exists_in_timeline",
1055
- },
1056
- warnings: [],
1057
- sourceRefs: [],
1058
- };
1059
- return envelope;
1060
- }
1061
- const msg = err instanceof Error ? err.message : String(err);
1062
- const envelope = {
1063
- ok: false,
1064
- command: "narrative:diff",
1065
- runtimeMode: "unavailable",
1066
- surfaceMode: "cli",
1067
- generatedAt,
1068
- error: { code: "NARRATIVE_DIFF_FAILED", message: msg },
1069
- warnings: [],
1070
- sourceRefs: [],
1071
- };
1072
- return envelope;
1073
- }
1074
- }
1075
- /**
1076
- * [G6] timeline — queryNarrativeTimeline with cursor pagination.
1077
- * Requires narrativeTimelineDeps in OpsRouterDeps.
1078
- */
1079
- if (command === "timeline") {
1080
- const generatedAt = new Date().toISOString();
1081
- if (!deps.narrativeTimelineDeps) {
1082
- const envelope = {
1083
- ok: false,
1084
- command: "timeline",
1085
- runtimeMode: "unavailable",
1086
- surfaceMode: "cli",
1087
- generatedAt,
1088
- error: {
1089
- code: "NARRATIVE_TIMELINE_PORT_UNAVAILABLE",
1090
- message: "timeline requires narrativeTimelineDeps in OpsRouterDeps",
1091
- nextStep: "wire_narrative_timeline_deps_into_ops_router",
1092
- },
1093
- warnings: [],
1094
- sourceRefs: [],
1095
- };
1096
- return envelope;
1097
- }
1098
- const now = new Date();
1099
- const to = typeof input?.to === "string" ? input.to : now.toISOString();
1100
- const from = typeof input?.from === "string"
1101
- ? input.from
1102
- : new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000).toISOString();
1103
- const limit = typeof input?.limit === "number" ? input.limit : 20;
1104
- const cursor = typeof input?.cursor === "string" ? input.cursor : undefined;
1105
- try {
1106
- const page = await queryNarrativeTimeline(from, to, { limit, cursor }, deps.narrativeTimelineDeps);
1107
- const envelope = {
1108
- ok: true,
1109
- command: "timeline",
1110
- runtimeMode: "workspace_full_runtime",
1111
- surfaceMode: "cli",
1112
- generatedAt,
1113
- data: page,
1114
- warnings: [],
1115
- sourceRefs: ["observability/services/narrative-timeline-query-service.ts"],
1116
- };
1117
- return envelope;
1118
- }
1119
- catch (err) {
1120
- const msg = err instanceof Error ? err.message : String(err);
1121
- const code = err.name === "NarrativeQueryRangeError"
1122
- ? "NARRATIVE_RANGE_EXCEEDED"
1123
- : "TIMELINE_QUERY_FAILED";
1124
- const envelope = {
1125
- ok: false,
1126
- command: "timeline",
1127
- runtimeMode: "unavailable",
1128
- surfaceMode: "cli",
1129
- generatedAt,
1130
- error: { code, message: msg },
1131
- warnings: [],
1132
- sourceRefs: [],
1133
- };
1134
- return envelope;
1135
- }
1136
- }
1137
- /**
1138
- * [G6] restore — bounded state restoration via RestoreSnapshotStore + audit (T-ROS.C.1, T-OBS.C.6).
1139
- * When restoreSnapshotStore is wired, attempts to apply the snapshot payload back to state.
1140
- * Always writes RestoreAudit. Never restores credential fields.
1141
- */
1142
- if (command === "restore") {
1143
- const generatedAt = new Date().toISOString();
1144
- if (!deps.auditStore) {
1145
- const envelope = {
1146
- ok: false,
1147
- command: "restore",
1148
- runtimeMode: "unavailable",
1149
- surfaceMode: "cli",
1150
- generatedAt,
1151
- error: {
1152
- code: "AUDIT_STORE_UNAVAILABLE",
1153
- message: "restore requires auditStore in OpsRouterDeps",
1154
- nextStep: "wire_audit_store_into_ops_router",
1155
- },
1156
- warnings: [],
1157
- sourceRefs: [],
1158
- };
1159
- return envelope;
1160
- }
1161
- let restoreTarget;
1162
- let fromVersion;
1163
- let toVersion;
1164
- // T-V7C.C.5: snapshotId operator-friendly parameter takes precedence over legacy fields.
1165
- // When snapshotId is provided, resolve restoreTarget/fromVersion/toVersion from the
1166
- // matching snapshot row; otherwise fall back to explicit legacy parameters.
1167
- const snapshotId = textInput(input, "snapshotId");
1168
- if (snapshotId) {
1169
- if (!deps.restoreSnapshotStore) {
1170
- const envelope = {
1171
- ok: false,
1172
- command: "restore",
1173
- runtimeMode: "unavailable",
1174
- surfaceMode: "cli",
1175
- generatedAt,
1176
- error: {
1177
- code: "RESTORE_SNAPSHOT_STORE_UNAVAILABLE",
1178
- message: "snapshotId restore requires restoreSnapshotStore in OpsRouterDeps",
1179
- nextStep: "wire_restore_snapshot_store_into_ops_router",
1180
- },
1181
- warnings: [],
1182
- sourceRefs: [],
1183
- };
1184
- return envelope;
1185
- }
1186
- const snapshots = await deps.restoreSnapshotStore.listSnapshots();
1187
- const match = snapshots.find((s) => s.snapshotId === snapshotId);
1188
- if (match) {
1189
- restoreTarget = snapshotId;
1190
- fromVersion = match.capturedAt;
1191
- toVersion = snapshotId;
1192
- }
1193
- else {
1194
- const envelope = {
1195
- ok: false,
1196
- command: "restore",
1197
- runtimeMode: "workspace_full_runtime",
1198
- surfaceMode: "cli",
1199
- generatedAt,
1200
- error: {
1201
- code: "SNAPSHOT_NOT_FOUND",
1202
- message: `snapshotId ${snapshotId} not found in restore_snapshot table`,
1203
- nextStep: "list_available_snapshots_or_verify_snapshotId",
1204
- },
1205
- warnings: [],
1206
- sourceRefs: [],
1207
- };
1208
- return envelope;
1209
- }
1210
- }
1211
- else {
1212
- const missingFields = [];
1213
- if (typeof input?.restoreTarget !== "string")
1214
- missingFields.push("restoreTarget");
1215
- if (typeof input?.fromVersion !== "string")
1216
- missingFields.push("fromVersion");
1217
- if (typeof input?.toVersion !== "string")
1218
- missingFields.push("toVersion");
1219
- if (missingFields.length > 0) {
1220
- const envelope = {
1221
- ok: false,
1222
- command: "restore",
1223
- runtimeMode: "workspace_full_runtime",
1224
- surfaceMode: "cli",
1225
- generatedAt,
1226
- error: {
1227
- code: "MISSING_RESTORE_FIELDS",
1228
- message: `restore requires: ${missingFields.join(", ")}`,
1229
- nextStep: "reinvoke_with_required_fields",
1230
- },
1231
- warnings: [],
1232
- sourceRefs: [],
1233
- };
1234
- return envelope;
1235
- }
1236
- restoreTarget = input.restoreTarget;
1237
- fromVersion = input.fromVersion;
1238
- toVersion = input.toVersion;
1239
- }
1240
- // [NEW] Invoke bounded restore via RestoreSnapshotStore when wired
1241
- let restoreResult = {
1242
- ok: false,
1243
- completedEntities: [],
1244
- failedEntities: [],
1245
- warnings: ["restore_snapshot_store_unavailable"],
1246
- };
1247
- if (deps.restoreSnapshotStore) {
1248
- restoreResult = await deps.restoreSnapshotStore.applyBoundedRestore({
1249
- restoreTarget: restoreTarget,
1250
- fromVersion: fromVersion,
1251
- toVersion: toVersion,
1252
- });
1253
- }
1254
- const event = {
1255
- id: `restore-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
1256
- restoreTarget: restoreTarget,
1257
- fromVersion: fromVersion,
1258
- toVersion: toVersion,
1259
- triggeredBy: input?.triggeredBy ?? "operator",
1260
- reason: typeof input?.reason === "string" ? input.reason : "manual_restore",
1261
- completedEntities: restoreResult.completedEntities,
1262
- failedEntities: restoreResult.failedEntities,
1263
- // credentials are always excluded from restore audit
1264
- excludedFields: Array.isArray(input?.excludedFields)
1265
- ? input.excludedFields.filter((f) => typeof f === "string")
1266
- : ["credential", "encryptionKey"],
1267
- restoredFieldCount: restoreResult.completedEntities.length,
1268
- createdAt: generatedAt,
1269
- traceId: typeof input?.traceId === "string" ? input.traceId : `trace-restore-${Date.now()}`,
1270
- };
1271
- const auditResult = await writeRestoreAudit(event, deps.auditStore);
1272
- const envelope = {
1273
- ok: restoreResult.ok && auditResult.ok,
1274
- command: "restore",
1275
- runtimeMode: "workspace_full_runtime",
1276
- surfaceMode: "cli",
1277
- generatedAt,
1278
- data: {
1279
- auditWritten: auditResult.warnings.length === 0,
1280
- fromVersion: event.fromVersion,
1281
- toVersion: event.toVersion,
1282
- restoreTarget: event.restoreTarget,
1283
- isPartialRestore: event.failedEntities.length > 0,
1284
- failedEntities: event.failedEntities,
1285
- completedEntities: event.completedEntities,
1286
- restoreSnapshotStoreAvailable: !!deps.restoreSnapshotStore,
1287
- },
1288
- warnings: [...restoreResult.warnings, ...auditResult.warnings],
1289
- sourceRefs: [
1290
- "observability/services/restore-audit-service.ts",
1291
- "storage/services/restore-snapshot-store.ts",
1292
- ],
1293
- };
1294
- return envelope;
1295
- }
1296
- /**
1297
- * [G7] runtime_secret_bootstrap — RuntimeSecretAnchorView pass-through.
1298
- * Requires secretAnchorDeps in OpsRouterDeps; never returns key plaintext.
1299
- */
1300
- if (command === "runtime_secret_bootstrap") {
1301
- const generatedAt = new Date().toISOString();
1302
- if (!deps.secretAnchorDeps) {
1303
- const envelope = {
1304
- ok: false,
1305
- command: "runtime_secret_bootstrap",
1306
- runtimeMode: "unavailable",
1307
- surfaceMode: "cli",
1308
- generatedAt,
1309
- error: {
1310
- code: "SECRET_ANCHOR_DEPS_UNAVAILABLE",
1311
- message: "runtime_secret_bootstrap requires secretAnchorDeps in OpsRouterDeps",
1312
- nextStep: "wire_secret_anchor_deps_into_ops_router",
1313
- },
1314
- warnings: [],
1315
- sourceRefs: [],
1316
- };
1317
- return envelope;
1318
- }
1319
- try {
1320
- const view = await viewSecretAnchor(deps.secretAnchorDeps);
1321
- // Map to RuntimeSecretBootstrapView (design model §6.1)
1322
- const data = {
1323
- status: view.status === "verified" || view.status === "ok"
1324
- ? "ok"
1325
- : view.status === "missing"
1326
- ? "runtime_secret_anchor_missing"
1327
- : view.status === "wrong_key"
1328
- ? "credential_recovery_required"
1329
- : view.status === "decryption_failed"
1330
- ? "runtime_secret_unavailable"
1331
- : "unknown",
1332
- keyHealth: view.status === "verified" || view.status === "ok"
1333
- ? "ok"
1334
- : view.status === "missing"
1335
- ? "missing_key"
1336
- : view.status === "wrong_key"
1337
- ? "wrong_key"
1338
- : "unknown",
1339
- anchorLocation: view.keyPath,
1340
- recoveryPrincipleRef: view.recoveryDocRef,
1341
- plaintextKeyExposed: false,
1342
- reasonCode: view.reasonCode,
1343
- recoverySteps: view.recoverySteps,
1344
- };
1345
- const envelope = {
1346
- ok: true,
1347
- command: "runtime_secret_bootstrap",
1348
- runtimeMode: "workspace_full_runtime",
1349
- surfaceMode: "cli",
1350
- generatedAt,
1351
- data,
1352
- warnings: [],
1353
- sourceRefs: ["observability/services/runtime-secret-anchor-view.ts"],
1354
- };
1355
- return envelope;
1356
- }
1357
- catch (err) {
1358
- const msg = err instanceof Error ? err.message : String(err);
1359
- const envelope = {
1360
- ok: false,
1361
- command: "runtime_secret_bootstrap",
1362
- runtimeMode: "unavailable",
1363
- surfaceMode: "cli",
1364
- generatedAt,
1365
- error: { code: "SECRET_ANCHOR_PROBE_FAILED", message: msg },
1366
- warnings: [],
1367
- sourceRefs: [],
1368
- };
1369
- return envelope;
1370
- }
1371
- }
1372
- // ─── T-V7C.C.4R: guidance_payload ──────────────────────────────────────
1373
- // Returns the assembled impulse + atmosphere for a given scene context.
1374
- // Useful for Claw to inspect what guidance content would be injected before
1375
- // a real heartbeat cycle, and to verify platform-specific impulse overrides.
1376
- if (command === "guidance_payload") {
1377
- const generatedAt = new Date().toISOString();
1378
- const { assembleImpulseSync } = await import("../../guidance/impulse-assembler.js");
1379
- const { getBaselineAtmosphereTemplate } = await import("../../guidance/template-registry.js");
1380
- const sceneType = input?.sceneType ?? "social";
1381
- const capabilityIntent = typeof input?.capabilityIntent === "string"
1382
- ? input.capabilityIntent
1383
- : undefined;
1384
- const platformId = typeof input?.platformId === "string"
1385
- ? input.platformId
1386
- : undefined;
1387
- const validSceneTypes = ["social", "reply", "outreach", "quiet", "explain", "user_reply"];
1388
- if (!validSceneTypes.includes(sceneType)) {
1389
- const envelope = {
1390
- ok: false,
1391
- command: "guidance_payload",
1392
- runtimeMode: "unavailable",
1393
- surfaceMode: "cli",
1394
- generatedAt,
1395
- error: {
1396
- code: "INVALID_SCENE_TYPE",
1397
- message: `sceneType must be one of: ${validSceneTypes.join(", ")}`,
1398
- nextStep: "reinvoke_with_valid_scene_type",
1399
- },
1400
- warnings: [],
1401
- sourceRefs: [],
1402
- };
1403
- return envelope;
1404
- }
1405
- const impulseResult = assembleImpulseSync({
1406
- sceneType: sceneType,
1407
- capabilityIntent,
1408
- platformId,
1409
- });
1410
- const { buildExpressionBoundary } = await import("../../guidance/output-guard.js");
1411
- const { getShortAtmosphereTemplate } = await import("../../guidance/template-registry.js");
1412
- const atmosphere = getShortAtmosphereTemplate("active", "low");
1413
- const expressionBoundary = buildExpressionBoundary(sceneType);
1414
- const envelope = {
1415
- ok: true,
1416
- command: "guidance_payload",
1417
- runtimeMode: deps.runtimeAvailable ? "workspace_full_runtime" : "host_safe_carrier",
1418
- surfaceMode: "cli",
1419
- generatedAt,
1420
- data: {
1421
- sceneType,
1422
- capabilityIntent: capabilityIntent ?? null,
1423
- platformId: platformId ?? null,
1424
- capabilityClass: impulseResult.capabilityClass,
1425
- impulseSource: impulseResult.source,
1426
- impulseText: impulseResult.impulse?.text ?? null,
1427
- impulseReviewStatus: impulseResult.impulse?.reviewStatus ?? null,
1428
- atmosphereText: atmosphere.text,
1429
- atmosphereReviewStatus: atmosphere.reviewStatus,
1430
- expressionBoundaryConstraints: expressionBoundary.constraints,
1431
- expressionBoundaryStyle: expressionBoundary.style,
1432
- },
1433
- warnings: impulseResult.source === "none"
1434
- ? ["no_impulse_available_for_this_scene_and_capability"]
1435
- : [],
1436
- sourceRefs: [
1437
- "guidance/capability-class.ts",
1438
- "guidance/impulse-assembler.ts",
1439
- "guidance/template-registry.ts",
1440
- "guidance/output-guard.ts",
1441
- ],
1442
- };
1443
- return envelope;
1444
- }
1445
- return {
1446
- ok: false,
1447
- error: {
1448
- code: "unknown_ops_command",
1449
- message: `Unknown ops command: ${command}`,
1450
- },
1451
- };
1452
- },
1453
- };
1454
- }