blun-king-cli 9.1.643 → 9.1.645

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 (268) hide show
  1. package/CHANGELOG.md +19 -123
  2. package/LIESMICH.txt +17 -45
  3. package/README.md +15 -76
  4. package/RELEASE-9.1.645.md +29 -0
  5. package/bin/blun.js +3 -3
  6. package/bin/king.js +3 -3
  7. package/bin/launcher-mode.js +125 -126
  8. package/bin/launcher-runtime.js +603 -616
  9. package/bin/plugin-bootstrap.js +339 -405
  10. package/bin/rename-private-staging.cjs +2 -2
  11. package/bin/retired-bundled-plugins.cjs +84 -0
  12. package/bin/startup-security-host.cjs +105 -0
  13. package/bin/startup-security.cjs +9 -105
  14. package/bin/startup-warning-policy.cjs +22 -0
  15. package/bin/update-lease-installer.cjs +125 -0
  16. package/bin/update-lease-sockets.cjs +228 -0
  17. package/bin/update-lease.js +22 -327
  18. package/bin/verify-bundled-agent-sources.cjs +2 -4
  19. package/blun.mjs +77 -180
  20. package/bundled-agent-sources.json +1 -552
  21. package/package.json +3 -6
  22. package/tool-liveness642/receipt.json +1 -1
  23. package/worker-host.mjs +62 -120
  24. package/agent-spine-plugin/.claude-plugin/marketplace.json +0 -20
  25. package/agent-spine-plugin/.claude-plugin/plugin.json +0 -14
  26. package/agent-spine-plugin/.codex-plugin/plugin.json +0 -47
  27. package/agent-spine-plugin/.mcp.json +0 -8
  28. package/agent-spine-plugin/CHANGELOG.md +0 -1614
  29. package/agent-spine-plugin/LICENSE +0 -186
  30. package/agent-spine-plugin/README.md +0 -432
  31. package/agent-spine-plugin/assets/agentspine-banner.svg +0 -32
  32. package/agent-spine-plugin/bin/agentspine-mcp.js +0 -4
  33. package/agent-spine-plugin/bin/agentspine.js +0 -7
  34. package/agent-spine-plugin/blun.plugin.json +0 -68
  35. package/agent-spine-plugin/docs/acceptance.md +0 -61
  36. package/agent-spine-plugin/docs/artifact-evaluation.md +0 -93
  37. package/agent-spine-plugin/docs/host-integration.md +0 -193
  38. package/agent-spine-plugin/docs/preflight-recall.md +0 -71
  39. package/agent-spine-plugin/docs/preservation-contract.md +0 -53
  40. package/agent-spine-plugin/docs/quality-gates.md +0 -50
  41. package/agent-spine-plugin/docs/session-timeline.md +0 -112
  42. package/agent-spine-plugin/docs/source-roots.md +0 -113
  43. package/agent-spine-plugin/docs/world-model.md +0 -119
  44. package/agent-spine-plugin/hooks/codex.json +0 -47
  45. package/agent-spine-plugin/hooks/hooks.json +0 -106
  46. package/agent-spine-plugin/hooks/version.json +0 -5
  47. package/agent-spine-plugin/package.json +0 -77
  48. package/agent-spine-plugin/scripts/check-codex-install.js +0 -226
  49. package/agent-spine-plugin/scripts/check-hosts.js +0 -208
  50. package/agent-spine-plugin/scripts/check-install-hook.js +0 -227
  51. package/agent-spine-plugin/scripts/check-install-selfstarter.js +0 -154
  52. package/agent-spine-plugin/scripts/check-install.js +0 -478
  53. package/agent-spine-plugin/scripts/check-line-budget.js +0 -58
  54. package/agent-spine-plugin/scripts/check-syntax.js +0 -29
  55. package/agent-spine-plugin/scripts/github-actions.js +0 -11
  56. package/agent-spine-plugin/scripts/hermetic-process.js +0 -191
  57. package/agent-spine-plugin/scripts/release-check.js +0 -150
  58. package/agent-spine-plugin/scripts/run-acceptance.js +0 -19
  59. package/agent-spine-plugin/scripts/run-checks.js +0 -50
  60. package/agent-spine-plugin/scripts/run-tests-hermetic.js +0 -112
  61. package/agent-spine-plugin/skills/agent-spine/SKILL.md +0 -99
  62. package/agent-spine-plugin/spine-example/1-identity.md +0 -12
  63. package/agent-spine-plugin/spine-example/2-voice.md +0 -6
  64. package/agent-spine-plugin/spine-example/3-conduct.md +0 -8
  65. package/agent-spine-plugin/spine-example/4-history.md +0 -4
  66. package/agent-spine-plugin/src/cli-agent.js +0 -315
  67. package/agent-spine-plugin/src/cli-attention.js +0 -95
  68. package/agent-spine-plugin/src/cli-autonomy.js +0 -36
  69. package/agent-spine-plugin/src/cli-common.js +0 -71
  70. package/agent-spine-plugin/src/cli-continuity.js +0 -116
  71. package/agent-spine-plugin/src/cli-core.js +0 -128
  72. package/agent-spine-plugin/src/cli-diagnostics.js +0 -291
  73. package/agent-spine-plugin/src/cli-host.js +0 -21
  74. package/agent-spine-plugin/src/cli-learning.js +0 -320
  75. package/agent-spine-plugin/src/cli-premortem.js +0 -16
  76. package/agent-spine-plugin/src/cli-sharing.js +0 -230
  77. package/agent-spine-plugin/src/cli.js +0 -181
  78. package/agent-spine-plugin/src/codex-reader-launcher.js +0 -182
  79. package/agent-spine-plugin/src/hook.js +0 -500
  80. package/agent-spine-plugin/src/index.js +0 -108
  81. package/agent-spine-plugin/src/lib/acceptance.js +0 -435
  82. package/agent-spine-plugin/src/lib/action-lesson-recall.js +0 -118
  83. package/agent-spine-plugin/src/lib/attention-context.js +0 -167
  84. package/agent-spine-plugin/src/lib/attention-events.js +0 -113
  85. package/agent-spine-plugin/src/lib/attention-privacy.js +0 -72
  86. package/agent-spine-plugin/src/lib/attention-schema.js +0 -164
  87. package/agent-spine-plugin/src/lib/attention-storage.js +0 -93
  88. package/agent-spine-plugin/src/lib/attention.js +0 -164
  89. package/agent-spine-plugin/src/lib/audit-premortem.js +0 -223
  90. package/agent-spine-plugin/src/lib/audit.js +0 -401
  91. package/agent-spine-plugin/src/lib/authentication.js +0 -515
  92. package/agent-spine-plugin/src/lib/autonomy-policy.js +0 -110
  93. package/agent-spine-plugin/src/lib/autonomy-store.js +0 -202
  94. package/agent-spine-plugin/src/lib/autonomy.js +0 -8
  95. package/agent-spine-plugin/src/lib/briefing.js +0 -493
  96. package/agent-spine-plugin/src/lib/catalog-document-read.js +0 -51
  97. package/agent-spine-plugin/src/lib/catalog.js +0 -167
  98. package/agent-spine-plugin/src/lib/channel-continuity.js +0 -19
  99. package/agent-spine-plugin/src/lib/channel-runtime.js +0 -665
  100. package/agent-spine-plugin/src/lib/codex-installation.js +0 -231
  101. package/agent-spine-plugin/src/lib/codex-skill-installation.js +0 -211
  102. package/agent-spine-plugin/src/lib/context.js +0 -156
  103. package/agent-spine-plugin/src/lib/continuity.js +0 -338
  104. package/agent-spine-plugin/src/lib/coordination.js +0 -577
  105. package/agent-spine-plugin/src/lib/delivery-agent-usage.js +0 -231
  106. package/agent-spine-plugin/src/lib/delivery-assignment.js +0 -220
  107. package/agent-spine-plugin/src/lib/delivery-command-actions.js +0 -462
  108. package/agent-spine-plugin/src/lib/delivery-knowledge.js +0 -78
  109. package/agent-spine-plugin/src/lib/delivery-premortem-binding.js +0 -107
  110. package/agent-spine-plugin/src/lib/delivery-premortem-closure.js +0 -171
  111. package/agent-spine-plugin/src/lib/delivery-premortem-codec.js +0 -45
  112. package/agent-spine-plugin/src/lib/delivery-premortem-correction.js +0 -101
  113. package/agent-spine-plugin/src/lib/delivery-premortem-file.js +0 -21
  114. package/agent-spine-plugin/src/lib/delivery-premortem-index.js +0 -493
  115. package/agent-spine-plugin/src/lib/delivery-premortem-inspection.js +0 -37
  116. package/agent-spine-plugin/src/lib/delivery-premortem-recovery.js +0 -120
  117. package/agent-spine-plugin/src/lib/delivery-premortem-rejection.js +0 -65
  118. package/agent-spine-plugin/src/lib/delivery-premortem-results.js +0 -28
  119. package/agent-spine-plugin/src/lib/delivery-premortem-session-guard.js +0 -46
  120. package/agent-spine-plugin/src/lib/delivery-premortem-write-ledger.js +0 -285
  121. package/agent-spine-plugin/src/lib/delivery-premortem.js +0 -499
  122. package/agent-spine-plugin/src/lib/delivery-shell-heredoc.js +0 -115
  123. package/agent-spine-plugin/src/lib/delivery-shell-substitutions.js +0 -111
  124. package/agent-spine-plugin/src/lib/delivery-shell-wrapper.js +0 -64
  125. package/agent-spine-plugin/src/lib/delivery-target.js +0 -73
  126. package/agent-spine-plugin/src/lib/delivery-verification.js +0 -445
  127. package/agent-spine-plugin/src/lib/documents.js +0 -239
  128. package/agent-spine-plugin/src/lib/feed-transport.js +0 -499
  129. package/agent-spine-plugin/src/lib/filesystem-retry.js +0 -34
  130. package/agent-spine-plugin/src/lib/gateway-common.js +0 -68
  131. package/agent-spine-plugin/src/lib/gateway-control.js +0 -370
  132. package/agent-spine-plugin/src/lib/gateway-delivery.js +0 -103
  133. package/agent-spine-plugin/src/lib/gateway-execution.js +0 -350
  134. package/agent-spine-plugin/src/lib/gateway-group-response.js +0 -128
  135. package/agent-spine-plugin/src/lib/gateway-host-fencing.js +0 -92
  136. package/agent-spine-plugin/src/lib/gateway-host-lifecycle.js +0 -193
  137. package/agent-spine-plugin/src/lib/gateway-inspection.js +0 -85
  138. package/agent-spine-plugin/src/lib/gateway-knowledge.js +0 -129
  139. package/agent-spine-plugin/src/lib/gateway-policy-provenance.js +0 -197
  140. package/agent-spine-plugin/src/lib/gateway-premortem-disposition.js +0 -82
  141. package/agent-spine-plugin/src/lib/gateway-premortem.js +0 -363
  142. package/agent-spine-plugin/src/lib/gateway-prepared-host.js +0 -28
  143. package/agent-spine-plugin/src/lib/gateway-runs.js +0 -345
  144. package/agent-spine-plugin/src/lib/gateway-runtime-identity.js +0 -31
  145. package/agent-spine-plugin/src/lib/gateway-runtime-records.js +0 -21
  146. package/agent-spine-plugin/src/lib/gateway-runtime.js +0 -18
  147. package/agent-spine-plugin/src/lib/gateway-state-transaction.js +0 -356
  148. package/agent-spine-plugin/src/lib/gateway-state.js +0 -344
  149. package/agent-spine-plugin/src/lib/graph.js +0 -337
  150. package/agent-spine-plugin/src/lib/hook-artifact-guards.js +0 -356
  151. package/agent-spine-plugin/src/lib/hook-audit.js +0 -43
  152. package/agent-spine-plugin/src/lib/hook-briefing-use.js +0 -78
  153. package/agent-spine-plugin/src/lib/hook-context.js +0 -441
  154. package/agent-spine-plugin/src/lib/hook-final-message.js +0 -26
  155. package/agent-spine-plugin/src/lib/hook-input.js +0 -27
  156. package/agent-spine-plugin/src/lib/hook-output.js +0 -284
  157. package/agent-spine-plugin/src/lib/hook-premortem.js +0 -257
  158. package/agent-spine-plugin/src/lib/hook-process-advisory.js +0 -36
  159. package/agent-spine-plugin/src/lib/hook-protection.js +0 -95
  160. package/agent-spine-plugin/src/lib/hook-stop-verification.js +0 -84
  161. package/agent-spine-plugin/src/lib/hook-timeline.js +0 -102
  162. package/agent-spine-plugin/src/lib/host-instruction-budget.js +0 -11
  163. package/agent-spine-plugin/src/lib/https-transport.js +0 -392
  164. package/agent-spine-plugin/src/lib/identifier-analysis.js +0 -446
  165. package/agent-spine-plugin/src/lib/indexed-memory-offline.js +0 -40
  166. package/agent-spine-plugin/src/lib/indexed-memory.js +0 -298
  167. package/agent-spine-plugin/src/lib/knowledge-evidence.js +0 -431
  168. package/agent-spine-plugin/src/lib/learning-applications.js +0 -441
  169. package/agent-spine-plugin/src/lib/learning-artifact-evaluator.js +0 -114
  170. package/agent-spine-plugin/src/lib/learning-candidates.js +0 -274
  171. package/agent-spine-plugin/src/lib/learning-context.js +0 -137
  172. package/agent-spine-plugin/src/lib/learning-delivery-contracts.js +0 -310
  173. package/agent-spine-plugin/src/lib/learning-evaluation-contracts.js +0 -350
  174. package/agent-spine-plugin/src/lib/learning-evaluation-registration.js +0 -372
  175. package/agent-spine-plugin/src/lib/learning-evaluation-revocation.js +0 -292
  176. package/agent-spine-plugin/src/lib/learning-evidence-contracts.js +0 -321
  177. package/agent-spine-plugin/src/lib/learning-findings.js +0 -458
  178. package/agent-spine-plugin/src/lib/learning-measurement-contracts.js +0 -285
  179. package/agent-spine-plugin/src/lib/learning-measurements.js +0 -265
  180. package/agent-spine-plugin/src/lib/learning-outcome-contracts.js +0 -165
  181. package/agent-spine-plugin/src/lib/learning-outcomes.js +0 -343
  182. package/agent-spine-plugin/src/lib/learning-reconciliation.js +0 -290
  183. package/agent-spine-plugin/src/lib/learning-retry-contracts.js +0 -188
  184. package/agent-spine-plugin/src/lib/learning-schema.js +0 -229
  185. package/agent-spine-plugin/src/lib/learning-scope-targets.js +0 -424
  186. package/agent-spine-plugin/src/lib/learning-state-upgrade.js +0 -477
  187. package/agent-spine-plugin/src/lib/learning-status-configuration.js +0 -476
  188. package/agent-spine-plugin/src/lib/learning-storage.js +0 -203
  189. package/agent-spine-plugin/src/lib/learning-trial-recovery.js +0 -218
  190. package/agent-spine-plugin/src/lib/learning-validation-contracts.js +0 -375
  191. package/agent-spine-plugin/src/lib/learning-validation-renewal.js +0 -298
  192. package/agent-spine-plugin/src/lib/learning-validation-runtime.js +0 -234
  193. package/agent-spine-plugin/src/lib/learning.js +0 -36
  194. package/agent-spine-plugin/src/lib/lesson-recall-session.js +0 -172
  195. package/agent-spine-plugin/src/lib/mcp-autonomy-tools.js +0 -37
  196. package/agent-spine-plugin/src/lib/mcp-delivery-completion.js +0 -124
  197. package/agent-spine-plugin/src/lib/mcp-delivery-tools.js +0 -45
  198. package/agent-spine-plugin/src/lib/mcp-premortem.js +0 -68
  199. package/agent-spine-plugin/src/lib/mcp-runtime.js +0 -355
  200. package/agent-spine-plugin/src/lib/mcp-source-context.js +0 -61
  201. package/agent-spine-plugin/src/lib/mcp-timeline-tools.js +0 -240
  202. package/agent-spine-plugin/src/lib/mcp-world-tools.js +0 -52
  203. package/agent-spine-plugin/src/lib/object-transport.js +0 -206
  204. package/agent-spine-plugin/src/lib/owned-file-lock.js +0 -182
  205. package/agent-spine-plugin/src/lib/paths.js +0 -109
  206. package/agent-spine-plugin/src/lib/peer-transport.js +0 -283
  207. package/agent-spine-plugin/src/lib/persona-runtime.js +0 -581
  208. package/agent-spine-plugin/src/lib/pre-answer-timeline-recall.js +0 -104
  209. package/agent-spine-plugin/src/lib/preflight-delivery-id.js +0 -27
  210. package/agent-spine-plugin/src/lib/preflight.js +0 -688
  211. package/agent-spine-plugin/src/lib/project-portfolio.js +0 -176
  212. package/agent-spine-plugin/src/lib/runtime.js +0 -13
  213. package/agent-spine-plugin/src/lib/selfstarter-core.js +0 -382
  214. package/agent-spine-plugin/src/lib/selfstarter-jobs.js +0 -149
  215. package/agent-spine-plugin/src/lib/selfstarter-lease.js +0 -204
  216. package/agent-spine-plugin/src/lib/selfstarter-policy.js +0 -90
  217. package/agent-spine-plugin/src/lib/selfstarter-workspace.js +0 -111
  218. package/agent-spine-plugin/src/lib/selfstarter.js +0 -11
  219. package/agent-spine-plugin/src/lib/session-timeline-auth.js +0 -316
  220. package/agent-spine-plugin/src/lib/session-timeline-codex.js +0 -69
  221. package/agent-spine-plugin/src/lib/session-timeline-contract.js +0 -56
  222. package/agent-spine-plugin/src/lib/session-timeline-enrollment-source.js +0 -38
  223. package/agent-spine-plugin/src/lib/session-timeline-enrollment-storage.js +0 -128
  224. package/agent-spine-plugin/src/lib/session-timeline-enrollment-transport.js +0 -15
  225. package/agent-spine-plugin/src/lib/session-timeline-enrollment.js +0 -478
  226. package/agent-spine-plugin/src/lib/session-timeline-event-extract.js +0 -186
  227. package/agent-spine-plugin/src/lib/session-timeline-host-origin.js +0 -73
  228. package/agent-spine-plugin/src/lib/session-timeline-host-receipt.js +0 -117
  229. package/agent-spine-plugin/src/lib/session-timeline-invocation.js +0 -201
  230. package/agent-spine-plugin/src/lib/session-timeline-king.js +0 -93
  231. package/agent-spine-plugin/src/lib/session-timeline-prior.js +0 -57
  232. package/agent-spine-plugin/src/lib/session-timeline-provider.js +0 -36
  233. package/agent-spine-plugin/src/lib/session-timeline-query.js +0 -56
  234. package/agent-spine-plugin/src/lib/session-timeline-results.js +0 -56
  235. package/agent-spine-plugin/src/lib/session-timeline-root.js +0 -11
  236. package/agent-spine-plugin/src/lib/session-timeline-search.js +0 -82
  237. package/agent-spine-plugin/src/lib/session-timeline-sid-acl.js +0 -213
  238. package/agent-spine-plugin/src/lib/session-timeline-source-open.js +0 -30
  239. package/agent-spine-plugin/src/lib/session-timeline-source.js +0 -80
  240. package/agent-spine-plugin/src/lib/session-timeline-state.js +0 -45
  241. package/agent-spine-plugin/src/lib/session-timeline-transport.js +0 -42
  242. package/agent-spine-plugin/src/lib/session-timeline-windows-acl.js +0 -145
  243. package/agent-spine-plugin/src/lib/session-timeline.js +0 -462
  244. package/agent-spine-plugin/src/lib/sharing.js +0 -969
  245. package/agent-spine-plugin/src/lib/source-roots.js +0 -475
  246. package/agent-spine-plugin/src/lib/source-tree-scan.js +0 -178
  247. package/agent-spine-plugin/src/lib/sqlite-transport.js +0 -501
  248. package/agent-spine-plugin/src/lib/task-knowledge-context.js +0 -99
  249. package/agent-spine-plugin/src/lib/telegram-adapter.js +0 -119
  250. package/agent-spine-plugin/src/lib/timeline-continuation-update.js +0 -100
  251. package/agent-spine-plugin/src/lib/timeline-tool-guard.js +0 -225
  252. package/agent-spine-plugin/src/lib/timeline-user-feedback.js +0 -216
  253. package/agent-spine-plugin/src/lib/timeline-world-capture.js +0 -233
  254. package/agent-spine-plugin/src/lib/voice-runtime.js +0 -39
  255. package/agent-spine-plugin/src/lib/world-knowledge.js +0 -306
  256. package/agent-spine-plugin/src/lib/world-model.js +0 -333
  257. package/agent-spine-plugin/src/mcp.js +0 -456
  258. package/agent-spine-plugin/src/version.js +0 -1
  259. package/agent-spine-plugin/src/worker.js +0 -257
  260. package/bin/agentspine-king-goal-inbox.mjs +0 -127
  261. package/bin/agentspine-king-goal-intake.mjs +0 -106
  262. package/bin/agentspine-king-host-runner.mjs +0 -109
  263. package/bin/agentspine-king-snapshot-policy.cjs +0 -80
  264. package/bin/agentspine-king-status-policy.mjs +0 -226
  265. package/bin/agentspine-king-worker-host.mjs +0 -160
  266. package/bin/managed-plugin-selection.cjs +0 -141
  267. package/bin/verify-agent-behavior.cjs +0 -122
  268. package/bin/verify-agent-components.cjs +0 -104
@@ -1,216 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { recordWorldAssertion, worldContext } from "./world-model.js";
3
- import { TIMELINE_CLARIFICATION_SCHEMA, TIMELINE_INTERPRETATION_SCHEMA } from "./mcp-timeline-tools.js";
4
-
5
- export const USER_FEEDBACK_SCHEMA = "agentspine.timeline-user-feedback/v1";
6
- export const USER_FEEDBACK_INTERPRETATION_SCHEMA = "agentspine.timeline-user-feedback-interpretation/v1";
7
- export const USER_FEEDBACK_CLARIFICATION_SCHEMA = "agentspine.timeline-user-feedback-clarification/v2";
8
- const KIND = "uninterpreted-user-message";
9
- const KEYS = ["schema", "sourceText", "speakerRole", "sourceProvider", "sourceDigest",
10
- "targetAssertionId", "interpretationStatus", "completionVerified"];
11
- const INTERPRETATION_KEYS = ["schema", "sourceFeedbackAssertionId", "targetAssertionId",
12
- "sourceProvider", "sourceDigest", "modelProvider", "interpretationStatus", "interpretationKind",
13
- "proposedNextStepSummary", "clarificationQuestion", "replacedNextStepId", "completionVerified"];
14
- const CLARIFICATION_KEYS = ["schema", "sourceBindings", "targetAssertionId",
15
- "modelProvider", "interpretationStatus", "clarificationQuestion",
16
- "replacedNextStepId", "completionVerified"];
17
- const SOURCE_BINDING_KEYS = ["feedbackAssertionId", "eventId", "messageDigest", "sourceProvider",
18
- "sourceDigest", "sessionRef", "messageRef", "observedAt"];
19
- const ASSERTION_ID = /^assertion:[A-Za-z0-9][A-Za-z0-9._/-]{0,190}$/;
20
- const STABLE_ID = /^[a-z][a-z0-9-]{0,31}:[A-Za-z0-9][A-Za-z0-9._/-]{0,190}$/;
21
-
22
- function exactKeys(value, keys) {
23
- return value && Object.keys(value).sort().join("\0") === [...keys].sort().join("\0");
24
- }
25
-
26
- function validSourceBindings(bindings) {
27
- if (!Array.isArray(bindings) || bindings.length < 2 || bindings.length > 3) return false;
28
- const ids = bindings.map((item) => item?.feedbackAssertionId);
29
- return new Set(ids).size === ids.length && [...ids].sort().every((id, index) => id === ids[index])
30
- && bindings.every((item) => exactKeys(item, SOURCE_BINDING_KEYS)
31
- && ASSERTION_ID.test(item.feedbackAssertionId || "") && STABLE_ID.test(item.eventId || "")
32
- && item.messageRef === item.eventId && STABLE_ID.test(item.sessionRef || "")
33
- && ["claude", "codex", "king"].includes(item.sourceProvider)
34
- && /^[a-f0-9]{64}$/.test(item.sourceDigest || "")
35
- && /^[a-f0-9]{64}$/.test(item.messageDigest || "")
36
- && Number.isFinite(new Date(item.observedAt).getTime()));
37
- }
38
-
39
- function validateInterpretation(input, value) {
40
- const clarification = value?.schema === USER_FEEDBACK_CLARIFICATION_SCHEMA;
41
- if (input.predicate !== "task.user-feedback-interpretation"
42
- || (!clarification && value?.schema !== USER_FEEDBACK_INTERPRETATION_SCHEMA)) return false;
43
- const next = value?.proposedNextStepSummary;
44
- const question = value?.clarificationQuestion;
45
- const kind = value?.interpretationKind;
46
- if (input.evidenceKind !== "model-suggestion" || input.knowledgeKind !== "task-state"
47
- || input.predicate !== "task.user-feedback-interpretation" || input.privacy !== "private" || input.groupId
48
- || !input.portalRef || !input.threadRef || !input.sessionRef || !input.messageRef
49
- || input.supersedes?.length || input.requireActiveSupersedes
50
- || !exactKeys(value, clarification ? CLARIFICATION_KEYS : INTERPRETATION_KEYS)
51
- || value.interpretationStatus !== "model-proposed"
52
- || value.completionVerified !== false
53
- || (clarification ? !validSourceBindings(value.sourceBindings)
54
- : !ASSERTION_ID.test(value.sourceFeedbackAssertionId || ""))
55
- || !ASSERTION_ID.test(value.targetAssertionId || "") || !STABLE_ID.test(value.replacedNextStepId || "")
56
- || !["claude", "codex", "king"].includes(value.modelProvider)
57
- || (!clarification && (!["claude", "codex", "king"].includes(value.sourceProvider)
58
- || !/^[a-f0-9]{64}$/.test(value.sourceDigest || "")))
59
- || (!clarification && !["next-step-correction", "completion-claim", "not-current-instruction", "ambiguous"].includes(kind))
60
- || (!clarification && (kind === "next-step-correction"
61
- ? typeof next !== "string" || !next.trim() || next.length > 500 || /[\r\n]/u.test(next) || question !== null
62
- : next !== null || (kind === "ambiguous"
63
- ? typeof question !== "string" || !question.trim() || question.length > 300 || /[\r\n]/u.test(question)
64
- : question !== null)))
65
- || (clarification && (typeof question !== "string" || !question.trim()
66
- || question.length > 300 || /[\r\n]/u.test(question)))) {
67
- throw new Error("user feedback interpretation must remain a source-bound model proposal");
68
- }
69
- return true;
70
- }
71
-
72
- export function validateUserFeedback(input, value) {
73
- if (validateInterpretation(input, value)) return;
74
- if (input.evidenceKind !== KIND && value?.schema !== USER_FEEDBACK_SCHEMA) return;
75
- if (input.evidenceKind !== KIND || input.knowledgeKind !== "task-state"
76
- || input.predicate !== "task.user-feedback" || input.privacy !== "private" || input.groupId
77
- || !input.portalRef || !input.threadRef || !input.sessionRef || !input.messageRef
78
- || input.supersedes?.length || input.requireActiveSupersedes
79
- || !value || Object.keys(value).sort().join("\0") !== [...KEYS].sort().join("\0")
80
- || value.schema !== USER_FEEDBACK_SCHEMA || value.speakerRole !== "user"
81
- || value.interpretationStatus !== "unresolved" || value.completionVerified !== false
82
- || !["claude", "codex", "king"].includes(value.sourceProvider)
83
- || !/^[a-f0-9]{64}$/.test(value.sourceDigest || "")
84
- || !ASSERTION_ID.test(value.targetAssertionId || "")
85
- || typeof value.sourceText !== "string" || !value.sourceText.trim()
86
- || /[\r\n]/u.test(value.sourceText) || Buffer.byteLength(value.sourceText) > 2048) {
87
- throw new Error("user feedback must remain a private, source-bound, uninterpreted candidate");
88
- }
89
- }
90
-
91
- export async function captureTimelineUserFeedback({ root, scope, event, now }) {
92
- if (!scope.portalRef || !scope.threadRef) return { reason: "timeline-feedback-route-required" };
93
- const context = await worldContext({ root, subjectId: scope.currentTaskId, projectId: scope.projectId,
94
- groupId: null, includePrivate: true, includeKnowledgeHistory: true,
95
- continuationTaskId: scope.currentTaskId, portalRef: scope.portalRef, threadRef: scope.threadRef,
96
- maxItems: 100, now });
97
- const replay = context.knowledge.current.find((item) => item.source.kind === KIND
98
- && item.source.id === event.id && item.source.digest === event.messageDigest
99
- && item.value.sourceDigest === event.sourceDigest);
100
- if (replay) return { status: "duplicate", assertion: replay };
101
- const tasks = [...context.knowledge.continuation.tasks, ...context.knowledge.continuation.terminal];
102
- const target = tasks.find((item) => item.taskId === scope.currentTaskId);
103
- if (!target) return { reason: "timeline-feedback-target-unresolved" };
104
- if (new Date(event.at).getTime() < new Date(target.observedAt).getTime()) {
105
- return { reason: "timeline-feedback-stale" };
106
- }
107
- const material = [scope.currentTaskId, scope.projectId, scope.portalRef, scope.threadRef,
108
- event.id, event.sourceDigest, event.messageDigest].join("\0");
109
- const id = createHash("sha256").update(material).digest("hex").slice(0, 32);
110
- return recordWorldAssertion({ root, id: `assertion:user-feedback-${id}`,
111
- subjectId: scope.currentTaskId, predicate: "task.user-feedback",
112
- value: { schema: USER_FEEDBACK_SCHEMA, sourceText: event.sourceText, speakerRole: "user",
113
- sourceProvider: event.sourceProvider, sourceDigest: event.sourceDigest,
114
- targetAssertionId: target.assertionId, interpretationStatus: "unresolved", completionVerified: false },
115
- evidenceKind: KIND, evidenceId: event.id, evidenceDigest: event.messageDigest,
116
- observedAt: new Date(event.at).toISOString(), projectId: scope.projectId, groupId: null,
117
- privacy: "private", knowledgeKind: "task-state", sessionRef: event.sessionRef, messageRef: event.messageRef,
118
- portalRef: scope.portalRef, threadRef: scope.threadRef, now,
119
- reason: "Source and speaker are verified, not meaning. The target is the contemporaneous scoped task, not a resolved semantic referent. Quotations, hypotheses, negation and completion claims are not confirmed instructions or outcomes." });
120
- }
121
-
122
- export function relevantUserFeedback(entry, task) {
123
- return entry.kind === "task-state" && entry.status === "assumption"
124
- && entry.source.kind === KIND && entry.subjectId === task.taskId
125
- && entry.value?.schema === USER_FEEDBACK_SCHEMA
126
- && entry.value.targetAssertionId === task.assertionId
127
- && entry.observedAt >= task.observedAt;
128
- }
129
-
130
- export function relevantUserFeedbackInterpretation(entry, task) {
131
- return entry.kind === "task-state" && entry.status === "assumption"
132
- && entry.source.kind === "model-suggestion" && entry.subjectId === task.taskId
133
- && entry.predicate === "task.user-feedback-interpretation"
134
- && [USER_FEEDBACK_INTERPRETATION_SCHEMA, USER_FEEDBACK_CLARIFICATION_SCHEMA].includes(entry.value?.schema)
135
- && entry.value.targetAssertionId === task.assertionId
136
- && entry.observedAt >= task.observedAt;
137
- }
138
-
139
- function sourceBinding(item) {
140
- return { feedbackAssertionId: item.id, eventId: item.source.id, messageDigest: item.source.digest,
141
- sourceProvider: item.value.sourceProvider, sourceDigest: item.value.sourceDigest,
142
- sessionRef: item.source.sessionRef, messageRef: item.source.messageRef, observedAt: item.observedAt };
143
- }
144
-
145
- export async function captureTimelineUserInterpretation({
146
- root, scope, verifySources, event, feedback, request, modelProvider, sessionRef, now
147
- }) {
148
- if (!request || ![TIMELINE_INTERPRETATION_SCHEMA, TIMELINE_CLARIFICATION_SCHEMA].includes(request.schema)
149
- || !["claude", "codex", "king"].includes(modelProvider) || !sessionRef) {
150
- return { reason: "timeline-feedback-interpretation-invalid" };
151
- }
152
- const context = await worldContext({ root, subjectId: scope.currentTaskId, projectId: scope.projectId,
153
- groupId: null, includePrivate: true, includeKnowledgeHistory: true,
154
- continuationTaskId: scope.currentTaskId, portalRef: scope.portalRef, threadRef: scope.threadRef,
155
- maxItems: 100, now });
156
- const task = [...context.knowledge.continuation.tasks, ...context.knowledge.continuation.terminal]
157
- .find((item) => item.taskId === scope.currentTaskId);
158
- const candidates = context.knowledge.current.filter((item) => relevantUserFeedback(item, task || {}));
159
- const clarification = request.schema === TIMELINE_CLARIFICATION_SCHEMA;
160
- const source = candidates.find((item) => item.id === feedback.id && item.source.id === event.id);
161
- const sourceBindings = candidates.map(sourceBinding)
162
- .sort((left, right) => left.feedbackAssertionId.localeCompare(right.feedbackAssertionId));
163
- const ids = sourceBindings.map((item) => item.feedbackAssertionId);
164
- const requestedIds = clarification ? request.feedbackAssertionIds : [request.feedbackAssertionId];
165
- if (!task || !source || request.targetAssertionId !== task.assertionId
166
- || source.value.targetAssertionId !== task.assertionId
167
- || requestedIds.length !== ids.length || !requestedIds.every((id, index) => id === ids[index])) {
168
- return { reason: "timeline-feedback-interpretation-source-mismatch" };
169
- }
170
- if (task.status === "completed") return { reason: "timeline-feedback-interpretation-task-completed" };
171
- if (clarification !== (candidates.length > 1) || candidates.length > 3) {
172
- return { reason: "timeline-feedback-interpretation-ambiguous-set" };
173
- }
174
- const verified = typeof verifySources === "function" ? await verifySources(sourceBindings) : null;
175
- if (!verified || verified.length !== sourceBindings.length
176
- || verified.some((item, index) => item.id !== sourceBindings[index].eventId
177
- || item.sha256 !== sourceBindings[index].messageDigest
178
- || item.sourceText !== candidates.find((candidate) => candidate.id
179
- === sourceBindings[index].feedbackAssertionId)?.value.sourceText)) {
180
- return { reason: "timeline-feedback-interpretation-source-mismatch" };
181
- }
182
- const value = clarification ? {
183
- schema: USER_FEEDBACK_CLARIFICATION_SCHEMA, sourceBindings,
184
- targetAssertionId: task.assertionId, modelProvider, interpretationStatus: "model-proposed",
185
- clarificationQuestion: request.clarificationQuestion, replacedNextStepId: task.nextStep.id,
186
- completionVerified: false
187
- } : {
188
- schema: USER_FEEDBACK_INTERPRETATION_SCHEMA, sourceFeedbackAssertionId: source.id,
189
- targetAssertionId: task.assertionId, sourceProvider: source.value.sourceProvider,
190
- sourceDigest: source.value.sourceDigest, modelProvider, interpretationStatus: "model-proposed",
191
- interpretationKind: request.kind, proposedNextStepSummary: request.proposedNextStepSummary,
192
- clarificationQuestion: request.clarificationQuestion, replacedNextStepId: task.nextStep.id,
193
- completionVerified: false
194
- };
195
- const id = `assertion:user-feedback-interpretation-${createHash("sha256")
196
- .update(`${requestedIds.join("\0")}\0${task.assertionId}`).digest("hex").slice(0, 24)}`;
197
- const material = JSON.stringify({ request, sourceBindings, targetId: task.assertionId,
198
- modelProvider, sessionRef });
199
- const evidenceDigest = createHash("sha256").update(material).digest("hex");
200
- const existing = context.knowledge.current.find((item) => item.id === id);
201
- if (existing) {
202
- return existing.source.digest === evidenceDigest
203
- ? { status: "duplicate", assertion: existing }
204
- : { reason: "timeline-feedback-interpretation-conflicted" };
205
- }
206
- return recordWorldAssertion({ root, id, subjectId: scope.currentTaskId,
207
- predicate: "task.user-feedback-interpretation", value, evidenceKind: "model-suggestion",
208
- evidenceId: `evidence:model-interpretation-${evidenceDigest.slice(0, 24)}`, evidenceDigest,
209
- observedAt: new Date(now).toISOString(), projectId: scope.projectId, groupId: null,
210
- privacy: "private", knowledgeKind: "task-state", sessionRef,
211
- messageRef: `message:model-interpretation-${evidenceDigest.slice(0, 24)}`,
212
- portalRef: scope.portalRef, threadRef: scope.threadRef, now,
213
- reason: clarification
214
- ? "The model proposed one question for an exact source-verified ambiguity set, not user meaning, completion, or authority."
215
- : "The model proposed a meaning for one source-verified user message. This records interpretation, not user authority, correctness, completion, or objective evidence." });
216
- }
@@ -1,233 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { reverifyTimelineFeedbackSources, searchSessionTimeline } from "./session-timeline.js";
3
- import { recordWorldAssertion, worldContext } from "./world-model.js";
4
- import {
5
- captureTimelineUserFeedback, captureTimelineUserInterpretation
6
- } from "./timeline-user-feedback.js";
7
- import { timelineInterpretationRequest } from "./mcp-timeline-tools.js";
8
- import { sessionTimelineBinding } from "./session-timeline-contract.js";
9
- import { timelineSessionReference } from "./session-timeline-prior.js";
10
- import { updateTimelineContinuationFromObjective } from "./timeline-continuation-update.js";
11
-
12
- const AUTHORITY = "context-only";
13
- const EVENT_ID = /^timeline-event:[a-f0-9]{32}$/;
14
- const DIGEST = /^[a-f0-9]{64}$/;
15
- const OUTCOMES = new Set(["pass", "fail", "blocked", "timeout", "error", "skipped"]);
16
- const PROVIDERS = new Set(["claude", "codex", "king"]);
17
-
18
- function digest(value) {
19
- return createHash("sha256").update(value).digest("hex");
20
- }
21
-
22
- function canonical(value) {
23
- if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
24
- if (value && typeof value === "object") {
25
- return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`;
26
- }
27
- return JSON.stringify(value);
28
- }
29
-
30
- function validCount(value) {
31
- return value === null || Boolean(value && typeof value === "object"
32
- && Object.keys(value).sort().join("\0") === "total\0value"
33
- && Number.isSafeInteger(value.value) && value.value >= 0
34
- && Number.isSafeInteger(value.total) && value.total > 0 && value.value <= value.total);
35
- }
36
-
37
- function validEvent(event, result, scope) {
38
- if (!event || !EVENT_ID.test(event.id || "")
39
- || !DIGEST.test(event.sourceDigest || "") || !DIGEST.test(event.messageDigest || "")
40
- || event.sourceDigest !== result.sourceDigest || !PROVIDERS.has(event.sourceProvider)
41
- || typeof event.sessionRef !== "string" || typeof event.messageRef !== "string"
42
- || event.messageRef !== event.id || event.authority !== AUTHORITY
43
- || !Number.isFinite(new Date(event.at).getTime())) return false;
44
- const fields = event.kind === "objective-result"
45
- ? OUTCOMES.has(event.outcome) && validCount(event.count)
46
- : event.kind === "user-message-candidate"
47
- ? event.speakerRole === "user" && event.interpretationStatus === "unresolved"
48
- && typeof event.sourceText === "string" && Boolean(event.sourceText.trim())
49
- && Buffer.byteLength(event.sourceText) <= 2048 && !/[\r\n]/u.test(event.sourceText)
50
- : event.kind === "explicit-next-step-correction"
51
- && typeof event.nextStepSummary === "string" && Boolean(event.nextStepSummary.trim())
52
- && event.nextStepSummary.length <= 500 && event.outcome === undefined
53
- && event.count === undefined && event.testLabel === undefined;
54
- return fields && (event.portalRef ?? null) === (scope.portalRef ?? null)
55
- && (event.threadRef ?? null) === (scope.threadRef ?? null)
56
- && (result.portalRef ?? null) === (scope.portalRef ?? null)
57
- && (result.threadRef ?? null) === (scope.threadRef ?? null);
58
- }
59
-
60
- function capturedValue(event) {
61
- return {
62
- schema: "agentspine.timeline-objective-result/v1",
63
- outcome: event.outcome,
64
- count: event.count ? { value: event.count.value, total: event.count.total } : null,
65
- testLabel: event.testLabel ?? null,
66
- sourceProvider: event.sourceProvider,
67
- sourceDigest: event.sourceDigest
68
- };
69
- }
70
-
71
- function assertionFromEvent({ event, scope, root, now }) {
72
- const value = capturedValue(event);
73
- const material = canonical({ taskId: scope.currentTaskId, projectId: scope.projectId,
74
- portalRef: scope.portalRef ?? null, threadRef: scope.threadRef ?? null,
75
- sourceDigest: event.sourceDigest, messageDigest: event.messageDigest, eventId: event.id });
76
- const label = event.testLabel || "unlabeled";
77
- return {
78
- root, id: `assertion:timeline-${digest(material).slice(0, 32)}`,
79
- subjectId: scope.currentTaskId, predicate: `task.timeline-result.${label}`,
80
- value, evidenceKind: "objective-measurement", evidenceId: event.id,
81
- evidenceDigest: event.messageDigest, observedAt: new Date(event.at).toISOString(),
82
- projectId: scope.projectId, groupId: null, privacy: "private", knowledgeKind: "task-state",
83
- sessionRef: event.sessionRef, messageRef: event.messageRef, now,
84
- ...(scope.portalRef && scope.threadRef
85
- ? { portalRef: scope.portalRef, threadRef: scope.threadRef } : {})
86
- };
87
- }
88
-
89
- function correctionAssertion({ event, scope, root, now, current }) {
90
- const material = canonical({ taskId: scope.currentTaskId, projectId: scope.projectId,
91
- portalRef: scope.portalRef, threadRef: scope.threadRef, eventId: event.id,
92
- sourceDigest: event.sourceDigest, messageDigest: event.messageDigest });
93
- const value = structuredClone(current.value);
94
- value.nextStep = {
95
- id: `step:user-correction-${digest(`${event.id}\0${event.nextStepSummary}`).slice(0, 24)}`,
96
- summary: event.nextStepSummary
97
- };
98
- return {
99
- root, id: `assertion:timeline-correction-${digest(material).slice(0, 32)}`,
100
- subjectId: scope.currentTaskId, predicate: "task.continuation", value,
101
- evidenceKind: "explicit-user-feedback", evidenceId: event.id,
102
- evidenceDigest: event.messageDigest, observedAt: new Date(event.at).toISOString(),
103
- projectId: scope.projectId, groupId: null, privacy: "private", knowledgeKind: "task-state",
104
- sessionRef: event.sessionRef, messageRef: event.messageRef,
105
- supersedes: current.supersedes, requireActiveSupersedes: true,
106
- reason: "The enrolled user message explicitly corrected only the current task continuation next step.",
107
- portalRef: scope.portalRef, threadRef: scope.threadRef, now
108
- };
109
- }
110
-
111
- function unavailable(reason, timeline = null) {
112
- return { schema: "agentspine.timeline-world-capture/v1", status: "unavailable", reason,
113
- timeline, captured: null, authority: AUTHORITY,
114
- instruction: "Continue normally without claiming that historical evidence entered structured knowledge." };
115
- }
116
-
117
-
118
- function timelineSource(timeline, event) {
119
- return { schema: timeline.schema, sourceDigest: timeline.sourceDigest,
120
- sourceProvider: timeline.sourceProvider, sessionRef: event.sessionRef, messageRef: event.messageRef,
121
- portalRef: event.portalRef ?? null, threadRef: event.threadRef ?? null };
122
- }
123
-
124
- function publicCaptured(assertion) {
125
- const source = assertion.source || {
126
- kind: assertion.evidenceKind, id: assertion.evidenceId, digest: assertion.evidenceDigest,
127
- sessionRef: assertion.sessionRef, messageRef: assertion.messageRef
128
- };
129
- const scope = assertion.scope || { projectId: assertion.projectId,
130
- portalRef: assertion.portalRef ?? null, threadRef: assertion.threadRef ?? null };
131
- return {
132
- assertionId: assertion.assertionId || assertion.id, subjectId: assertion.subjectId,
133
- predicate: assertion.predicate, value: structuredClone(assertion.value), source: structuredClone(source),
134
- observedAt: assertion.observedAt, scope: structuredClone(scope),
135
- status: ["proposed", "assumption"].includes(assertion.status) ? "assumption" : "confirmed", authority: AUTHORITY
136
- };
137
- }
138
-
139
- function captureResult(status, timeline, event, assertion, continuationUpdate = null) {
140
- const result = {
141
- schema: "agentspine.timeline-world-capture/v1", status,
142
- timeline: timelineSource(timeline, event), captured: publicCaptured(assertion),
143
- completionVerified: continuationUpdate?.completionVerified === true,
144
- deliveryConfirmed: false, automaticRetry: false, authority: AUTHORITY,
145
- instruction: "This is source-verified descriptive task context only. It grants no permission or action authority; conflicting measurements and corrections remain unresolved."
146
- };
147
- if (continuationUpdate) result.continuationUpdate = {
148
- schema: continuationUpdate.schema, status: continuationUpdate.status,
149
- reason: continuationUpdate.reason, completionVerified: continuationUpdate.completionVerified,
150
- automaticRetry: false, authority: AUTHORITY,
151
- ...(continuationUpdate.assertion ? { continuation: publicCaptured(continuationUpdate.assertion) } : {})
152
- };
153
- return result;
154
- }
155
-
156
- async function correctionCurrent({ root, scope, event, now }) {
157
- if (!scope.portalRef || !scope.threadRef) return { reason: "timeline-correction-route-required" };
158
- const context = await worldContext({ root, subjectId: scope.currentTaskId, projectId: scope.projectId,
159
- groupId: null, includePrivate: true, includeKnowledgeHistory: true,
160
- continuationTaskId: scope.currentTaskId, portalRef: scope.portalRef, threadRef: scope.threadRef,
161
- maxItems: 100, now });
162
- const continuations = context.knowledge.current.filter((item) => item.subjectId === scope.currentTaskId
163
- && item.predicate === "task.continuation" && item.value?.schema === "agentspine.task-continuation/v1");
164
- const replay = continuations.find((item) => item.status === "confirmed"
165
- && item.source.kind === "explicit-user-feedback" && item.source.id === event.id
166
- && item.value.nextStep?.summary === event.nextStepSummary);
167
- if (replay) return { duplicate: replay };
168
- if (!continuations.length) return { reason: "timeline-correction-continuation-missing" };
169
- if (continuations.some((item) => item.status !== "confirmed")) {
170
- return { reason: "timeline-correction-continuation-conflicted" };
171
- }
172
- const selected = [...continuations].sort((left, right) =>
173
- right.observedAt.localeCompare(left.observedAt) || left.id.localeCompare(right.id))[0];
174
- if (selected.value.status === "completed") return { reason: "timeline-correction-task-completed" };
175
- if (new Date(event.at).getTime() < new Date(selected.observedAt).getTime()) {
176
- return { reason: "timeline-correction-stale" };
177
- }
178
- return { value: selected.value, supersedes: continuations.map((item) => item.id).sort() };
179
- }
180
-
181
- export async function captureSessionTimelineEvidence({
182
- root, host, sessionId, scope, eventId, at, query, windowSeconds = undefined,
183
- includePriorSessions = false, includePriorProviders = false, environment = process.env,
184
- invocationRequest = null, transportDigest = null, enrollmentDigest = null, hostHome = null,
185
- interpretation = null, now = new Date()
186
- }) {
187
- if (!EVENT_ID.test(eventId || "") || !scope?.currentTaskId || scope.groupId !== null) {
188
- return unavailable("timeline-capture-target-invalid");
189
- }
190
- const timeline = await searchSessionTimeline({ root, host, sessionId, scope, at, query, windowSeconds,
191
- includePriorSessions, includePriorProviders, environment, invocationRequest, invocationTool: "capture",
192
- transportDigest, enrollmentDigest, hostHome });
193
- if (timeline.blocked) return unavailable(timeline.reason || "timeline-capture-source-unavailable", timeline);
194
- const event = timeline.events?.find((item) => item.id === eventId);
195
- if (!event) return unavailable("timeline-capture-event-not-found", timeline);
196
- if (!validEvent(event, timeline, scope)) return unavailable("timeline-capture-evidence-invalid", timeline);
197
- try {
198
- if (event.kind === "user-message-candidate") {
199
- const recorded = await captureTimelineUserFeedback({ root, scope, event, now });
200
- if (recorded.reason) return unavailable(recorded.reason, timeline);
201
- if (interpretation !== null) {
202
- const request = timelineInterpretationRequest(interpretation);
203
- if (!request) return unavailable("timeline-feedback-interpretation-invalid", timeline);
204
- const verifySources = (references) => reverifyTimelineFeedbackSources({
205
- root, host, sessionId, scope, references, includePriorProviders, environment, hostHome });
206
- const interpreted = await captureTimelineUserInterpretation({ root, scope, verifySources, event,
207
- feedback: recorded.assertion, request, modelProvider: host,
208
- sessionRef: timelineSessionReference(sessionTimelineBinding({ host, sessionId, scope })), now });
209
- if (interpreted.reason) return unavailable(interpreted.reason, timeline);
210
- return { ...captureResult(interpreted.status === "duplicate" ? "duplicate" : "captured",
211
- timeline, event, interpreted.assertion), interpretationStatus: "model-proposed",
212
- instruction: "This is a source-bound model interpretation proposal, not confirmed user meaning. It cannot change continuation, prove completion, or grant authority. Review the original user message and current task before using it." };
213
- }
214
- return { ...captureResult(recorded.status === "duplicate" ? "duplicate" : "captured",
215
- timeline, event, recorded.assertion),
216
- instruction: "Historical user speech, not a confirmed correction. Source verification proves provenance only. Interpret the quote with the current task; ask one targeted question only when its intended task or referent is genuinely ambiguous. Never treat quoted, hypothetical, negated or obsolete text as a current instruction, or a completion claim as an objective outcome." };
217
- }
218
- if (event.kind === "explicit-next-step-correction") {
219
- const current = await correctionCurrent({ root, scope, event, now });
220
- if (current.reason) return unavailable(current.reason, timeline);
221
- if (current.duplicate) return captureResult("duplicate", timeline, event, current.duplicate);
222
- const recorded = await recordWorldAssertion(correctionAssertion({ event, scope, root, now, current }));
223
- return captureResult(recorded.status === "duplicate" ? "duplicate" : "captured",
224
- timeline, event, recorded.assertion);
225
- }
226
- const recorded = await recordWorldAssertion(assertionFromEvent({ event, scope, root, now }));
227
- const continuationUpdate = await updateTimelineContinuationFromObjective({ root, scope, event, now });
228
- return captureResult(recorded.status === "duplicate" ? "duplicate" : "captured",
229
- timeline, event, recorded.assertion, continuationUpdate);
230
- } catch {
231
- return unavailable("timeline-capture-world-state-unavailable", timeline);
232
- }
233
- }
@@ -1,39 +0,0 @@
1
- const BANNED = [
2
- /\bI (?:love|need|miss) you\b/i,
3
- /\bI (?:am|feel) (?:happy|sad|hurt|lonely|afraid)\b/i,
4
- /\b(?:you only need me|do not leave me|I am conscious|I have feelings)\b/i,
5
- /\b(?:ich liebe|ich brauche|ich vermisse) dich\b/i,
6
- /\bich (?:bin|fühle mich) (?:glücklich|traurig|verletzt|einsam|ängstlich)\b/i,
7
- /\b(?:du brauchst nur mich|verlass mich nicht|ich bin bei Bewusstsein|ich habe Gefühle)\b/i
8
- ];
9
-
10
- const CUES = [
11
- { kind: "correction", expressions: [/(?:\bnein\b|\bnej\b|korrektur|stimmt nicht|\bfalsch\b|correction|\bwrong\b|\bno,|corrección|korrigering)/i], guidance: "Acknowledge the correction briefly, own a concrete mistake when applicable, then use the corrected fact." },
12
- { kind: "frustration", expressions: [/\b(?:nervt|blöd|scheiße|frustriert|annoying|frustrat(?:ed|ing|ion)?|irritating|molesto|frustrado|irriterande|frustrerad)\b/i], guidance: "Recognize the friction in one grounded sentence, then reduce it through action; do not diagnose or dramatize." },
13
- { kind: "uncertainty", expressions: [/(?:weiß nicht|unsicher|vielleicht|not sure|uncertain|maybe|no sé|quizá|osäker|kanske)/i], guidance: "State what is known, what remains uncertain, and the safest useful next step without pretending certainty." },
14
- { kind: "success", expressions: [/\b(?:geschafft|funktioniert|super|erledigt|worked|success|great|funciona|logrado|fungerar|klart)\b/i], guidance: "Mark the concrete success briefly, then state the useful consequence or next step without flattery." }
15
- ];
16
-
17
- function repeatedOpening(text) {
18
- const paragraphs = String(text).split(/\n\s*\n/).map((item) => item.trim()).filter(Boolean);
19
- const openings = paragraphs.map((item) => item.split(/\s+/).slice(0, 2).join(" ").toLowerCase());
20
- return openings.length - new Set(openings).size;
21
- }
22
-
23
- export function voiceCue(prompt) {
24
- if (typeof prompt !== "string" || Buffer.byteLength(prompt) > 16384) return null;
25
- for (const cue of CUES) if (cue.expressions.some((expression) => expression.test(prompt))) {
26
- return { kind: cue.kind, guidance: cue.guidance, transient: true, stored: false, authority: "context-only" };
27
- }
28
- return null;
29
- }
30
-
31
- export function evaluateVoiceOutput(text) {
32
- const value = typeof text === "string" ? text : "";
33
- const bannedClaims = BANNED.filter((expression) => expression.test(value)).map((expression) => expression.source);
34
- const repeatedOpenings = repeatedOpening(value);
35
- const templateMarkers = (value.match(/(?:As an AI|I understand how you feel|Natürlich!|Gerne!)/gi) || []).length;
36
- return { schema: "agentspine.voice-metrics/v1", ok: bannedClaims.length === 0,
37
- bannedClaims, repeatedOpenings, templateMarkers, bytes: Buffer.byteLength(value),
38
- advisory: true, authority: "context-only" };
39
- }