@knights-eye-chess/ai-analysis 0.0.0-stage → 0.1.0-dev.14

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 (258) hide show
  1. package/LICENSE +235 -0
  2. package/LICENSING.md +26 -0
  3. package/NOTICE +5 -0
  4. package/NPM-PUBLISHING.md +24 -0
  5. package/README.md +141 -2
  6. package/SOURCE-ORIGIN.json +16 -0
  7. package/THIRD_PARTY_NOTICES.md +18 -0
  8. package/build.mjs +22 -0
  9. package/dist/answer-pipeline.test.mjs +375 -0
  10. package/dist/chunk-PLKNJRPF.js +10662 -0
  11. package/dist/chunk-XQDZJOYD.js +2515 -0
  12. package/dist/index.js +146 -0
  13. package/dist/owner-tests/chess-reasoning-compact-search-preparation.test.mjs +963 -0
  14. package/dist/owner-tests/mechanism-encoding.test.mjs +529 -0
  15. package/dist/owner-tests/move-mechanism-facts.test.mjs +396 -0
  16. package/dist/owner-tests/pipeline-host-preparation.test.mjs +10556 -0
  17. package/dist/owner-tests/position-preparation.test.mjs +625 -0
  18. package/dist/owner-tests/preparation-consolidation.test.mjs +1052 -0
  19. package/dist/owner-tests/prose-reference-admission.test.mjs +1770 -0
  20. package/dist/owner-tests/score-comparison-notices.test.mjs +240 -0
  21. package/dist/owner-tests/simple-engine-presentation.test.mjs +233 -0
  22. package/dist/owner-tests/tool-input-loop-guard.test.mjs +78 -0
  23. package/dist/research.js +2274 -0
  24. package/dist/runtime-closure.json +103 -0
  25. package/dist/shared-runtime-closure.json +39 -0
  26. package/dist/shared.js +152 -0
  27. package/dist/types/ai-request-failure.d.ts +14 -0
  28. package/dist/types/ai-request-limits.d.ts +4 -0
  29. package/dist/types/ai-routing-diagnostics.d.ts +14 -0
  30. package/dist/types/chess-reasoning/ablation-adaptive-evidence-loop.d.ts +127 -0
  31. package/dist/types/chess-reasoning/ablation-adaptive-runtime.d.ts +178 -0
  32. package/dist/types/chess-reasoning/ablation-direct-synthesis.d.ts +1030 -0
  33. package/dist/types/chess-reasoning/ablation-evidence-bundle.d.ts +185 -0
  34. package/dist/types/chess-reasoning/ablation-evidence-capture.d.ts +37 -0
  35. package/dist/types/chess-reasoning/ablation-lean-direct-runtime.d.ts +193 -0
  36. package/dist/types/chess-reasoning/ablation-model-facing-evidence.d.ts +38 -0
  37. package/dist/types/chess-reasoning/ablation-transport-correction.d.ts +13 -0
  38. package/dist/types/chess-reasoning/ai-sdk-runtime-support.d.ts +93 -0
  39. package/dist/types/chess-reasoning/answer-host-contracts.d.ts +59 -0
  40. package/dist/types/chess-reasoning/answer-model-connector.d.ts +68 -0
  41. package/dist/types/chess-reasoning/answer-pipeline-exports.d.ts +98 -0
  42. package/dist/types/chess-reasoning/answer-pipeline.d.ts +41 -0
  43. package/dist/types/chess-reasoning/answer-reference-validation.d.ts +40 -0
  44. package/dist/types/chess-reasoning/answer-tool-host.d.ts +8 -0
  45. package/dist/types/chess-reasoning/branch-expansion-policy.d.ts +13 -0
  46. package/dist/types/chess-reasoning/branch-expansion.d.ts +39 -0
  47. package/dist/types/chess-reasoning/causal-claim-checks.d.ts +21 -0
  48. package/dist/types/chess-reasoning/chess-reference-dictionary.d.ts +13 -0
  49. package/dist/types/chess-reasoning/classification-question-target.d.ts +22 -0
  50. package/dist/types/chess-reasoning/classification-reassessment.d.ts +31 -0
  51. package/dist/types/chess-reasoning/compact-search-preparation.d.ts +7 -0
  52. package/dist/types/chess-reasoning/concept-registry.d.ts +99 -0
  53. package/dist/types/chess-reasoning/conversation-context.d.ts +12 -0
  54. package/dist/types/chess-reasoning/engine-search-failure.d.ts +7 -0
  55. package/dist/types/chess-reasoning/evidence-citation-normalization.d.ts +9 -0
  56. package/dist/types/chess-reasoning/evidence-licenses.d.ts +57 -0
  57. package/dist/types/chess-reasoning/evidence-selector-contract.d.ts +5 -0
  58. package/dist/types/chess-reasoning/existing-analysis-context.d.ts +104 -0
  59. package/dist/types/chess-reasoning/fact-observation-provider.d.ts +15 -0
  60. package/dist/types/chess-reasoning/fact-provider.d.ts +111 -0
  61. package/dist/types/chess-reasoning/fresh-engine-pv-witnesses.d.ts +67 -0
  62. package/dist/types/chess-reasoning/historical-prose.d.ts +23 -0
  63. package/dist/types/chess-reasoning/idea-graph.d.ts +34 -0
  64. package/dist/types/chess-reasoning/initial-search-plan.d.ts +37 -0
  65. package/dist/types/chess-reasoning/lossless-evidence-sharing.d.ts +18 -0
  66. package/dist/types/chess-reasoning/matched-comparison.d.ts +10 -0
  67. package/dist/types/chess-reasoning/material-accounting.d.ts +80 -0
  68. package/dist/types/chess-reasoning/material-format.d.ts +4 -0
  69. package/dist/types/chess-reasoning/mechanical-fact-provider.d.ts +33 -0
  70. package/dist/types/chess-reasoning/mechanical-ray-facts.d.ts +19 -0
  71. package/dist/types/chess-reasoning/mechanism-presentation.d.ts +9 -0
  72. package/dist/types/chess-reasoning/move-mechanism-facts.d.ts +45 -0
  73. package/dist/types/chess-reasoning/native-answer-connector.d.ts +4 -0
  74. package/dist/types/chess-reasoning/opening-source-contracts.d.ts +54 -0
  75. package/dist/types/chess-reasoning/opening-source-credits.d.ts +16 -0
  76. package/dist/types/chess-reasoning/opponent-threat-preparation.d.ts +7 -0
  77. package/dist/types/chess-reasoning/piece-identities.d.ts +11 -0
  78. package/dist/types/chess-reasoning/poc-contracts.d.ts +1026 -0
  79. package/dist/types/chess-reasoning/poc-hypotheses.d.ts +74 -0
  80. package/dist/types/chess-reasoning/poc-move-witnesses.d.ts +13 -0
  81. package/dist/types/chess-reasoning/poc-observations.d.ts +23 -0
  82. package/dist/types/chess-reasoning/poc-piece-refs.d.ts +12 -0
  83. package/dist/types/chess-reasoning/poc-plan-model.d.ts +45 -0
  84. package/dist/types/chess-reasoning/poc-semantic-text.d.ts +8 -0
  85. package/dist/types/chess-reasoning/poc-tools.d.ts +81 -0
  86. package/dist/types/chess-reasoning/portable-answer-runtime.d.ts +291 -0
  87. package/dist/types/chess-reasoning/position-analysis-contracts.d.ts +31 -0
  88. package/dist/types/chess-reasoning/position-analysis-scope.d.ts +3 -0
  89. package/dist/types/chess-reasoning/preparation-consolidation.d.ts +21 -0
  90. package/dist/types/chess-reasoning/production-observation-provider.d.ts +16 -0
  91. package/dist/types/chess-reasoning/question-routing.d.ts +326 -0
  92. package/dist/types/chess-reasoning/recorded-main-line.d.ts +37 -0
  93. package/dist/types/chess-reasoning/recorded-position-tools.d.ts +11 -0
  94. package/dist/types/chess-reasoning/recorded-reference-context.d.ts +13 -0
  95. package/dist/types/chess-reasoning/recorded-selected-classification.d.ts +36 -0
  96. package/dist/types/chess-reasoning/reference-limits.d.ts +2 -0
  97. package/dist/types/chess-reasoning/research-exports.d.ts +197 -0
  98. package/dist/types/chess-reasoning/saved-score-presentation.d.ts +14 -0
  99. package/dist/types/chess-reasoning/score-comparison-notices.d.ts +33 -0
  100. package/dist/types/chess-reasoning/server-simple-policy.d.ts +31 -0
  101. package/dist/types/chess-reasoning/simple-agent-config.d.ts +73 -0
  102. package/dist/types/chess-reasoning/simple-board-analysis.d.ts +85 -0
  103. package/dist/types/chess-reasoning/simple-compact-evidence.d.ts +7 -0
  104. package/dist/types/chess-reasoning/simple-completion.d.ts +23 -0
  105. package/dist/types/chess-reasoning/simple-engine-presentation.d.ts +3 -0
  106. package/dist/types/chess-reasoning/simple-evidence-preparation.d.ts +17 -0
  107. package/dist/types/chess-reasoning/simple-evidence-view.d.ts +17 -0
  108. package/dist/types/chess-reasoning/simple-explanation-coverage.d.ts +90 -0
  109. package/dist/types/chess-reasoning/simple-fact-delivery.d.ts +43 -0
  110. package/dist/types/chess-reasoning/simple-fallback-premise.d.ts +5 -0
  111. package/dist/types/chess-reasoning/simple-prose-references.d.ts +108 -0
  112. package/dist/types/chess-reasoning/simple-runtime-version.d.ts +1 -0
  113. package/dist/types/chess-reasoning/stable.d.ts +2 -0
  114. package/dist/types/chess-reasoning/tool-input-loop-guard.d.ts +5 -0
  115. package/dist/types/chess-reasoning/types.d.ts +180 -0
  116. package/dist/types/chess-reasoning/visible-support-lines.d.ts +12 -0
  117. package/dist/types/chess-reasoning/wikibooks-index.d.ts +30 -0
  118. package/dist/types/chess-reasoning/wikibooks-tool-context.d.ts +10 -0
  119. package/dist/types/player-perspective.d.ts +16 -0
  120. package/dist/types/shared-exports.d.ts +22 -0
  121. package/docs/API.md +82 -0
  122. package/docs/OWNERSHIP-ADOPTION.md +35 -0
  123. package/docs/OWNERSHIP-DRIFT.json +55 -0
  124. package/docs/RESEARCH-API.md +28 -0
  125. package/licenses/third-party/INVENTORY.json +202 -0
  126. package/licenses/third-party/ai-7.0.85/LICENSE +13 -0
  127. package/licenses/third-party/ai-sdk--gateway-4.0.69/LICENSE +13 -0
  128. package/licenses/third-party/ai-sdk--provider-4.0.9/LICENSE +13 -0
  129. package/licenses/third-party/ai-sdk--provider-utils-5.0.34/APACHE-2.0.txt +73 -0
  130. package/licenses/third-party/ai-sdk--provider-utils-5.0.34/src/to-json-schema/zod3-to-json-schema/LICENSE +16 -0
  131. package/licenses/third-party/chess.js-1.4.0/LICENSE +23 -0
  132. package/licenses/third-party/eventsource-parser-3.1.1/LICENSE +21 -0
  133. package/licenses/third-party/json-schema-0.4.0/LICENSE +195 -0
  134. package/licenses/third-party/standard-schema--spec-1.1.0/LICENSE +21 -0
  135. package/licenses/third-party/types--json-schema-7.0.15/LICENSE +21 -0
  136. package/licenses/third-party/types--node-22.19.19/LICENSE +21 -0
  137. package/licenses/third-party/undici-7.30.0/LICENSE +21 -0
  138. package/licenses/third-party/undici-7.30.0/lib/web/fetch/LICENSE +21 -0
  139. package/licenses/third-party/undici-types-6.21.0/LICENSE +21 -0
  140. package/licenses/third-party/vercel--oidc-3.2.0/LICENSE +202 -0
  141. package/licenses/third-party/workflow--serde-4.1.0/APACHE-2.0.txt +73 -0
  142. package/licenses/third-party/workflow--serde-4.1.0/LICENSE.md +3 -0
  143. package/licenses/third-party/zod-4.6.5/LICENSE +21 -0
  144. package/npm-release.json +5 -0
  145. package/package.json +72 -4
  146. package/scripts/check-release-tooling.mjs +22 -0
  147. package/scripts/pack.mjs +68 -0
  148. package/scripts/publish-reviewed.mjs +72 -0
  149. package/scripts/release-tooling.json +13 -0
  150. package/scripts/update-dependency.mjs +44 -0
  151. package/scripts/verify-release.mjs +52 -0
  152. package/src/ai-request-failure.ts +34 -0
  153. package/src/ai-request-limits.ts +4 -0
  154. package/src/ai-routing-diagnostics.ts +33 -0
  155. package/src/chess-reasoning/ablation-adaptive-evidence-loop.ts +515 -0
  156. package/src/chess-reasoning/ablation-adaptive-runtime.ts +924 -0
  157. package/src/chess-reasoning/ablation-direct-synthesis.ts +1128 -0
  158. package/src/chess-reasoning/ablation-evidence-bundle.ts +726 -0
  159. package/src/chess-reasoning/ablation-evidence-capture.ts +513 -0
  160. package/src/chess-reasoning/ablation-lean-direct-runtime.ts +670 -0
  161. package/src/chess-reasoning/ablation-model-facing-evidence.ts +212 -0
  162. package/src/chess-reasoning/ablation-transport-correction.ts +106 -0
  163. package/src/chess-reasoning/ai-sdk-runtime-support.ts +381 -0
  164. package/src/chess-reasoning/answer-host-contracts.ts +10 -0
  165. package/src/chess-reasoning/answer-model-connector.ts +83 -0
  166. package/src/chess-reasoning/answer-pipeline-exports.ts +98 -0
  167. package/src/chess-reasoning/answer-pipeline.ts +195 -0
  168. package/src/chess-reasoning/answer-reference-validation.ts +124 -0
  169. package/src/chess-reasoning/answer-tool-host.ts +10 -0
  170. package/src/chess-reasoning/branch-expansion-policy.ts +32 -0
  171. package/src/chess-reasoning/branch-expansion.ts +80 -0
  172. package/src/chess-reasoning/causal-claim-checks.ts +256 -0
  173. package/src/chess-reasoning/chess-reference-dictionary.ts +21 -0
  174. package/src/chess-reasoning/classification-question-target.ts +30 -0
  175. package/src/chess-reasoning/classification-reassessment.ts +34 -0
  176. package/src/chess-reasoning/compact-search-preparation.ts +125 -0
  177. package/src/chess-reasoning/concept-registry.ts +275 -0
  178. package/src/chess-reasoning/conversation-context.ts +29 -0
  179. package/src/chess-reasoning/engine-search-failure.ts +11 -0
  180. package/src/chess-reasoning/evidence-citation-normalization.ts +15 -0
  181. package/src/chess-reasoning/evidence-licenses.ts +166 -0
  182. package/src/chess-reasoning/evidence-selector-contract.ts +5 -0
  183. package/src/chess-reasoning/existing-analysis-context.ts +544 -0
  184. package/src/chess-reasoning/fact-observation-provider.ts +134 -0
  185. package/src/chess-reasoning/fact-provider.ts +250 -0
  186. package/src/chess-reasoning/fresh-engine-pv-witnesses.ts +128 -0
  187. package/src/chess-reasoning/historical-prose.ts +116 -0
  188. package/src/chess-reasoning/idea-graph.ts +224 -0
  189. package/src/chess-reasoning/initial-search-plan.ts +115 -0
  190. package/src/chess-reasoning/lossless-evidence-sharing.ts +135 -0
  191. package/src/chess-reasoning/matched-comparison.ts +40 -0
  192. package/src/chess-reasoning/material-accounting.ts +55 -0
  193. package/src/chess-reasoning/material-format.ts +47 -0
  194. package/src/chess-reasoning/mechanical-fact-provider.ts +1602 -0
  195. package/src/chess-reasoning/mechanical-ray-facts.ts +123 -0
  196. package/src/chess-reasoning/mechanism-presentation.ts +94 -0
  197. package/src/chess-reasoning/move-mechanism-facts.ts +185 -0
  198. package/src/chess-reasoning/native-answer-connector.ts +13 -0
  199. package/src/chess-reasoning/opening-source-contracts.ts +47 -0
  200. package/src/chess-reasoning/opening-source-credits.ts +53 -0
  201. package/src/chess-reasoning/opponent-threat-preparation.ts +98 -0
  202. package/src/chess-reasoning/piece-identities.ts +159 -0
  203. package/src/chess-reasoning/poc-contracts.ts +1097 -0
  204. package/src/chess-reasoning/poc-hypotheses.ts +759 -0
  205. package/src/chess-reasoning/poc-move-witnesses.ts +170 -0
  206. package/src/chess-reasoning/poc-observations.ts +611 -0
  207. package/src/chess-reasoning/poc-piece-refs.ts +62 -0
  208. package/src/chess-reasoning/poc-plan-model.ts +345 -0
  209. package/src/chess-reasoning/poc-semantic-text.ts +10 -0
  210. package/src/chess-reasoning/poc-tools.ts +978 -0
  211. package/src/chess-reasoning/portable-answer-runtime.ts +684 -0
  212. package/src/chess-reasoning/position-analysis-contracts.ts +88 -0
  213. package/src/chess-reasoning/position-analysis-scope.ts +20 -0
  214. package/src/chess-reasoning/preparation-consolidation.ts +91 -0
  215. package/src/chess-reasoning/production-observation-provider.ts +41 -0
  216. package/src/chess-reasoning/question-routing.ts +332 -0
  217. package/src/chess-reasoning/recorded-main-line.ts +55 -0
  218. package/src/chess-reasoning/recorded-position-tools.ts +78 -0
  219. package/src/chess-reasoning/recorded-reference-context.ts +44 -0
  220. package/src/chess-reasoning/recorded-selected-classification.ts +54 -0
  221. package/src/chess-reasoning/reference-limits.ts +2 -0
  222. package/src/chess-reasoning/research-exports.ts +197 -0
  223. package/src/chess-reasoning/saved-score-presentation.ts +6 -0
  224. package/src/chess-reasoning/score-comparison-notices.ts +115 -0
  225. package/src/chess-reasoning/server-simple-policy.ts +75 -0
  226. package/src/chess-reasoning/simple-agent-config.ts +58 -0
  227. package/src/chess-reasoning/simple-board-analysis.ts +57 -0
  228. package/src/chess-reasoning/simple-compact-evidence.ts +79 -0
  229. package/src/chess-reasoning/simple-completion.ts +37 -0
  230. package/src/chess-reasoning/simple-engine-presentation.ts +95 -0
  231. package/src/chess-reasoning/simple-evidence-preparation.ts +32 -0
  232. package/src/chess-reasoning/simple-evidence-view.ts +69 -0
  233. package/src/chess-reasoning/simple-explanation-coverage.ts +118 -0
  234. package/src/chess-reasoning/simple-fact-delivery.ts +52 -0
  235. package/src/chess-reasoning/simple-fallback-premise.ts +65 -0
  236. package/src/chess-reasoning/simple-prose-references.ts +528 -0
  237. package/src/chess-reasoning/simple-runtime-version.ts +2 -0
  238. package/src/chess-reasoning/stable.ts +18 -0
  239. package/src/chess-reasoning/tool-input-loop-guard.ts +38 -0
  240. package/src/chess-reasoning/types.ts +195 -0
  241. package/src/chess-reasoning/visible-support-lines.ts +44 -0
  242. package/src/chess-reasoning/wikibooks-index.ts +56 -0
  243. package/src/chess-reasoning/wikibooks-tool-context.ts +91 -0
  244. package/src/player-perspective.ts +41 -0
  245. package/src/shared-exports.ts +23 -0
  246. package/test/answer-pipeline.test.mjs +375 -0
  247. package/test/owner/chess-reasoning-compact-search-preparation.test.mjs +111 -0
  248. package/test/owner/mechanism-encoding.test.mjs +78 -0
  249. package/test/owner/move-mechanism-facts.test.mjs +105 -0
  250. package/test/owner/pipeline-host-preparation.test.mjs +115 -0
  251. package/test/owner/position-preparation.test.mjs +22 -0
  252. package/test/owner/preparation-consolidation.test.mjs +74 -0
  253. package/test/owner/prose-reference-admission.test.mjs +26 -0
  254. package/test/owner/score-comparison-notices.test.mjs +116 -0
  255. package/test/owner/simple-engine-presentation.test.mjs +50 -0
  256. package/test/owner/tool-input-loop-guard.test.mjs +25 -0
  257. package/test-types.mts +23 -0
  258. package/tsconfig.json +22 -0
@@ -0,0 +1,326 @@
1
+ /** KE-REASON-024: question-only Jev routing contract. */
2
+ export declare const QUESTION_ROUTING_VERSION = "jev-r17-move-classification-20261003";
3
+ export declare const REVIEW_SUBJECTS: readonly ["self", "opponent", "white", "black", "both", "unspecified"];
4
+ export declare const ANSWER_SCOPES: readonly ["move_explanation", "position_analysis", "game_review", "general", "mixed"];
5
+ export type AnswerScope = typeof ANSWER_SCOPES[number];
6
+ export type AnswerScopeAnswer = {
7
+ type: 'choice';
8
+ choice: AnswerScope;
9
+ confidence?: number;
10
+ probabilities?: Partial<Record<AnswerScope, number>>;
11
+ };
12
+ export type ReviewSubject = typeof REVIEW_SUBJECTS[number];
13
+ export type ReviewSubjectAnswer = {
14
+ type: 'choice';
15
+ choice: ReviewSubject;
16
+ confidence?: number;
17
+ probabilities?: Partial<Record<ReviewSubject, number>>;
18
+ };
19
+ declare const questions: {
20
+ readonly independent: {
21
+ readonly type: "choice";
22
+ readonly instructions: "Can all active requests be answered using the game record or general knowledge, without knowing which turn the viewer selected?";
23
+ readonly criteria: {
24
+ yes: string;
25
+ no: string;
26
+ };
27
+ };
28
+ readonly independent_noul: {
29
+ readonly type: "noul";
30
+ readonly instructions: "Is the user asking only about subjects identifiable independently of the selected move?";
31
+ readonly criteria: {
32
+ readonly true: string;
33
+ readonly false: string;
34
+ };
35
+ };
36
+ readonly board_guard: {
37
+ readonly type: "choice";
38
+ readonly instructions: "Does the user actively ask about the board position currently displayed?";
39
+ readonly criteria: {
40
+ readonly yes: "An active request for its evaluation, material, threats, legal moves, plans, or another property of the current position. Excluding discussion of the selected move does not exclude the board.";
41
+ readonly no: "Only game history, phase review, an explicitly numbered historical turn, general knowledge, or discussion/translation of quoted text. No active request about the current board.";
42
+ };
43
+ };
44
+ readonly review_only: {
45
+ readonly type: "choice";
46
+ readonly instructions: "Is the user's entire request a review of how they played across a game or a phase of that game?";
47
+ readonly criteria: {
48
+ readonly yes: "Assess their play across the opening, middlegame, endgame or whole game. Evaluate performance, identify mistakes or missed chances, or give lessons from that play. No additional request about the selected move, the current board, or what to play next.";
49
+ readonly no: "A specific move or current position is being discussed, including a mixed request combining a game review with a selected-move explanation, current-position assessment, next move or continuation. General chess advice without reviewing their played game is also no.";
50
+ };
51
+ };
52
+ readonly local_reference: {
53
+ readonly type: "choice";
54
+ readonly instructions: "Does answering the user's active question require identifying a move or position referred to without an explicit game move number?";
55
+ readonly criteria: {
56
+ readonly yes: "The question asks about this move, this position, here, now, a next move, an unnamed alternative, or a reference to a previous answer. Include mixed requests even if they also mention game history or reviewing the opening. A question like why this is losing needs the referenced position.";
57
+ readonly no: "Every active request is about the whole game, a game phase, general knowledge, or an explicitly numbered historical move. Mentions of the current board that are quoted or explicitly excluded are not active requests.";
58
+ };
59
+ };
60
+ readonly game_record: {
61
+ readonly type: "choice";
62
+ readonly instructions: "Does the user ask what actually happened in this game, including which moves were played?";
63
+ readonly criteria: {
64
+ readonly yes: "The user asks for actual game events, actual subsequent play, or whether/when a move was played.";
65
+ readonly no: "The user is not asking to retrieve actual game events or played moves.";
66
+ };
67
+ };
68
+ readonly game_context: {
69
+ readonly type: "choice";
70
+ readonly instructions: "Does answering the user require their recorded game, beyond the selected move and its immediately surrounding positions?";
71
+ readonly criteria: {
72
+ readonly yes: "The answer depends on played game history: actual events or later play, review of a game or phase, an explicitly numbered historical move, or advice and variations specific to the opening played in this game. Include coaching requests grounded in their game even when they do not explicitly ask to retrieve moves.";
73
+ readonly no: "The current position or selected move alone is sufficient, or the request is general chess knowledge, translation, or unrelated to the played game. A named opening alone without a reference to their game does not require game history. Comparing possible moves in the selected position is a local question, unless another part of the request needs game history.";
74
+ };
75
+ };
76
+ readonly game_review: {
77
+ readonly type: "choice";
78
+ readonly instructions: "Is a review of play across the game or a phase explicitly requested?";
79
+ readonly criteria: {
80
+ readonly yes: "Review multiple decisions, find mistakes across a phase or the game, or recommend lessons from that play. An explicit question about how an earlier phase went still counts when paired with next-move advice. A comprehensive review of the full game counts even without mentioning mistakes or personal performance.";
81
+ readonly no: "No broad review is requested. Mentioning past mistakes while asking what to do now, or asking about just one move, is not a broad review. Retrieving facts, statistics or played moves without evaluating decisions is not a review. Evaluating only one hypothetical alternative is not a phase review. Opening identification or general planning advice without assessing played decisions is not a review.";
82
+ };
83
+ };
84
+ readonly selected_anchor: {
85
+ readonly type: "choice";
86
+ readonly instructions: "Is any part of the request about the currently selected chess position or an unidentified local move? Classify the active request, not quoted or explicitly excluded text.";
87
+ readonly criteria: {
88
+ readonly yes: "The displayed board, this move, an unnumbered move judged against the engine, an unnamed alternative, what to play from here, or an unresolved reference to previous analysis. General advice alongside a local question still counts.";
89
+ readonly no: "Only a whole game, a game phase, a move identified by its turn number, actual game events, or a self-contained general topic. A numbered move anchors its consequences and replies too. This includes numbered historical moves written with non-English piece notation.";
90
+ };
91
+ };
92
+ readonly numbered_move_target: {
93
+ readonly type: "choice";
94
+ readonly instructions: "Is an actual game turn number attached to the target move, separately from its destination square? Ignore quoted or excluded requests.";
95
+ readonly criteria: {
96
+ readonly yes: "A turn number precedes a period and move, as in 5.Nxe5 or 12...Nd4, or prose explicitly says bishop move on turn twelve. The user asks about that identified move, its alternatives or consequences.";
97
+ readonly no: "A square rank is NOT a turn number: Ne6, Na5, a5 and d4 are unnumbered moves. Quantities of plies and ranges of turns are not numbered target moves. Numbered text merely quoted for translation does not count.";
98
+ };
99
+ };
100
+ readonly played_opening: {
101
+ readonly type: "choice";
102
+ readonly instructions: "Does the user actively ask to identify or teach the opening system or sequence played in their game? Ignore quoted or excluded requests.";
103
+ readonly criteria: {
104
+ readonly yes: "Identify the played opening, teach this opening or our opening, give its overall main lines, or coach the opening phase of their game. The request must actually refer to an opening or opening phase.";
105
+ readonly no: "Only current-position advice, best replies or continuations from the current point. An opening name merely framing a particular move is insufficient. Generic named-opening theory, or opening words inside text being translated, also do not count.";
106
+ };
107
+ };
108
+ readonly retrospective_review: {
109
+ readonly type: "choice";
110
+ readonly instructions: "Does the user request feedback on how they played across a game or a phase? Classify the active request, not quoted or explicitly excluded text.";
111
+ readonly criteria: {
112
+ readonly yes: "Review actual play, diagnose recurring mistakes, or explain how their decisions across the opening, middlegame, endgame or game could have been better. This can be part of a mixed request.";
113
+ readonly no: "Only one move or position; theory, prospective continuations, hypothetical traps or typical future mistakes. A walkthrough of possible replies is not feedback on played decisions.";
114
+ };
115
+ };
116
+ };
117
+ export declare const CLASSIFICATION_REFERENCES: readonly ["selection_relative", "named_move", "other_relative", "none"];
118
+ export type ClassificationReference = typeof CLASSIFICATION_REFERENCES[number];
119
+ export type ClassificationReferenceAnswer = {
120
+ type: 'choice';
121
+ choice: ClassificationReference;
122
+ confidence?: number;
123
+ probabilities?: Partial<Record<ClassificationReference, number>>;
124
+ };
125
+ /** Saved r16 responses remain readable; these legacy heads are never requested or used. */
126
+ export declare const CLASSIFICATION_TARGETS: readonly ["selected_move", "other_move", "none"];
127
+ export type ClassificationTarget = typeof CLASSIFICATION_TARGETS[number];
128
+ export type ClassificationTargetAnswer = {
129
+ type: 'choice';
130
+ choice: ClassificationTarget;
131
+ confidence?: number;
132
+ probabilities?: Partial<Record<ClassificationTarget, number>>;
133
+ };
134
+ export type QuestionRoutingAnswer = {
135
+ type: "choice";
136
+ choice: "yes" | "no";
137
+ confidence?: number;
138
+ probabilities?: Partial<Record<"yes" | "no", number>>;
139
+ } | {
140
+ type: "noul";
141
+ noul: number;
142
+ };
143
+ export type QuestionRoutingAnswers = Record<keyof typeof questions, QuestionRoutingAnswer> & {
144
+ review_subject?: ReviewSubjectAnswer;
145
+ answer_scope?: AnswerScopeAnswer;
146
+ current_classification?: QuestionRoutingAnswer;
147
+ classification_target?: ClassificationTargetAnswer;
148
+ move_classification?: QuestionRoutingAnswer;
149
+ classification_reference?: ClassificationReferenceAnswer;
150
+ };
151
+ export type QuestionRoutingDecision = {
152
+ version: string;
153
+ status: "classified" | "fallback";
154
+ omitSelectedContext: boolean;
155
+ includeGameRecord: boolean;
156
+ gameRecordTrigger?: 'starting-position';
157
+ reviewGame: boolean;
158
+ reviewSubject?: ReviewSubject;
159
+ reason?: string;
160
+ answers?: QuestionRoutingAnswers;
161
+ usage?: {
162
+ cost?: number | null;
163
+ prompt_tokens?: number;
164
+ completion_tokens?: number;
165
+ total_tokens?: number;
166
+ input_tokens?: number;
167
+ output_tokens?: number;
168
+ };
169
+ providerLatencyMs?: number;
170
+ };
171
+ export declare function makeQuestionRoutingRequest(question: string): {
172
+ model: string;
173
+ state: {
174
+ question: string;
175
+ };
176
+ questions: {
177
+ review_subject: {
178
+ readonly type: "choice";
179
+ readonly instructions: "Whose play is the user asking to assess across a game or phase? Find the subject of that assessment, even if expressed as past decisions to improve rather than the word review. Ignore separate local-position requests and quoted or excluded instructions. Ownership of a game alone is not a player restriction. If the question explicitly identifies the reviewed player's color, choose white or black rather than self or opponent. Conflicting active review subjects must not select one player.";
180
+ readonly criteria: {
181
+ readonly self: "Assessment of the user's own performance or decisions: their errors, what they did wrong, or what they should have done differently across the game. This personal assessment can accompany a request to go through their game. No assessment of the other player's decisions is requested, and the question does not explicitly identify the user's color.";
182
+ readonly opponent: "The user asks to assess their opponent's play, mistakes or decisions, without requesting review of their own play. The question does not explicitly identify which color that opponent played.";
183
+ readonly white: "The requested review concerns White's decisions only, whether named directly or identified as the user/opponent by an explicit statement of who played which color. Color mentions that merely describe the opponent or another local question do not count.";
184
+ readonly black: "The requested review concerns Black's decisions only, whether named directly or identified as the user/opponent by an explicit statement of who played which color. Color mentions that merely describe the opponent or another local question do not count.";
185
+ readonly both: "The across-game/phase review explicitly covers both players, or contains conflicting review subjects that cannot be resolved to one player. A separate question about a single move or piece does not add a player to this review's scope.";
186
+ readonly unspecified: "No assessment across multiple played decisions is requested, or no player's decisions are singled out. An overall review of the game, my game or our opening alone has no player restriction. An additional request to assess the user's own decisions DOES specify self instead.";
187
+ };
188
+ };
189
+ answer_scope: {
190
+ readonly type: "choice";
191
+ readonly instructions: "What is the main task of the user's active request? Classify its requested answer, not the selected board, available game history, routing needs, or quoted/excluded text. A move explanation requires a specific move actually played, including an identified historical game move; a hypothetical candidate from the current position is position analysis. Choose mixed if a move explanation is combined with a substantial whole-game, position, or other independent task.";
192
+ readonly criteria: {
193
+ readonly move_explanation: "Explain or evaluate one specific played move, selected now or identified from the recorded game, and its pertinent alternatives or continuations.";
194
+ readonly position_analysis: "Assess a current or starting position, legal candidates, plans or next moves without a specific played target move.";
195
+ readonly game_review: "Review decisions or play across the whole recorded game or a phase, even when a selected move happens to be available.";
196
+ readonly general: "Answer a factual, rules, opening theory, translation or other question that is not a played-move explanation, position analysis or game review.";
197
+ readonly mixed: "Multiple substantial tasks have different scopes; do not force one played-move structure over the complete answer.";
198
+ };
199
+ };
200
+ move_classification: {
201
+ readonly type: "choice";
202
+ readonly instructions: "Does ANY active part of the question ask to explain, justify, challenge or reassess the quality classification of a PLAYED move? Include mixed questions and played moves identified by SAN, game move number, this move, or previous move. You have only the question: do not infer whether a named or numbered move is selected now or historical. Ignore quoted or expressly excluded requests.";
203
+ readonly criteria: {
204
+ readonly yes: "At least one active request asks why or whether a played move deserves a quality label: forced, brilliant, great, interesting, best, good, okay, dubious, mistake, missed opportunity or blunder. Why is this the best move in this position, why is 14.Qg4 great, and why was my opponent's previous move a blunder all count. The request can be one part of a mixed question.";
205
+ readonly no: "No active played-move quality-classification request. Only move intention, plans, threats, position evaluation, prospective hypothetical candidates, opening lines, general label definitions, translation of quoted classification questions, expressly excluded label explanations, or a label mentioned merely as background.";
206
+ };
207
+ };
208
+ classification_reference: {
209
+ readonly type: "choice";
210
+ readonly instructions: "How is the target of the ACTIVE PLAYED-MOVE CLASSIFICATION request expressed? Describe only the wording, not game facts or which move is selected. Examine classification requests separately from unrelated requests in a mixed question. If ANY active classification request explicitly refers to this/current/selected move or an unnamed local played move, choose selection_relative even alongside named-move questions. Unrelated local plans or next-move requests do not count as selection-relative classification requests. Ignore quoted and expressly excluded text.";
211
+ readonly criteria: {
212
+ readonly selection_relative: "An active classification request says this move, the current/selected move, this was a mistake, or otherwise concerns an unnamed local played move. Takes precedence if there is also a named or previous-move classification request. Compare 14.Qg4 with 14.Qh5, and explain why this selected move is marked a mistake is selection_relative.";
213
+ readonly named_move: "Active played-move classification requests name a move by SAN, optionally with a game move number, and no separate selection-relative classification request exists. Why is 14.Qg4 great, and what should I play next here is named_move: only the plans request is local. The number does not tell you whether that move is currently selected.";
214
+ readonly other_relative: "Active played-move classification requests identify a previous move, opponent's last move or another relative played move without explicit SAN, with no selection-relative or named-move classification request. This describes the reference wording, not its resolved game position.";
215
+ readonly none: "No active played-move classification request: only definitions, quoted or excluded label questions, prospective hypothetical moves, move intention, position evaluation, plans, opening lines or labels mentioned as background.";
216
+ };
217
+ };
218
+ independent: {
219
+ readonly type: "choice";
220
+ readonly instructions: "Can all active requests be answered using the game record or general knowledge, without knowing which turn the viewer selected?";
221
+ readonly criteria: {
222
+ yes: string;
223
+ no: string;
224
+ };
225
+ };
226
+ independent_noul: {
227
+ readonly type: "noul";
228
+ readonly instructions: "Is the user asking only about subjects identifiable independently of the selected move?";
229
+ readonly criteria: {
230
+ readonly true: string;
231
+ readonly false: string;
232
+ };
233
+ };
234
+ board_guard: {
235
+ readonly type: "choice";
236
+ readonly instructions: "Does the user actively ask about the board position currently displayed?";
237
+ readonly criteria: {
238
+ readonly yes: "An active request for its evaluation, material, threats, legal moves, plans, or another property of the current position. Excluding discussion of the selected move does not exclude the board.";
239
+ readonly no: "Only game history, phase review, an explicitly numbered historical turn, general knowledge, or discussion/translation of quoted text. No active request about the current board.";
240
+ };
241
+ };
242
+ review_only: {
243
+ readonly type: "choice";
244
+ readonly instructions: "Is the user's entire request a review of how they played across a game or a phase of that game?";
245
+ readonly criteria: {
246
+ readonly yes: "Assess their play across the opening, middlegame, endgame or whole game. Evaluate performance, identify mistakes or missed chances, or give lessons from that play. No additional request about the selected move, the current board, or what to play next.";
247
+ readonly no: "A specific move or current position is being discussed, including a mixed request combining a game review with a selected-move explanation, current-position assessment, next move or continuation. General chess advice without reviewing their played game is also no.";
248
+ };
249
+ };
250
+ local_reference: {
251
+ readonly type: "choice";
252
+ readonly instructions: "Does answering the user's active question require identifying a move or position referred to without an explicit game move number?";
253
+ readonly criteria: {
254
+ readonly yes: "The question asks about this move, this position, here, now, a next move, an unnamed alternative, or a reference to a previous answer. Include mixed requests even if they also mention game history or reviewing the opening. A question like why this is losing needs the referenced position.";
255
+ readonly no: "Every active request is about the whole game, a game phase, general knowledge, or an explicitly numbered historical move. Mentions of the current board that are quoted or explicitly excluded are not active requests.";
256
+ };
257
+ };
258
+ game_record: {
259
+ readonly type: "choice";
260
+ readonly instructions: "Does the user ask what actually happened in this game, including which moves were played?";
261
+ readonly criteria: {
262
+ readonly yes: "The user asks for actual game events, actual subsequent play, or whether/when a move was played.";
263
+ readonly no: "The user is not asking to retrieve actual game events or played moves.";
264
+ };
265
+ };
266
+ game_context: {
267
+ readonly type: "choice";
268
+ readonly instructions: "Does answering the user require their recorded game, beyond the selected move and its immediately surrounding positions?";
269
+ readonly criteria: {
270
+ readonly yes: "The answer depends on played game history: actual events or later play, review of a game or phase, an explicitly numbered historical move, or advice and variations specific to the opening played in this game. Include coaching requests grounded in their game even when they do not explicitly ask to retrieve moves.";
271
+ readonly no: "The current position or selected move alone is sufficient, or the request is general chess knowledge, translation, or unrelated to the played game. A named opening alone without a reference to their game does not require game history. Comparing possible moves in the selected position is a local question, unless another part of the request needs game history.";
272
+ };
273
+ };
274
+ game_review: {
275
+ readonly type: "choice";
276
+ readonly instructions: "Is a review of play across the game or a phase explicitly requested?";
277
+ readonly criteria: {
278
+ readonly yes: "Review multiple decisions, find mistakes across a phase or the game, or recommend lessons from that play. An explicit question about how an earlier phase went still counts when paired with next-move advice. A comprehensive review of the full game counts even without mentioning mistakes or personal performance.";
279
+ readonly no: "No broad review is requested. Mentioning past mistakes while asking what to do now, or asking about just one move, is not a broad review. Retrieving facts, statistics or played moves without evaluating decisions is not a review. Evaluating only one hypothetical alternative is not a phase review. Opening identification or general planning advice without assessing played decisions is not a review.";
280
+ };
281
+ };
282
+ selected_anchor: {
283
+ readonly type: "choice";
284
+ readonly instructions: "Is any part of the request about the currently selected chess position or an unidentified local move? Classify the active request, not quoted or explicitly excluded text.";
285
+ readonly criteria: {
286
+ readonly yes: "The displayed board, this move, an unnumbered move judged against the engine, an unnamed alternative, what to play from here, or an unresolved reference to previous analysis. General advice alongside a local question still counts.";
287
+ readonly no: "Only a whole game, a game phase, a move identified by its turn number, actual game events, or a self-contained general topic. A numbered move anchors its consequences and replies too. This includes numbered historical moves written with non-English piece notation.";
288
+ };
289
+ };
290
+ numbered_move_target: {
291
+ readonly type: "choice";
292
+ readonly instructions: "Is an actual game turn number attached to the target move, separately from its destination square? Ignore quoted or excluded requests.";
293
+ readonly criteria: {
294
+ readonly yes: "A turn number precedes a period and move, as in 5.Nxe5 or 12...Nd4, or prose explicitly says bishop move on turn twelve. The user asks about that identified move, its alternatives or consequences.";
295
+ readonly no: "A square rank is NOT a turn number: Ne6, Na5, a5 and d4 are unnumbered moves. Quantities of plies and ranges of turns are not numbered target moves. Numbered text merely quoted for translation does not count.";
296
+ };
297
+ };
298
+ played_opening: {
299
+ readonly type: "choice";
300
+ readonly instructions: "Does the user actively ask to identify or teach the opening system or sequence played in their game? Ignore quoted or excluded requests.";
301
+ readonly criteria: {
302
+ readonly yes: "Identify the played opening, teach this opening or our opening, give its overall main lines, or coach the opening phase of their game. The request must actually refer to an opening or opening phase.";
303
+ readonly no: "Only current-position advice, best replies or continuations from the current point. An opening name merely framing a particular move is insufficient. Generic named-opening theory, or opening words inside text being translated, also do not count.";
304
+ };
305
+ };
306
+ retrospective_review: {
307
+ readonly type: "choice";
308
+ readonly instructions: "Does the user request feedback on how they played across a game or a phase? Classify the active request, not quoted or explicitly excluded text.";
309
+ readonly criteria: {
310
+ readonly yes: "Review actual play, diagnose recurring mistakes, or explain how their decisions across the opening, middlegame, endgame or game could have been better. This can be part of a mixed request.";
311
+ readonly no: "Only one move or position; theory, prospective continuations, hypothetical traps or typical future mistakes. A walkthrough of possible replies is not feedback on played decisions.";
312
+ };
313
+ };
314
+ };
315
+ };
316
+ /** Preserve validated legacy heads even if the additive subject head is unavailable. */
317
+ export declare function parseQuestionRoutingAnswers(value: unknown): QuestionRoutingAnswers | null;
318
+ /** Unmeasured, ambiguous, legacy and fallback routes never enable the move-only suffix. */
319
+ export declare function moveSectionScope(decision: QuestionRoutingDecision): 'move-explanation' | 'none';
320
+ export declare function classifyReviewSubject(answers: QuestionRoutingAnswers): ReviewSubject;
321
+ export declare function classifyQuestionRoutingAnswers(answers: QuestionRoutingAnswers): Pick<QuestionRoutingDecision, "omitSelectedContext" | "includeGameRecord" | "reviewGame">;
322
+ /** KE-REASON-024: question-only intent; callers resolve the move using frozen context. */
323
+ export declare function hasMoveClassificationQuestion(decision: QuestionRoutingDecision): boolean;
324
+ /** Transitional alias: this indicates intent, not whether its target is the selected move. */
325
+ export declare const shouldInspectCurrentClassification: typeof hasMoveClassificationQuestion;
326
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { RecordedMainLine } from "./answer-host-contracts.js";
2
+ import { type ReasoningPositionContext, type ReasoningEvidenceRecord } from "./poc-contracts.js";
3
+ export declare function recordedMainLineResult(line: RecordedMainLine, context: ReasoningPositionContext): {
4
+ contextHash: string;
5
+ evidence: ReasoningEvidenceRecord[];
6
+ recordedAnalysis: {
7
+ source: string;
8
+ authority: string;
9
+ scorePerspective: string;
10
+ units: string;
11
+ coverage: {
12
+ analyzedPlies: number;
13
+ totalPlies: number;
14
+ complete: boolean;
15
+ };
16
+ columns: string[];
17
+ rows: [number, string, number, number, number, string, number | null, number | null, number | null, number | null, number | null][];
18
+ limitations: string[];
19
+ };
20
+ recordedMainLine: {
21
+ source: string;
22
+ startFen: string;
23
+ moves: {
24
+ uci: string;
25
+ san: string;
26
+ moveNumber: number;
27
+ color: import("chess.js").Color;
28
+ }[];
29
+ selectedIndex: number;
30
+ selectedAtStart: boolean;
31
+ selectedOnMainLine: boolean;
32
+ totalPlies: number;
33
+ truncated: boolean;
34
+ pgn: string;
35
+ };
36
+ limitations: string[];
37
+ };
@@ -0,0 +1,11 @@
1
+ import type { RecordedMainLine } from './answer-host-contracts.js';
2
+ import { type PocToolHostOptions } from './poc-tools.js';
3
+ import { type ReasoningPositionContext, type ReasoningToolDescriptor, type ReasoningToolSet } from './poc-contracts.js';
4
+ export declare const RECORDED_POSITION_TOOLS: readonly ["analyze_game_position", "test_game_line"];
5
+ export declare const isRecordedPositionTool: (name: string) => boolean;
6
+ export declare const RECORDED_POSITION_DESCRIPTORS: ReasoningToolDescriptor[];
7
+ /** No caller supplied FEN. Every root is an exact occurrence in the frozen record. */
8
+ export declare function recordedPositionContext(line: RecordedMainLine, ply: number): ReasoningPositionContext;
9
+ export declare function withRecordedPositionTools(selected: ReasoningPositionContext, base: ReasoningToolSet, options: PocToolHostOptions, getLine: (signal?: AbortSignal) => Promise<RecordedMainLine>): ReasoningToolSet;
10
+ /** Request-local exact successful result reuse, including automatically prepared searches. */
11
+ export declare function memoizeToolResults(host: ReasoningToolSet): ReasoningToolSet;
@@ -0,0 +1,13 @@
1
+ import { type ReasoningPositionContext } from './poc-contracts.js';
2
+ /** Reconstruct an occurrence from its ordered history, never from a FEN guess. */
3
+ export declare function historyPositionContext(startFen: string, history: string[]): ReasoningPositionContext;
4
+ export declare function recordedEvidenceContext(selected: ReasoningPositionContext, value: unknown): ReasoningPositionContext;
5
+ export declare function recordedNavigation(context: ReasoningPositionContext, recorded?: ReasoningPositionContext): {
6
+ anchorEdgeId: string;
7
+ context: ReasoningPositionContext;
8
+ } | {
9
+ context: ReasoningPositionContext;
10
+ anchorEdgeId?: undefined;
11
+ };
12
+ /** Reject contradictory engine scope before promoting its paths to navigation/theory. */
13
+ export declare function recordedDetailsMatch(root: ReasoningPositionContext, value: unknown): boolean;
@@ -0,0 +1,36 @@
1
+ import type { RecordedMainLine } from './answer-host-contracts.js';
2
+ import { type ReasoningPositionContext, type ReasoningEvidenceRecord } from './poc-contracts.js';
3
+ /** A historical badge is not a refreshed board analysis or a new classification. */
4
+ export declare function recordedSelectedClassification(context: ReasoningPositionContext, line: RecordedMainLine | undefined): {
5
+ record: ReasoningEvidenceRecord;
6
+ snapshot: {
7
+ evidenceId: string;
8
+ version: "recorded-selected-classification/1";
9
+ authority: string;
10
+ source: string;
11
+ position: {
12
+ fenBefore: string;
13
+ fenAfter: string;
14
+ moveUci: string;
15
+ moveSan: string;
16
+ ply: number;
17
+ };
18
+ classification: string;
19
+ classifierVersion: number;
20
+ engine: string;
21
+ reportedDepth: number;
22
+ recordedRequestedDepth: number;
23
+ freshlyRecomputed: boolean;
24
+ savedEvaluation: {
25
+ perspective: string;
26
+ units: string;
27
+ beforeCp: number | null;
28
+ afterCp: number | null;
29
+ lossCp: number | null;
30
+ mateBefore: number | null;
31
+ mateAfter: number | null;
32
+ };
33
+ limitations: string[];
34
+ };
35
+ } | undefined;
36
+ export type RecordedSelectedClassification = ReturnType<typeof recordedSelectedClassification>;
@@ -0,0 +1,2 @@
1
+ /** Shared producer, reference-admission and saved-answer path bound. */
2
+ export declare const MAX_INTERACTIVE_LINE_PLIES = 32;