@mechane-ai/elements 0.46.0 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (419) hide show
  1. package/README.md +590 -34
  2. package/bin/mechane-elements-catalog.mjs +104 -12
  3. package/dist/ai.js +4 -4
  4. package/dist/article-BXZr10QQ.js +1904 -0
  5. package/dist/article.js +1 -0
  6. package/dist/catalog.json +3696 -33
  7. package/dist/categorical-values-BpVq8cFj.js +107 -0
  8. package/dist/cells-xVmnQ9oQ.js +384 -0
  9. package/dist/chart-link-AE_xuxiP.js +35 -0
  10. package/dist/chart-tones-ei3BC2AL.js +27 -0
  11. package/dist/charts/cartesian.js +1 -2958
  12. package/dist/charts/cells.js +1 -0
  13. package/dist/charts/comparison.js +1 -0
  14. package/dist/charts/distribution.js +1 -781
  15. package/dist/charts/figure.js +3404 -0
  16. package/dist/charts/graph.js +1 -655
  17. package/dist/charts/hierarchy.js +1 -121
  18. package/dist/charts/image.js +1 -0
  19. package/dist/charts/matrix.js +4 -644
  20. package/dist/charts/plot.js +15 -0
  21. package/dist/charts/relationship.js +1 -0
  22. package/dist/charts/text.js +1 -0
  23. package/dist/charts/timeline.js +1 -266
  24. package/dist/charts/transforms.js +677 -0
  25. package/dist/charts/trend.js +1 -0
  26. package/dist/charts.js +8 -3
  27. package/dist/clock-DSm5lkNE.js +16 -0
  28. package/dist/collections.js +1 -2195
  29. package/dist/color-legend-CIo7DhXB.js +62 -0
  30. package/dist/dates-Cww8UR_n.js +810 -0
  31. package/dist/describe-lesson-BmREzDpt.js +175 -0
  32. package/dist/dumbbell-plot-DQdTxDeO.js +509 -0
  33. package/dist/embedding-map-CF-J-8JW.js +1929 -0
  34. package/dist/feedback.js +1 -1
  35. package/dist/figure-format-B8kRZMlo.js +36 -0
  36. package/dist/figure-frame-BJ3REgTA.js +270 -0
  37. package/dist/forms/dates.js +1 -810
  38. package/dist/forms.js +1 -1
  39. package/dist/heatmap-scale-Zte6Ya-g.js +20 -0
  40. package/dist/image-grid-Dl2sjIMB.js +598 -0
  41. package/dist/kits/evaluation.js +431 -0
  42. package/dist/kits/interpretability.js +1033 -0
  43. package/dist/kits/operations.js +239 -0
  44. package/dist/kits/training.js +335 -0
  45. package/dist/label-place-Z0fryBZb.js +42 -0
  46. package/dist/lesson/agent.js +811 -0
  47. package/dist/lesson/spec.js +661 -0
  48. package/dist/lesson.js +5 -0
  49. package/dist/locate-Bcg3QcP4.js +11 -0
  50. package/dist/mdx.js +227 -0
  51. package/dist/packages/charts/src/cartesian/bar-chart.d.ts +40 -21
  52. package/dist/packages/charts/src/cartesian/bar-data.d.ts +15 -4
  53. package/dist/packages/charts/src/cartesian/bar-overlays.d.ts +7 -3
  54. package/dist/packages/charts/src/cartesian/breakdown-bar.d.ts +10 -8
  55. package/dist/packages/charts/src/cartesian/bridge-chart.d.ts +20 -16
  56. package/dist/packages/charts/src/cartesian/bridge-data.d.ts +5 -4
  57. package/dist/packages/charts/src/cartesian/composition-bars.d.ts +8 -4
  58. package/dist/packages/charts/src/cartesian/index.d.ts +5 -5
  59. package/dist/packages/charts/src/cartesian/reference-lines.d.ts +25 -18
  60. package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +30 -25
  61. package/dist/packages/charts/src/cartesian/sparkline.d.ts +14 -2
  62. package/dist/packages/charts/src/cartesian/time-series-bands.d.ts +3 -2
  63. package/dist/packages/charts/src/cartesian/time-series-data.d.ts +12 -2
  64. package/dist/packages/charts/src/cartesian/time-series-line.d.ts +2 -2
  65. package/dist/packages/charts/src/cartesian/time-series-overlays.d.ts +6 -4
  66. package/dist/packages/charts/src/cartesian/time-series.d.ts +60 -36
  67. package/dist/packages/charts/src/cartesian/value-labels.d.ts +22 -0
  68. package/dist/packages/charts/src/categorical-values.d.ts +1 -1
  69. package/dist/packages/charts/src/cells/bar-cell.d.ts +13 -0
  70. package/dist/packages/charts/src/cells/cell-layout.d.ts +81 -0
  71. package/dist/packages/charts/src/cells/change-cell.d.ts +17 -0
  72. package/dist/packages/charts/src/cells/heat-cell.d.ts +19 -0
  73. package/dist/packages/charts/src/cells/index.d.ts +11 -0
  74. package/dist/packages/charts/src/cells/interval-cell.d.ts +16 -0
  75. package/dist/packages/charts/src/cells/spark-cell.d.ts +22 -0
  76. package/dist/packages/charts/src/chart-frame.d.ts +14 -7
  77. package/dist/packages/charts/src/chart-grid.d.ts +19 -0
  78. package/dist/packages/charts/src/chart-input.d.ts +1 -9
  79. package/dist/packages/charts/src/chart-link.d.ts +56 -0
  80. package/dist/packages/charts/src/chart.d.ts +0 -8
  81. package/dist/packages/charts/src/comparison/bullet-bar.d.ts +34 -0
  82. package/dist/packages/charts/src/comparison/comparison-plot.d.ts +54 -0
  83. package/dist/packages/charts/src/comparison/dot-plot.d.ts +41 -0
  84. package/dist/packages/charts/src/comparison/dumbbell-plot.d.ts +33 -0
  85. package/dist/packages/charts/src/comparison/index.d.ts +6 -0
  86. package/dist/packages/charts/src/distribution/box-plot.d.ts +40 -0
  87. package/dist/packages/charts/src/distribution/distribution-input.d.ts +5 -3
  88. package/dist/packages/charts/src/distribution/distribution-plot.d.ts +28 -161
  89. package/dist/packages/charts/src/distribution/ecdf.d.ts +16 -15
  90. package/dist/packages/charts/src/distribution/group-plot-input.d.ts +35 -0
  91. package/dist/packages/charts/src/distribution/group-plot-layout.d.ts +79 -0
  92. package/dist/packages/charts/src/distribution/group-plot.d.ts +73 -0
  93. package/dist/packages/charts/src/distribution/histogram.d.ts +16 -16
  94. package/dist/packages/charts/src/distribution/index.d.ts +11 -0
  95. package/dist/packages/charts/src/distribution/interval-plot.d.ts +16 -13
  96. package/dist/packages/charts/src/distribution/ranked-bars.d.ts +17 -14
  97. package/dist/packages/charts/src/distribution/ridgeline.d.ts +34 -0
  98. package/dist/packages/charts/src/distribution/strip-plot.d.ts +37 -0
  99. package/dist/packages/charts/src/distribution/violin-plot.d.ts +34 -0
  100. package/dist/packages/charts/src/figure/figure-format.d.ts +34 -0
  101. package/dist/packages/charts/src/figure/figure-frame.d.ts +47 -0
  102. package/dist/packages/charts/src/figure/figure-props.d.ts +54 -0
  103. package/dist/packages/charts/src/figure/tone-scope.d.ts +32 -0
  104. package/dist/packages/charts/src/graph/attribution-graph.d.ts +62 -0
  105. package/dist/packages/charts/src/graph/attribution-layout.d.ts +88 -0
  106. package/dist/packages/charts/src/graph/flow-diagram.d.ts +14 -15
  107. package/dist/packages/charts/src/graph/flow-layout.d.ts +4 -2
  108. package/dist/packages/charts/src/graph/graph-canvas.d.ts +33 -0
  109. package/dist/packages/charts/src/graph/index.d.ts +6 -2
  110. package/dist/packages/charts/src/graph/relation-graph.d.ts +24 -13
  111. package/dist/packages/charts/src/graph/tree-diagram.d.ts +41 -0
  112. package/dist/packages/charts/src/graph/tree-layout.d.ts +71 -0
  113. package/dist/packages/charts/src/hierarchy/area-mark.d.ts +17 -0
  114. package/dist/packages/charts/src/hierarchy/icicle.d.ts +35 -0
  115. package/dist/packages/charts/src/hierarchy/index.d.ts +2 -0
  116. package/dist/packages/charts/src/hierarchy/partition-layout.d.ts +25 -0
  117. package/dist/packages/charts/src/hierarchy/treemap-layout.d.ts +26 -0
  118. package/dist/packages/charts/src/hierarchy/treemap.d.ts +11 -9
  119. package/dist/packages/charts/src/image/attribution-legend.d.ts +13 -0
  120. package/dist/packages/charts/src/image/attribution-overlay.d.ts +50 -0
  121. package/dist/packages/charts/src/image/attribution-ramp.d.ts +16 -0
  122. package/dist/packages/charts/src/image/image-atlas.d.ts +37 -0
  123. package/dist/packages/charts/src/image/image-fill.d.ts +9 -0
  124. package/dist/packages/charts/src/image/image-grid.d.ts +26 -0
  125. package/dist/packages/charts/src/image/image-input.d.ts +27 -0
  126. package/dist/packages/charts/src/image/image-tile.d.ts +27 -0
  127. package/dist/packages/charts/src/image/index.d.ts +7 -0
  128. package/dist/packages/charts/src/index.d.ts +15 -1
  129. package/dist/packages/charts/src/matrix/attention-matrix.d.ts +41 -0
  130. package/dist/packages/charts/src/matrix/calendar-heatmap.d.ts +37 -0
  131. package/dist/packages/charts/src/matrix/color-legend.d.ts +9 -2
  132. package/dist/packages/charts/src/matrix/confusion-matrix.d.ts +36 -0
  133. package/dist/packages/charts/src/matrix/correlation-matrix.d.ts +34 -0
  134. package/dist/packages/charts/src/matrix/heatmap-scale.d.ts +8 -2
  135. package/dist/packages/charts/src/matrix/index.d.ts +15 -3
  136. package/dist/packages/charts/src/matrix/matrix-cells.d.ts +27 -3
  137. package/dist/packages/charts/src/matrix/matrix-figure.d.ts +50 -0
  138. package/dist/packages/charts/src/matrix/matrix-mark.d.ts +34 -0
  139. package/dist/packages/charts/src/matrix/matrix-presets.d.ts +20 -0
  140. package/dist/packages/charts/src/matrix/matrix-range.d.ts +45 -0
  141. package/dist/packages/charts/src/matrix/matrix-strip.d.ts +13 -14
  142. package/dist/packages/charts/src/matrix/matrix-types.d.ts +40 -0
  143. package/dist/packages/charts/src/matrix/matrix.d.ts +13 -11
  144. package/dist/packages/charts/src/matrix/token-heatmap.d.ts +16 -10
  145. package/dist/packages/charts/src/plot/contours.d.ts +45 -0
  146. package/dist/packages/charts/src/plot/index.d.ts +49 -0
  147. package/dist/packages/charts/src/plot/label-place.d.ts +35 -0
  148. package/dist/packages/charts/src/plot/locate.d.ts +18 -0
  149. package/dist/packages/charts/src/plot/path.d.ts +39 -0
  150. package/dist/packages/charts/src/plot/plot-axes.d.ts +20 -0
  151. package/dist/packages/charts/src/plot/plot-layout.d.ts +221 -0
  152. package/dist/packages/charts/src/plot/plot-marks.d.ts +128 -0
  153. package/dist/packages/charts/src/plot/plot-surface.d.ts +32 -0
  154. package/dist/packages/charts/src/plot/render/density-layer.d.ts +17 -0
  155. package/dist/packages/charts/src/plot/render/hit-index.d.ts +37 -0
  156. package/dist/packages/charts/src/plot/render/plot-viewport.d.ts +39 -0
  157. package/dist/packages/charts/src/plot/render/point-layer.d.ts +41 -0
  158. package/dist/packages/charts/src/plot/render/theme-colors.d.ts +15 -0
  159. package/dist/packages/charts/src/plot/scale.d.ts +48 -0
  160. package/dist/packages/charts/src/plot/ticks.d.ts +34 -0
  161. package/dist/packages/charts/src/plot-width.d.ts +3 -2
  162. package/dist/packages/charts/src/relationship/contour-plot.d.ts +61 -0
  163. package/dist/packages/charts/src/relationship/density-map.d.ts +45 -0
  164. package/dist/packages/charts/src/relationship/embedding-map.d.ts +75 -0
  165. package/dist/packages/charts/src/relationship/index.d.ts +11 -0
  166. package/dist/packages/charts/src/relationship/level-legend.d.ts +11 -0
  167. package/dist/packages/charts/src/relationship/measures.d.ts +85 -0
  168. package/dist/packages/charts/src/relationship/parallel-coordinates.d.ts +30 -0
  169. package/dist/packages/charts/src/relationship/range-controls.d.ts +20 -0
  170. package/dist/packages/charts/src/relationship/scatter-matrix.d.ts +20 -0
  171. package/dist/packages/charts/src/spec/chart-guide.d.ts +21 -0
  172. package/dist/packages/charts/src/spec/figure-registry.d.ts +44 -0
  173. package/dist/packages/charts/src/spec/figure-spec.d.ts +147 -0
  174. package/dist/packages/charts/src/spec/figure-text.d.ts +8 -0
  175. package/dist/packages/charts/src/spec/figure.d.ts +12 -0
  176. package/dist/packages/charts/src/spec/guide-data.d.ts +85 -0
  177. package/dist/packages/charts/src/spec/index.d.ts +10 -0
  178. package/dist/packages/charts/src/spec/validate-figure.d.ts +15 -0
  179. package/dist/packages/charts/src/text/index.d.ts +11 -0
  180. package/dist/packages/charts/src/text/token-examples.d.ts +42 -0
  181. package/dist/packages/charts/src/text/token-grid.d.ts +47 -0
  182. package/dist/packages/charts/src/text/token-links.d.ts +49 -0
  183. package/dist/packages/charts/src/text/token-predictions.d.ts +38 -0
  184. package/dist/packages/charts/src/text/token-scale.d.ts +20 -0
  185. package/dist/packages/charts/src/text/token-text.d.ts +39 -0
  186. package/dist/packages/charts/src/timeline/event-strip.d.ts +70 -0
  187. package/dist/packages/charts/src/timeline/index.d.ts +3 -1
  188. package/dist/packages/charts/src/timeline/waterfall.d.ts +24 -13
  189. package/dist/packages/charts/src/transforms/bins.d.ts +91 -0
  190. package/dist/packages/charts/src/transforms/density.d.ts +53 -0
  191. package/dist/packages/charts/src/transforms/fits.d.ts +50 -0
  192. package/dist/packages/charts/src/transforms/index.d.ts +19 -0
  193. package/dist/packages/charts/src/transforms/matrices.d.ts +49 -0
  194. package/dist/packages/charts/src/transforms/quantiles.d.ts +96 -0
  195. package/dist/packages/charts/src/transforms/ranks.d.ts +44 -0
  196. package/dist/packages/charts/src/transforms/runs.d.ts +47 -0
  197. package/dist/packages/charts/src/transforms/sampling.d.ts +75 -0
  198. package/dist/packages/charts/src/transforms/smoothing.d.ts +41 -0
  199. package/dist/packages/charts/src/transforms/values.d.ts +70 -0
  200. package/dist/packages/charts/src/trend/bump-chart.d.ts +33 -0
  201. package/dist/packages/charts/src/trend/column-figure.d.ts +38 -0
  202. package/dist/packages/charts/src/trend/column-positions.d.ts +21 -0
  203. package/dist/packages/charts/src/trend/curve-chart.d.ts +69 -0
  204. package/dist/packages/charts/src/trend/end-labels.d.ts +40 -0
  205. package/dist/packages/charts/src/trend/horizon-chart.d.ts +37 -0
  206. package/dist/packages/charts/src/trend/index.d.ts +10 -0
  207. package/dist/packages/charts/src/trend/line-locate.d.ts +21 -0
  208. package/dist/packages/charts/src/trend/runs-chart.d.ts +50 -0
  209. package/dist/packages/charts/src/trend/slope-chart.d.ts +35 -0
  210. package/dist/packages/kits/src/evaluation/evaluation-data.d.ts +31 -0
  211. package/dist/packages/kits/src/evaluation/index.d.ts +8 -0
  212. package/dist/packages/kits/src/evaluation/leaderboard-cells.d.ts +62 -0
  213. package/dist/packages/kits/src/evaluation/leaderboard.d.ts +59 -0
  214. package/dist/packages/kits/src/evaluation/model-comparison.d.ts +59 -0
  215. package/dist/packages/kits/src/evaluation/score-breakdown.d.ts +33 -0
  216. package/dist/packages/kits/src/interpretability/attention-head-grid.d.ts +56 -0
  217. package/dist/packages/kits/src/interpretability/attribution-workbench.d.ts +29 -0
  218. package/dist/packages/kits/src/interpretability/embedding-atlas.d.ts +41 -0
  219. package/dist/packages/kits/src/interpretability/feature-card.d.ts +33 -0
  220. package/dist/packages/kits/src/interpretability/feature-list.d.ts +51 -0
  221. package/dist/packages/kits/src/interpretability/feature-logits.d.ts +23 -0
  222. package/dist/packages/kits/src/interpretability/features.d.ts +70 -0
  223. package/dist/packages/kits/src/interpretability/index.d.ts +16 -0
  224. package/dist/packages/kits/src/interpretability/kit-styles.d.ts +118 -0
  225. package/dist/packages/kits/src/interpretability/logit-lens.d.ts +50 -0
  226. package/dist/packages/kits/src/interpretability/node-panel.d.ts +32 -0
  227. package/dist/packages/kits/src/interpretability/shared-link.d.ts +8 -0
  228. package/dist/packages/kits/src/interpretability/steering-panel.d.ts +52 -0
  229. package/dist/packages/kits/src/operations/budget-board.d.ts +49 -0
  230. package/dist/packages/kits/src/operations/incident-timeline.d.ts +30 -0
  231. package/dist/packages/kits/src/operations/index.d.ts +6 -0
  232. package/dist/packages/kits/src/operations/service-health.d.ts +66 -0
  233. package/dist/packages/kits/src/training/index.d.ts +8 -0
  234. package/dist/packages/kits/src/training/run-dashboard.d.ts +49 -0
  235. package/dist/packages/kits/src/training/run-legend.d.ts +21 -0
  236. package/dist/packages/kits/src/training/run-marker.d.ts +5 -0
  237. package/dist/packages/kits/src/training/run-state.d.ts +7 -0
  238. package/dist/packages/kits/src/training/run-table.d.ts +63 -0
  239. package/dist/packages/kits/src/training/runs-overview.d.ts +20 -0
  240. package/dist/packages/kits/src/training/runs.d.ts +34 -0
  241. package/dist/packages/teaching/src/agent/index.d.ts +11 -0
  242. package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
  243. package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
  244. package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
  245. package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
  246. package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
  247. package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
  248. package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
  249. package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
  250. package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
  251. package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
  252. package/dist/packages/teaching/src/article/article.d.ts +42 -0
  253. package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
  254. package/dist/packages/teaching/src/article/beat.d.ts +16 -0
  255. package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
  256. package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
  257. package/dist/packages/teaching/src/article/figure.d.ts +51 -0
  258. package/dist/packages/teaching/src/article/index.d.ts +31 -0
  259. package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
  260. package/dist/packages/teaching/src/article/linked-target.d.ts +22 -0
  261. package/dist/packages/teaching/src/article/notes.d.ts +36 -0
  262. package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
  263. package/dist/packages/teaching/src/article/predict.d.ts +58 -0
  264. package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
  265. package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
  266. package/dist/packages/teaching/src/article/term.d.ts +35 -0
  267. package/dist/packages/teaching/src/article/tex.d.ts +12 -0
  268. package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
  269. package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
  270. package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
  271. package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
  272. package/dist/packages/teaching/src/article/walk.d.ts +34 -0
  273. package/dist/packages/teaching/src/lesson/bound-value.d.ts +29 -0
  274. package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
  275. package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
  276. package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
  277. package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
  278. package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
  279. package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
  280. package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
  281. package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
  282. package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
  283. package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
  284. package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
  285. package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
  286. package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
  287. package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
  288. package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
  289. package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
  290. package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
  291. package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
  292. package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
  293. package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
  294. package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
  295. package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
  296. package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
  297. package/dist/packages/teaching/src/scene/index.d.ts +77 -0
  298. package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
  299. package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
  300. package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
  301. package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
  302. package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
  303. package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
  304. package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
  305. package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
  306. package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
  307. package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
  308. package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
  309. package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
  310. package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
  311. package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
  312. package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
  313. package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
  314. package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
  315. package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
  316. package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
  317. package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
  318. package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
  319. package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
  320. package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
  321. package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
  322. package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
  323. package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
  324. package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
  325. package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
  326. package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
  327. package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
  328. package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
  329. package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
  330. package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
  331. package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
  332. package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
  333. package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
  334. package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
  335. package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
  336. package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
  337. package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
  338. package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
  339. package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
  340. package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
  341. package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
  342. package/dist/packages/teaching/src/spec/index.d.ts +14 -0
  343. package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
  344. package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
  345. package/dist/packages/teaching/src/time/clock.d.ts +7 -0
  346. package/dist/packages/teaching/src/time/tween.d.ts +19 -0
  347. package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
  348. package/dist/param-CqKUTHaO.js +450 -0
  349. package/dist/path-BglsXpnO.js +59 -0
  350. package/dist/plot-axes-DJkLW4wk.js +100 -0
  351. package/dist/plot-layout-CZVSJ-le.js +912 -0
  352. package/dist/plot-marks-uozcbOIX.js +229 -0
  353. package/dist/plot-surface-CbVBvgqZ.js +51 -0
  354. package/dist/plot-width-DcqtSgzb.js +124 -0
  355. package/dist/point-layer-C-EYETAt.js +655 -0
  356. package/dist/reference-lines-BDcttOp0.js +82 -0
  357. package/dist/scale-C2xgZyZN.js +63 -0
  358. package/dist/scene-0z2gbaDE.js +4938 -0
  359. package/dist/scene.js +1 -0
  360. package/dist/slope-chart-BKVEAVCs.js +1279 -0
  361. package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
  362. package/dist/{src-DVHlknB6.js → src-CExIrXPC.js} +169 -193
  363. package/dist/src-DIS0YOj0.js +44 -0
  364. package/dist/src-Dcfq8vE4.js +2195 -0
  365. package/dist/styles2.css +907 -59
  366. package/dist/time-series-BgzGNOk0.js +2670 -0
  367. package/dist/token-heatmap-BrW1OsKD.js +1354 -0
  368. package/dist/token-predictions-yerq_Oet.js +1093 -0
  369. package/dist/tone-scope-DKiSw-JR.js +32 -0
  370. package/dist/transport-BJweqDPj.js +715 -0
  371. package/dist/tree-diagram-D09BRqE-.js +1629 -0
  372. package/dist/treemap-CW4WsJNL.js +472 -0
  373. package/dist/use-tween-5HZ55_9d.js +72 -0
  374. package/dist/values-963L6n1m.js +65 -0
  375. package/dist/violin-plot-DrtPZ1-T.js +1292 -0
  376. package/dist/waterfall-DYLSnGjm.js +576 -0
  377. package/package.json +78 -4
  378. package/recipes/allocation-report.tsx +15 -7
  379. package/recipes/counting-cards.tsx +656 -0
  380. package/recipes/explorable-essay.tsx +172 -0
  381. package/skills/extend-elements/SKILL.md +81 -0
  382. package/skills/plan-lesson/SKILL.md +86 -0
  383. package/skills/plan-lesson/references/plan-format.md +114 -0
  384. package/skills/plan-lesson/references/worked-plan.md +171 -0
  385. package/skills/review-elements/SKILL.md +47 -3
  386. package/skills/review-explainer/SKILL.md +97 -0
  387. package/skills/upgrade-elements/SKILL.md +3 -1
  388. package/skills/upgrade-elements/references/releases.md +249 -0
  389. package/skills/use-elements/SKILL.md +22 -14
  390. package/skills/use-elements/references/charts.md +362 -41
  391. package/skills/use-elements/references/figures.md +173 -0
  392. package/skills/use-elements/references/kits.md +180 -0
  393. package/skills/use-elements/references/teaching.md +36 -0
  394. package/skills/write-explainer/SKILL.md +112 -0
  395. package/skills/write-explainer/references/article.md +164 -0
  396. package/skills/write-explainer/references/lesson.md +148 -0
  397. package/skills/write-explainer/references/mdx.md +78 -0
  398. package/skills/write-explainer/references/scene-parts.md +273 -0
  399. package/skills/write-explainer/references/scene.md +168 -0
  400. package/skills/write-explainer/references/tutor.md +104 -0
  401. package/skills/write-explainer/references/worked-essay.md +459 -0
  402. package/templates/essay/AGENTS.md +14 -0
  403. package/templates/essay/README.md +59 -0
  404. package/templates/essay/index.html +17 -0
  405. package/templates/essay/package.template.json +21 -0
  406. package/templates/essay/plan.json +96 -0
  407. package/templates/essay/src/essay.mdx +97 -0
  408. package/templates/essay/src/figures.tsx +92 -0
  409. package/templates/essay/src/lesson.ts +83 -0
  410. package/templates/essay/src/main.tsx +53 -0
  411. package/templates/essay/src/mdx.d.ts +7 -0
  412. package/templates/essay/tsconfig.template.json +15 -0
  413. package/templates/essay/vite.config.template.txt +8 -0
  414. package/dist/categorical-values-BXi-rJuv.js +0 -74
  415. package/dist/chart-data-CIJVWCYt.js +0 -21
  416. package/dist/chart-frame-BaxKn_MB.js +0 -236
  417. package/dist/chart-input-Bm82_9Rd.js +0 -22
  418. package/dist/chart-theme-4zprJ3rW.js +0 -404
  419. package/dist/plot-width-v2c_rA20.js +0 -63
@@ -0,0 +1,811 @@
1
+ import { l as e, r as t, t as n } from "../describe-lesson-BmREzDpt.js";
2
+ import { n as r } from "../clock-DSm5lkNE.js";
3
+ import { formatNumber as i } from "@ui-sdk/core/number";
4
+ // packages/teaching/src/agent/lesson-bridge.ts
5
+ var a = /* @__PURE__ */ new Set([
6
+ "mouse",
7
+ "touch",
8
+ "pen",
9
+ "keyboard",
10
+ "virtual"
11
+ ]), o = /* @__PURE__ */ new Set([
12
+ "number",
13
+ "string",
14
+ "boolean"
15
+ ]);
16
+ function s(e) {
17
+ return o.has(typeof e);
18
+ }
19
+ function c(e) {
20
+ return typeof e == "number" || typeof e == "string" || typeof e == "boolean" ? e : null;
21
+ }
22
+ function l(e) {
23
+ return typeof e == "object" && !!e && !Array.isArray(e);
24
+ }
25
+ function u(e) {
26
+ return typeof e == "object" && e && !Array.isArray(e) ? new Map(Object.entries(e)) : /* @__PURE__ */ new Map();
27
+ }
28
+ function d(e) {
29
+ return typeof e == "number" || typeof e == "string" ? e : void 0;
30
+ }
31
+ function f(e) {
32
+ return Array.isArray(e) ? e.filter((e) => typeof e == "string") : [];
33
+ }
34
+ function p(e) {
35
+ let t = u(e), n = [...u(t.get("predictions"))].flatMap(([e, t]) => {
36
+ let n = u(t), r = d(n.get("value")), i = d(n.get("answer"));
37
+ return r === void 0 || i === void 0 ? [] : [[e, {
38
+ value: r,
39
+ answer: i,
40
+ isCorrect: n.get("isCorrect") === !0
41
+ }]];
42
+ }), r = [...u(t.get("hints"))].flatMap(([e, t]) => typeof t == "number" ? [[e, t]] : []);
43
+ return {
44
+ predictions: Object.fromEntries(n),
45
+ reached: f(t.get("reached")),
46
+ hints: Object.fromEntries(r),
47
+ visited: f(t.get("visited"))
48
+ };
49
+ }
50
+ function m(e, t) {
51
+ return e.component === "lesson" && e.label === t.title;
52
+ }
53
+ function h(e, t) {
54
+ return e.snapshot().find((e) => m(e, t) && e.offPage !== !0);
55
+ }
56
+ function g(e, t) {
57
+ let n = e.snapshot().filter((e) => e.component === "lesson-progress");
58
+ return n.find((e) => e.label === t) ?? (n.length === 1 ? n[0] : void 0);
59
+ }
60
+ function _(e, t) {
61
+ let n = u(t);
62
+ return {
63
+ ...e.defaults,
64
+ ...Object.fromEntries([...n].flatMap(([t, n]) => {
65
+ let r = c(n);
66
+ return Object.hasOwn(e.params, t) && r !== null ? [[t, r]] : [];
67
+ }))
68
+ };
69
+ }
70
+ function v(e, t) {
71
+ let n = h(e, t);
72
+ if (n === void 0) return;
73
+ let r = _(t, n.values), { beat: i, step: a, playing: o } = n;
74
+ return {
75
+ ref: n.ref,
76
+ beat: typeof i == "string" ? i : null,
77
+ step: typeof a == "number" ? a : 0,
78
+ playing: typeof o == "string" ? o : null,
79
+ values: {
80
+ ...r,
81
+ ...t.compute(r)
82
+ }
83
+ };
84
+ }
85
+ function y(e, t) {
86
+ let n = [
87
+ {
88
+ name: "beat",
89
+ from: e.beat,
90
+ to: t.beat
91
+ },
92
+ {
93
+ name: "step",
94
+ from: e.step,
95
+ to: t.step
96
+ },
97
+ {
98
+ name: "playing",
99
+ from: e.playing,
100
+ to: t.playing
101
+ }
102
+ ], r = Object.keys(t.values).map((n) => ({
103
+ name: n,
104
+ from: e.values[n] ?? null,
105
+ to: t.values[n] ?? null
106
+ }));
107
+ return [...n, ...r].filter((e) => e.from !== e.to);
108
+ }
109
+ function b(e, t) {
110
+ let n = u(t.previous), r = u(t.value);
111
+ return Object.keys(e.params).flatMap((e) => {
112
+ let t = c(n.get(e)), i = c(r.get(e));
113
+ return s(i) && t !== i ? [{
114
+ name: e,
115
+ from: t,
116
+ to: i
117
+ }] : [];
118
+ });
119
+ }
120
+ async function x() {
121
+ let { promise: e, resolve: t } = Promise.withResolvers(), n = { stop: () => void 0 };
122
+ return n.stop = r(() => {
123
+ n.stop(), t();
124
+ }), await e;
125
+ }
126
+ // packages/teaching/src/agent/learner-trace.ts
127
+ var S = 400, C = 900, w = 1e3, T = 60, E = 2, ee = /* @__PURE__ */ new Set([
128
+ "drag",
129
+ "step-key",
130
+ "accessibility-adjust"
131
+ ]), D = /* @__PURE__ */ new Set(["restore", "reset"]);
132
+ function O(e, t) {
133
+ let n = Object.entries(t.predictions).flatMap(([t, n]) => Object.hasOwn(e.predictions, t) ? [] : [{
134
+ kind: "prediction",
135
+ name: t,
136
+ from: null,
137
+ to: n.value,
138
+ answer: n.answer,
139
+ isCorrect: n.isCorrect
140
+ }]), r = Object.entries(t.hints).flatMap(([t, n]) => {
141
+ let r = e.hints[t] ?? 0;
142
+ return n > r ? [{
143
+ kind: "hint",
144
+ name: t,
145
+ from: r,
146
+ to: n
147
+ }] : [];
148
+ }), i = new Set(e.reached), a = t.reached.filter((e) => !i.has(e)).map((e) => ({
149
+ kind: "challenge",
150
+ name: e,
151
+ from: null,
152
+ to: null
153
+ }));
154
+ return [
155
+ ...n,
156
+ ...r,
157
+ ...a
158
+ ];
159
+ }
160
+ function k({ agent: e, lesson: t, article: n = t.title, limit: r = 400, now: i = () => performance.now() }) {
161
+ let o = h(e, t), s = typeof o?.beat == "string" ? o.beat : null, l = {
162
+ started: i(),
163
+ startBeat: s,
164
+ beat: s,
165
+ values: _(t, o?.values),
166
+ dropped: 0,
167
+ events: [],
168
+ visits: []
169
+ }, u = /* @__PURE__ */ new Set();
170
+ function d() {
171
+ for (let e of u) e();
172
+ }
173
+ function f(e) {
174
+ let t = l.events.at(-1), n = t?.kind === e.kind && t.name === e.name && t.reason === e.reason && ee.has(e.reason) && e.at - t.at <= C ? [...l.events.slice(0, -1), {
175
+ ...t,
176
+ at: e.at,
177
+ to: e.to,
178
+ count: t.count + 1
179
+ }] : [...l.events, e];
180
+ l.dropped += Math.max(n.length - r, 0), l.events = n.slice(-r), d();
181
+ }
182
+ function v(e) {
183
+ let t = l.events.findLastIndex((t) => t.kind === "play" && t.name === e), n = l.values[e] ?? null;
184
+ t !== -1 && l.events[t]?.to === null && (l.events = l.events.map((e, r) => r === t ? {
185
+ ...e,
186
+ to: n
187
+ } : e), d());
188
+ }
189
+ function y(e, t, n) {
190
+ switch (e) {
191
+ case "beat":
192
+ case "step": return [{
193
+ kind: e,
194
+ name: e,
195
+ from: c(n),
196
+ to: c(t)
197
+ }];
198
+ case "playing": return typeof t == "string" ? [{
199
+ kind: "play",
200
+ name: t,
201
+ from: l.values[t] ?? null,
202
+ to: null
203
+ }] : [];
204
+ default: return [];
205
+ }
206
+ }
207
+ return {
208
+ read: () => ({
209
+ lesson: t.id,
210
+ startBeat: l.startBeat,
211
+ elapsed: Math.round(i() - l.started),
212
+ limit: r,
213
+ dropped: l.dropped,
214
+ events: l.events,
215
+ visits: l.visits
216
+ }),
217
+ subscribe(e) {
218
+ return u.add(e), () => {
219
+ u.delete(e);
220
+ };
221
+ },
222
+ clear() {
223
+ l.started = i(), l.startBeat = l.beat, l.dropped = 0, l.events = [], l.visits = [], d();
224
+ },
225
+ stop: e.subscribe((o) => {
226
+ let s = Math.round(i() - l.started), c = m(o, t), u = o.component === "lesson-progress" && o.ref === g(e, n)?.ref;
227
+ c && o.key === "beat" && (l.beat = typeof o.value == "string" ? o.value : null, l.visits = [...l.visits, {
228
+ at: s,
229
+ beat: l.beat
230
+ }].slice(-r));
231
+ let d = c && o.key === "values" ? b(t, o) : [];
232
+ c && o.key === "values" && (l.values = _(t, o.value)), c && o.key === "playing" && typeof o.previous == "string" && v(o.previous);
233
+ let h = u && o.source !== "agent" && !D.has(o.reason), x = o.key === "playing" && o.source !== "agent", S = c && (a.has(o.source) || x), C = h ? O(p(o.previous), p(o.value)) : [], w = S ? [...d.map((e) => ({
234
+ kind: "param",
235
+ ...e
236
+ })), ...y(o.key, o.value, o.previous)] : [];
237
+ for (let e of [...C, ...w]) f({
238
+ ...e,
239
+ at: s,
240
+ beat: l.beat,
241
+ source: o.source,
242
+ reason: o.reason,
243
+ count: 1
244
+ });
245
+ })
246
+ };
247
+ }
248
+ function A(e, t) {
249
+ let n = e / w, r = n >= T;
250
+ return i(r ? n / T : n, t, {
251
+ style: "unit",
252
+ unit: r ? "minute" : "second",
253
+ unitDisplay: "long",
254
+ maximumFractionDigits: 0
255
+ });
256
+ }
257
+ function j(e) {
258
+ let t = { value: 0 };
259
+ for (let n of e) t.value += n;
260
+ return t.value;
261
+ }
262
+ function M(e) {
263
+ return e === 1 ? "once" : `${e} times`;
264
+ }
265
+ function te(e, t, n) {
266
+ let r = [{
267
+ beat: e.startBeat,
268
+ at: 0
269
+ }, ...e.visits], i = r.map((t, n) => ({
270
+ beat: t.beat,
271
+ time: (r[n + 1]?.at ?? e.elapsed) - t.at
272
+ })), a = [...new Set(i.map(({ beat: e }) => e))].flatMap((e) => e === null ? [] : [e]).flatMap((e) => {
273
+ let r = j(i.filter((t) => t.beat === e).map((e) => e.time)), a = t.beats.findIndex((t) => t.id === e);
274
+ return r < w ? [] : [`${A(r, n)} on beat ${a + 1} (${t.beats[a]?.title ?? e})`];
275
+ });
276
+ return a.length === 0 ? void 0 : `Spent ${a.join(", then ")}.`;
277
+ }
278
+ function N({ lesson: e, name: n, events: r, locale: i }) {
279
+ let a = e.params[n], o = a?.label ?? n, s = j(r.map((e) => e.count)), c = r.at(-1)?.to ?? null, l = c === null ? "" : ` It is now ${t({
280
+ lesson: e,
281
+ name: n,
282
+ value: c,
283
+ locale: i
284
+ })}.`, u = r.flatMap((e) => [e.from, e.to]).filter((e) => typeof e == "number");
285
+ if (a?.kind === "number" && u.length > 0) {
286
+ let r = t({
287
+ lesson: e,
288
+ name: n,
289
+ value: Math.min(...u),
290
+ locale: i
291
+ }), a = t({
292
+ lesson: e,
293
+ name: n,
294
+ value: Math.max(...u),
295
+ locale: i
296
+ });
297
+ return `Moved ${o} ${M(s)}, between ${r} and ${a}.${l}`;
298
+ }
299
+ return `Changed ${o} ${M(s)}.${l}`;
300
+ }
301
+ function P({ lesson: e, locale: n, answers: r, event: a, value: o }) {
302
+ let s = r[a.name];
303
+ return o === null ? "nothing" : s === void 0 ? typeof o == "number" ? i(o, n, { maximumFractionDigits: E }) : String(o) : t({
304
+ lesson: e,
305
+ name: s,
306
+ value: o,
307
+ locale: n
308
+ });
309
+ }
310
+ function F(e) {
311
+ return typeof e.answer == "number" ? e.isCorrect === !0 ? "close" : "too far" : e.isCorrect === !0 ? "right" : "wrong";
312
+ }
313
+ function I({ record: e, lesson: n, locale: r, answers: i = {} }) {
314
+ if (e.events.length === 0) return "The reader has not acted yet.";
315
+ function a(t) {
316
+ return Map.groupBy(e.events.filter((e) => e.kind === t), (e) => e.name);
317
+ }
318
+ let o = [...a("param")].map(([e, t]) => N({
319
+ lesson: n,
320
+ name: e,
321
+ events: t,
322
+ locale: r
323
+ })), s = [...a("play")].map(([e, i]) => {
324
+ let a = i.at(-1)?.to ?? null, o = a === null ? "" : `, last stopping at ${t({
325
+ lesson: n,
326
+ name: e,
327
+ value: a,
328
+ locale: r
329
+ })}`;
330
+ return `Started the ${n.params[e]?.label ?? e} player ${M(i.length)}${o}.`;
331
+ }), c = e.events.flatMap((e) => {
332
+ let t = P({
333
+ lesson: n,
334
+ locale: r,
335
+ answers: i,
336
+ event: e,
337
+ value: e.to
338
+ }), a = P({
339
+ lesson: n,
340
+ locale: r,
341
+ answers: i,
342
+ event: e,
343
+ value: e.answer ?? null
344
+ });
345
+ return e.kind === "prediction" ? [`Predicted ${t} for "${e.name}"; the answer was ${a}, counted as ${F(e)}.`] : [];
346
+ }), l = [...a("hint")].map(([e, t]) => {
347
+ let n = Number(t.at(-1)?.to ?? 0);
348
+ return `Asked for ${n === 1 ? "1 hint" : `${n} hints`} on the challenge "${e}".`;
349
+ }), u = e.events.filter((e) => e.kind === "step").length, d = e.events.filter((e) => e.kind === "challenge");
350
+ return [
351
+ te(e, n, r),
352
+ ...o,
353
+ ...s,
354
+ u === 0 ? void 0 : `Moved through reveal steps ${M(u)}.`,
355
+ ...c,
356
+ ...l,
357
+ ...d.map((e) => `Reached the challenge "${e.name}".`),
358
+ e.dropped === 0 ? void 0 : `The trace keeps the last ${e.limit} events; ${e.dropped} earlier ones are not in it.`
359
+ ].filter((e) => e !== void 0).join(" ");
360
+ }
361
+ // packages/teaching/src/agent/lesson-tour.ts
362
+ var L = {
363
+ short: 1.5,
364
+ regular: 3,
365
+ long: 6
366
+ }, R = 1e3, z = /* @__PURE__ */ new Set([
367
+ "beat",
368
+ "step",
369
+ "state",
370
+ "values",
371
+ "say",
372
+ "hold"
373
+ ]), B = /* @__PURE__ */ new Set([
374
+ "done",
375
+ "stopped",
376
+ "failed"
377
+ ]), V = /* @__PURE__ */ new Set([
378
+ "beat",
379
+ "step",
380
+ "param",
381
+ "play"
382
+ ]), H = /* @__PURE__ */ new Set(["param", "play"]);
383
+ function U({ agent: e, lesson: t, tour: n, onSay: i }) {
384
+ let o = {
385
+ status: "playing",
386
+ index: -1,
387
+ waited: 0,
388
+ last: null,
389
+ isMoving: !1,
390
+ error: null
391
+ }, s = /* @__PURE__ */ new Set();
392
+ function c() {
393
+ for (let e of s) e();
394
+ }
395
+ function l(e, t = null) {
396
+ o.status = e, o.error = t, f(), p(), c();
397
+ }
398
+ async function u(n) {
399
+ let r = v(e, t);
400
+ if (r === void 0) {
401
+ l("failed", `The lesson "${t.title}" is not on the page for the agent.`);
402
+ return;
403
+ }
404
+ let a = [
405
+ ...n.beat !== void 0 || n.step !== void 0 ? [{
406
+ action: "setBeat",
407
+ args: [n.beat ?? r.beat, n.step ?? 0]
408
+ }] : [],
409
+ ...n.state === void 0 ? [] : [{
410
+ action: "showState",
411
+ args: [n.state]
412
+ }],
413
+ ...n.values === void 0 ? [] : [{
414
+ action: "setParams",
415
+ args: [n.values]
416
+ }]
417
+ ], s = a.length === 0 ? {
418
+ ok: !0,
419
+ error: void 0
420
+ } : await e.act({ steps: a.map(({ action: e, args: t }) => ({
421
+ ref: r.ref,
422
+ action: e,
423
+ args: t
424
+ })) });
425
+ s.ok ? n.say !== void 0 && i?.(n.say, o.index) : l("failed", s.error?.message ?? "The bridge refused a tour step.");
426
+ }
427
+ function d() {
428
+ o.index += 1, o.waited = 0, o.last = null;
429
+ let e = n[o.index];
430
+ e === void 0 ? (o.index = n.length - 1, l("done")) : (o.isMoving = !0, c(), u(e).then(() => {
431
+ o.isMoving = !1;
432
+ }));
433
+ }
434
+ let f = r((e) => {
435
+ if (o.status !== "playing" || o.isMoving) {
436
+ o.last = null;
437
+ return;
438
+ }
439
+ o.waited += o.last === null ? 0 : e - o.last, o.last = e;
440
+ let t = L[n[o.index]?.hold ?? "regular"] * R;
441
+ o.waited >= t && d();
442
+ }), p = e.subscribe((e) => {
443
+ (m(e, t) || e.component === "lesson-progress") && a.has(e.source) && o.status === "playing" && (o.status = "paused", c());
444
+ });
445
+ return d(), {
446
+ status: () => o.status,
447
+ index: () => o.index,
448
+ error: () => o.error,
449
+ pause() {
450
+ o.status === "playing" && (o.status = "paused", c());
451
+ },
452
+ resume() {
453
+ o.status === "paused" && (o.status = "playing", o.waited = 0, o.last = null, c());
454
+ },
455
+ stop() {
456
+ B.has(o.status) || l("stopped");
457
+ },
458
+ subscribe(e) {
459
+ return s.add(e), () => {
460
+ s.delete(e);
461
+ };
462
+ }
463
+ };
464
+ }
465
+ function W({ lesson: t, input: n, index: r, beat: i }) {
466
+ let a = `[${r}]`, o = u(n), s = o.get("beat"), c = t.beats.find((e) => e.id === (typeof s == "string" ? s : i)), d = o.get("step"), f = o.get("state"), p = o.get("hold"), m = typeof d == "number" && Number.isInteger(d) && d >= 0, h = c?.steps ?? 0, g = m && c !== void 0 && d > h, _ = c === void 0 ? t.beats.flatMap((e) => e.states ?? []) : c.states ?? [];
467
+ return [
468
+ ...[...o.keys()].filter((e) => !z.has(e)).map((e) => G(`${a}.${e}`, `A tour step takes beat, step, state, values, say and hold, not "${e}".`)),
469
+ ...s === void 0 || c !== void 0 ? [] : [G(`${a}.beat`, `"${JSON.stringify(s)}" is not a beat. The beats: ${t.beats.map((e) => e.id).join(", ")}.`)],
470
+ ...d === void 0 || m ? [] : [G(`${a}.step`, "step must be a whole number from 0.")],
471
+ ...g ? [G(`${a}.step`, `Beat "${c.id}" has reveal steps 0 to ${h}, not ${d}.`)] : [],
472
+ ...f === void 0 || _.some((e) => e.id === f) ? [] : [G(`${a}.state`, `"${JSON.stringify(f)}" is not a state ${c === void 0 ? "of any beat" : `of beat "${c.id}"`}.`)],
473
+ ...[...u(o.get("values"))].flatMap(([n, r]) => {
474
+ let i = e({
475
+ lesson: t,
476
+ name: n,
477
+ value: r
478
+ });
479
+ return i === void 0 ? [] : [G(`${a}.values.${n}`, i)];
480
+ }),
481
+ ...o.get("values") === void 0 || l(o.get("values")) ? [] : [G(`${a}.values`, "values must be an object of param names and values.")],
482
+ ...o.has("say") && typeof o.get("say") != "string" ? [G(`${a}.say`, "say must be a sentence.")] : [],
483
+ ...p === void 0 || typeof p == "string" && Object.hasOwn(L, p) ? [] : [G(`${a}.hold`, `hold must be one of ${Object.keys(L).join(", ")}; a tour names a pace, not milliseconds.`)],
484
+ ...o.size === 0 ? [K(a, "This step does nothing. Give it a beat, a state, values or something to say.")] : []
485
+ ];
486
+ }
487
+ function G(e, t) {
488
+ return {
489
+ path: e,
490
+ message: t,
491
+ severity: "error"
492
+ };
493
+ }
494
+ function K(e, t) {
495
+ return {
496
+ path: e,
497
+ message: t,
498
+ severity: "advice"
499
+ };
500
+ }
501
+ function q(e, t) {
502
+ if (!Array.isArray(e)) return [G("", "A tour is an array of steps.")];
503
+ let n = e, r = n.map((e, t) => {
504
+ let r = n.slice(0, t).map((e) => u(e).get("beat")).findLast((e) => typeof e == "string");
505
+ return typeof r == "string" ? r : void 0;
506
+ }), i = n.flatMap((e, n) => l(e) ? W({
507
+ lesson: t,
508
+ input: e,
509
+ index: n,
510
+ beat: r[n]
511
+ }) : [G(`[${n}]`, "A tour step is an object.")]), a = n.length > 0 && n.every((e) => !u(e).has("say"));
512
+ return [...i, ...a ? [K("", "This tour says nothing. Add say to the steps the reader should notice.")] : []];
513
+ }
514
+ function J(e) {
515
+ let t = e.events.filter((e) => V.has(e.kind)), n = t.flatMap((e, t) => t === 0 || e.kind === "beat" ? [t] : []);
516
+ return n.map((e, r) => {
517
+ let i = t.slice(e, n[r + 1] ?? t.length), a = i.find((e) => e.kind === "beat")?.to, o = i.findLast((e) => e.kind === "step")?.to, s = Object.fromEntries(i.flatMap((e) => H.has(e.kind) && e.to !== null ? [[e.name, e.to]] : []));
518
+ return {
519
+ ...typeof a == "string" && { beat: a },
520
+ ...typeof o == "number" && { step: o },
521
+ ...Object.keys(s).length > 0 && { values: s },
522
+ hold: "regular"
523
+ };
524
+ });
525
+ }
526
+ // packages/teaching/src/agent/tutor-tools.ts
527
+ var Y = "is not on the page for the agent: it has not rendered yet, or it is read-only or hidden.", X = "Paused. Every value holds where the player left it.", Z = "Nothing changed: the lesson already showed this, or the application refused the change.";
528
+ function Q(e = {}, t = []) {
529
+ return {
530
+ type: "object",
531
+ properties: e,
532
+ required: t
533
+ };
534
+ }
535
+ function $(e, t) {
536
+ let n = u(e).get(t);
537
+ return typeof n == "string" ? n : void 0;
538
+ }
539
+ function ne({ agent: e, lesson: r, locale: i, article: a = r.title, answers: o = {} }) {
540
+ let s = {
541
+ kind: "error",
542
+ message: `The lesson "${r.title}" ${Y}`
543
+ };
544
+ function l() {
545
+ let t = g(e, a);
546
+ return t === void 0 ? null : p(t.progress);
547
+ }
548
+ function d(e) {
549
+ return new Set(Object.entries(o).flatMap(([t, n]) => e !== null && Object.hasOwn(e.predictions, t) ? [] : [n]));
550
+ }
551
+ function f(e, t) {
552
+ return Object.fromEntries(Object.entries(e).filter(([e]) => !t.has(e)));
553
+ }
554
+ function h(e) {
555
+ let n = r.beats.findIndex((t) => t.id === e.beat), a = r.beats[n], o = l(), s = d(o), c = f(e.values, s);
556
+ return {
557
+ beat: a === void 0 ? null : {
558
+ id: a.id,
559
+ title: a.title,
560
+ number: n + 1,
561
+ of: r.beats.length
562
+ },
563
+ step: e.step,
564
+ steps: a?.steps ?? 0,
565
+ playing: e.playing,
566
+ values: c,
567
+ written: Object.fromEntries(Object.entries(c).map(([e, n]) => [e, t({
568
+ lesson: r,
569
+ name: e,
570
+ value: n,
571
+ locale: i
572
+ })])),
573
+ notes: {
574
+ goal: a?.goal ?? null,
575
+ misconception: a?.misconception ?? null,
576
+ hints: a?.hints ?? []
577
+ },
578
+ progress: o,
579
+ withheld: [...s]
580
+ };
581
+ }
582
+ async function _(t, n = Z) {
583
+ let i = v(e, r);
584
+ if (i === void 0) return s;
585
+ let a = await e.act({ steps: t.map((e) => ({
586
+ ref: i.ref,
587
+ action: e.action,
588
+ args: [...e.args]
589
+ })) });
590
+ await x();
591
+ let o = v(e, r) ?? i, c = d(l()), u = y(i, o).filter((e) => !c.has(e.name));
592
+ return a.ok ? {
593
+ kind: "ok",
594
+ changed: u,
595
+ at: {
596
+ beat: o.beat,
597
+ step: o.step
598
+ },
599
+ ...u.length === 0 && { note: n }
600
+ } : {
601
+ kind: "error",
602
+ message: a.error?.message ?? "The bridge refused the step."
603
+ };
604
+ }
605
+ let b = Object.keys(r.params), S = r.beats.map((e) => e.id), C = [...new Set(r.beats.flatMap((e) => (e.states ?? []).map((e) => e.id)))];
606
+ return [
607
+ {
608
+ name: "read_outline",
609
+ description: "Reads the lesson as plain JSON: its params with ranges, derived values with what they read, and beats with tutor notes and states. Call it once at the start.",
610
+ inputSchema: Q(),
611
+ run: async () => ({
612
+ kind: "ok",
613
+ outline: n(r)
614
+ })
615
+ },
616
+ {
617
+ name: "read_place",
618
+ description: "Reads where the reader is now: the beat and reveal step, every value as a number and as written on the page, the current beat's tutor notes, and the reader's progress. Prediction answers stay hidden until the reader commits.",
619
+ inputSchema: Q(),
620
+ run: async () => {
621
+ let t = v(e, r);
622
+ return t === void 0 ? s : {
623
+ kind: "ok",
624
+ place: h(t)
625
+ };
626
+ }
627
+ },
628
+ {
629
+ name: "set_param",
630
+ description: "Sets one param, as the agent. A number must be in its range, a choice takes an option id or label, a toggle takes true or false. Returns what changed.",
631
+ inputSchema: Q({
632
+ name: {
633
+ type: "string",
634
+ description: "The param to set.",
635
+ enum: b
636
+ },
637
+ value: {
638
+ type: [
639
+ "number",
640
+ "string",
641
+ "boolean"
642
+ ],
643
+ description: "Its new value."
644
+ }
645
+ }, ["name", "value"]),
646
+ run: async (e) => {
647
+ let t = $(e, "name"), n = u(e);
648
+ return t === void 0 || !n.has("value") ? {
649
+ kind: "error",
650
+ message: "set_param needs name, a param name, and value."
651
+ } : await _([{
652
+ action: "setParam",
653
+ args: [t, n.get("value")]
654
+ }]);
655
+ }
656
+ },
657
+ {
658
+ name: "set_params",
659
+ description: "Sets several params at once, as the agent, in one change, so the page never shows a mix of old and new values. Each value follows the rules of set_param.",
660
+ inputSchema: Q({ values: {
661
+ type: "object",
662
+ description: `Param names to their new values. Params: ${b.join(", ")}.`
663
+ } }, ["values"]),
664
+ run: async (e) => {
665
+ let t = u(u(e).get("values"));
666
+ return t.size === 0 ? {
667
+ kind: "error",
668
+ message: "set_params needs values, an object of param names to values."
669
+ } : await _([{
670
+ action: "setParams",
671
+ args: [Object.fromEntries(t)]
672
+ }]);
673
+ }
674
+ },
675
+ {
676
+ name: "show_state",
677
+ description: "Shows a state a beat declares in one change: the values it names are set and the rest return to their opening values. Use it to show the reader an example the author prepared.",
678
+ inputSchema: Q({ state: {
679
+ type: "string",
680
+ description: "The state id.",
681
+ enum: C
682
+ } }, ["state"]),
683
+ run: async (e) => {
684
+ let t = $(e, "state");
685
+ return t === void 0 ? {
686
+ kind: "error",
687
+ message: "show_state needs state, a state id."
688
+ } : await _([{
689
+ action: "showState",
690
+ args: [t]
691
+ }]);
692
+ }
693
+ },
694
+ {
695
+ name: "go_to_beat",
696
+ description: "Moves the lesson to a beat, at its first reveal step unless step says otherwise.",
697
+ inputSchema: Q({
698
+ beat: {
699
+ type: "string",
700
+ description: "The beat id.",
701
+ enum: S
702
+ },
703
+ step: {
704
+ type: "number",
705
+ description: "The reveal step, from 0. Defaults to 0."
706
+ }
707
+ }, ["beat"]),
708
+ run: async (e) => {
709
+ let t = $(e, "beat"), n = u(e).get("step") ?? 0;
710
+ return t === void 0 ? {
711
+ kind: "error",
712
+ message: "go_to_beat needs beat, a beat id."
713
+ } : await _([{
714
+ action: "setBeat",
715
+ args: [t, n]
716
+ }]);
717
+ }
718
+ },
719
+ {
720
+ name: "next",
721
+ description: "Shows the next reveal step, or the next beat at its first step.",
722
+ inputSchema: Q(),
723
+ run: async () => await _([{
724
+ action: "next",
725
+ args: []
726
+ }])
727
+ },
728
+ {
729
+ name: "previous",
730
+ description: "Hides the last reveal step, or goes back to the previous beat with every step shown.",
731
+ inputSchema: Q(),
732
+ run: async () => await _([{
733
+ action: "previous",
734
+ args: []
735
+ }])
736
+ },
737
+ {
738
+ name: "play",
739
+ description: "Starts the player of a number param, or the only player when the lesson has one.",
740
+ inputSchema: Q({ name: {
741
+ type: "string",
742
+ description: "The param whose player starts."
743
+ } }),
744
+ run: async (e) => {
745
+ let t = $(e, "name");
746
+ return await _([{
747
+ action: "play",
748
+ args: t === void 0 ? [] : [t]
749
+ }]);
750
+ }
751
+ },
752
+ {
753
+ name: "pause",
754
+ description: "Stops the player that is running.",
755
+ inputSchema: Q(),
756
+ run: async () => await _([{
757
+ action: "pause",
758
+ args: []
759
+ }], X)
760
+ },
761
+ {
762
+ name: "inspect_figure",
763
+ description: "Points at one object of a figure by its id, opening the figure's readout as a reader's hover would. Name the figure by its title.",
764
+ inputSchema: Q({
765
+ figure: {
766
+ type: "string",
767
+ description: "The title of the figure."
768
+ },
769
+ id: {
770
+ type: "string",
771
+ description: "The id of the object in the figure."
772
+ }
773
+ }, ["figure", "id"]),
774
+ run: async (t) => {
775
+ let n = $(t, "figure"), i = $(t, "id");
776
+ if (n === void 0 || i === void 0) return {
777
+ kind: "error",
778
+ message: "inspect_figure needs figure, a title, and id, an object id."
779
+ };
780
+ let a = e.snapshot().find((e) => e.label === n && !m(e, r));
781
+ if (a === void 0) return {
782
+ kind: "error",
783
+ message: `No figure titled "${n}" is on the page for the agent.`
784
+ };
785
+ if (!a.actions.includes("inspect")) return {
786
+ kind: "error",
787
+ message: `The ${a.component} "${n}" offers agents ${a.actions.length === 0 ? "no actions" : a.actions.join(", ")}, not inspect.`
788
+ };
789
+ let o = c(a.inspected), s = await e.act({ steps: [{
790
+ ref: a.ref,
791
+ action: "inspect",
792
+ args: [i]
793
+ }] });
794
+ await x();
795
+ let l = c(e.snapshot().find((e) => e.ref === a.ref)?.inspected);
796
+ return s.ok ? {
797
+ kind: "ok",
798
+ changed: o === l ? [] : [{
799
+ name: `${n} inspected`,
800
+ from: o,
801
+ to: l
802
+ }]
803
+ } : {
804
+ kind: "error",
805
+ message: s.error?.message ?? "The bridge refused the step."
806
+ };
807
+ }
808
+ }
809
+ ];
810
+ }
811
+ export { S as LEARNER_TRACE_LIMIT, k as createLearnerTrace, U as playTour, I as summarizeTrace, J as tourFromTrace, L as tourHolds, ne as tutorTools, q as validateTour };