@pie-players/pie-assessment-toolkit 0.3.74 → 1.0.0-beta.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 (257) hide show
  1. package/README.md +658 -714
  2. package/custom-elements.json +1315 -0
  3. package/dist/attempt/TestSession.d.ts +1 -21
  4. package/dist/attempt/TestSession.js +16 -102
  5. package/dist/components/ItemScope.custom-element.d.ts +1 -0
  6. package/dist/components/ItemScope.custom-element.js +1 -0
  7. package/dist/components/ItemToolBar.custom-element.js +1 -1
  8. package/dist/components/PieAssessmentToolkit.custom-element.js +14 -14
  9. package/dist/components/SectionToolBar.custom-element.js +1 -1
  10. package/dist/components/chunks/ItemToolBar-3zrc4p3d.js +4 -0
  11. package/dist/components/chunks/ItemToolBar-66hcwmfw.js +2 -0
  12. package/dist/components/chunks/ItemToolBar-9gqhfxtn.js +40 -0
  13. package/dist/components/chunks/ItemToolBar-hzc5wyjp.js +2 -0
  14. package/dist/components/chunks/{ItemToolBar-gmrryv2v.js → ItemToolBar-kkj69ptr.js} +1 -1
  15. package/dist/components/chunks/ItemToolBar-vdkyn9f3.js +2 -0
  16. package/dist/components/chunks/sre-engine-bj997w4b.js +1 -0
  17. package/dist/components/item-scope-element.d.ts +2 -0
  18. package/dist/components/item-scope-element.js +2 -0
  19. package/dist/context/assessment-toolkit-context.d.ts +33 -6
  20. package/dist/index.d.ts +25 -50
  21. package/dist/index.js +15 -45
  22. package/dist/policy/core/PolicySource.d.ts +2 -2
  23. package/dist/policy/core/ToolPolicyEngine.d.ts +118 -34
  24. package/dist/policy/core/ToolPolicyEngine.js +203 -56
  25. package/dist/policy/core/compose-decision.d.ts +28 -7
  26. package/dist/policy/core/compose-decision.js +95 -74
  27. package/dist/policy/core/decision-types.d.ts +98 -55
  28. package/dist/policy/core/feature-decision.d.ts +28 -19
  29. package/dist/policy/core/feature-decision.js +15 -11
  30. package/dist/policy/core/pnp-policy-inputs.d.ts +29 -35
  31. package/dist/policy/core/pnp-policy-inputs.js +40 -88
  32. package/dist/policy/core/provenance.d.ts +10 -5
  33. package/dist/policy/core/provenance.js +1 -1
  34. package/dist/policy/core/tool-parameters.d.ts +11 -0
  35. package/dist/policy/core/tool-parameters.js +15 -0
  36. package/dist/policy/engine.d.ts +7 -23
  37. package/dist/policy/engine.js +5 -20
  38. package/dist/policy/sources/PnpPolicySource.d.ts +43 -68
  39. package/dist/policy/sources/PnpPolicySource.js +133 -132
  40. package/dist/runtime/SectionControllerBinding.d.ts +283 -0
  41. package/dist/runtime/SectionControllerBinding.js +456 -0
  42. package/dist/runtime/SectionRuntimeEngine.d.ts +26 -289
  43. package/dist/runtime/SectionRuntimeEngine.js +30 -372
  44. package/dist/runtime/adapter/SectionEngineAdapter.d.ts +19 -80
  45. package/dist/runtime/adapter/SectionEngineAdapter.js +19 -92
  46. package/dist/runtime/adapter/dom-event-bridge.d.ts +15 -30
  47. package/dist/runtime/adapter/dom-event-bridge.js +17 -44
  48. package/dist/runtime/adapter/subscriber-fanout.d.ts +1 -3
  49. package/dist/runtime/adapter/subscriber-fanout.js +2 -6
  50. package/dist/runtime/catalog-context.d.ts +19 -0
  51. package/dist/runtime/catalog-context.js +28 -0
  52. package/dist/runtime/composition-emit-scheduler.d.ts +12 -18
  53. package/dist/runtime/composition-emit-scheduler.js +10 -16
  54. package/dist/runtime/content-language.d.ts +32 -0
  55. package/dist/runtime/content-language.js +46 -0
  56. package/dist/runtime/content-region.d.ts +13 -0
  57. package/dist/runtime/content-region.js +29 -0
  58. package/dist/runtime/content-registration.d.ts +13 -0
  59. package/dist/runtime/content-registration.js +25 -0
  60. package/dist/runtime/core/SectionEngineCore.d.ts +2 -4
  61. package/dist/runtime/core/SectionEngineCore.js +2 -6
  62. package/dist/runtime/core/cohort.d.ts +1 -6
  63. package/dist/runtime/core/cohort.js +1 -10
  64. package/dist/runtime/core/engine-input.d.ts +18 -30
  65. package/dist/runtime/core/engine-input.js +11 -12
  66. package/dist/runtime/core/engine-output.d.ts +17 -40
  67. package/dist/runtime/core/engine-output.js +9 -21
  68. package/dist/runtime/core/engine-readiness.d.ts +5 -37
  69. package/dist/runtime/core/engine-readiness.js +8 -41
  70. package/dist/runtime/core/engine-resolver.d.ts +46 -74
  71. package/dist/runtime/core/engine-resolver.js +18 -43
  72. package/dist/runtime/core/engine-state.d.ts +28 -36
  73. package/dist/runtime/core/engine-state.js +18 -21
  74. package/dist/runtime/core/engine-transition.d.ts +14 -19
  75. package/dist/runtime/core/engine-transition.js +74 -53
  76. package/dist/runtime/engine.d.ts +16 -19
  77. package/dist/runtime/engine.js +12 -19
  78. package/dist/runtime/page-warnings.d.ts +13 -0
  79. package/dist/runtime/page-warnings.js +22 -0
  80. package/dist/runtime/policy-input-forwarding.d.ts +25 -0
  81. package/dist/runtime/policy-input-forwarding.js +25 -0
  82. package/dist/runtime/registration-events.d.ts +22 -14
  83. package/dist/runtime/runtime-event-claim.d.ts +8 -0
  84. package/dist/runtime/runtime-event-claim.js +15 -0
  85. package/dist/runtime/runtime-id.d.ts +1 -1
  86. package/dist/runtime/runtime-id.js +1 -1
  87. package/dist/runtime/shell-event-bridge.d.ts +45 -0
  88. package/dist/runtime/shell-event-bridge.js +127 -0
  89. package/dist/runtime/shell-registration.d.ts +73 -0
  90. package/dist/runtime/shell-registration.js +95 -0
  91. package/dist/runtime/shell-scope.d.ts +68 -0
  92. package/dist/runtime/shell-scope.js +194 -0
  93. package/dist/runtime/tool-host-contract.d.ts +8 -14
  94. package/dist/runtime/tool-host-contract.js +12 -12
  95. package/dist/runtime/unclaimed-registration-watch.d.ts +7 -0
  96. package/dist/runtime/unclaimed-registration-watch.js +23 -0
  97. package/dist/services/AccessibilityCatalogResolver.d.ts +21 -31
  98. package/dist/services/AccessibilityCatalogResolver.js +29 -42
  99. package/dist/services/ElementToolStateStore.d.ts +42 -67
  100. package/dist/services/ElementToolStateStore.js +65 -71
  101. package/dist/services/HighlightCoordinator.d.ts +28 -40
  102. package/dist/services/HighlightCoordinator.js +459 -381
  103. package/dist/services/RangeSerializer.d.ts +11 -33
  104. package/dist/services/RangeSerializer.js +88 -59
  105. package/dist/services/SSMLExtractor.d.ts +8 -31
  106. package/dist/services/SSMLExtractor.js +18 -40
  107. package/dist/services/TTSService.d.ts +159 -119
  108. package/dist/services/TTSService.js +937 -822
  109. package/dist/services/ToolCoordinator.d.ts +42 -102
  110. package/dist/services/ToolCoordinator.js +178 -256
  111. package/dist/services/ToolRegistry.d.ts +152 -133
  112. package/dist/services/ToolRegistry.js +192 -178
  113. package/dist/services/ToolkitCoordinator.d.ts +233 -237
  114. package/dist/services/ToolkitCoordinator.js +615 -557
  115. package/dist/services/audio-handoff.d.ts +6 -7
  116. package/dist/services/audio-handoff.js +20 -14
  117. package/dist/services/catalog-owner.d.ts +0 -1
  118. package/dist/services/framework-error-bus.d.ts +3 -6
  119. package/dist/services/framework-error-bus.js +3 -6
  120. package/dist/services/framework-error.d.ts +51 -13
  121. package/dist/services/framework-error.js +19 -20
  122. package/dist/services/interfaces.d.ts +189 -184
  123. package/dist/services/section-controller-types.d.ts +7 -7
  124. package/dist/services/section-session-assignment.d.ts +21 -0
  125. package/dist/services/section-session-assignment.js +80 -0
  126. package/dist/services/spoken-audio-cards.d.ts +2 -6
  127. package/dist/services/spoken-audio-cards.js +2 -6
  128. package/dist/services/tool-config-defaults.d.ts +3 -3
  129. package/dist/services/tool-config-defaults.js +3 -3
  130. package/dist/services/tool-config-validation.d.ts +9 -12
  131. package/dist/services/tool-config-validation.js +47 -87
  132. package/dist/services/tool-context.d.ts +7 -31
  133. package/dist/services/tool-context.js +99 -65
  134. package/dist/services/tool-failure.d.ts +30 -0
  135. package/dist/services/tool-failure.js +11 -0
  136. package/dist/services/tool-icons.d.ts +5 -5
  137. package/dist/services/tool-icons.js +6 -5
  138. package/dist/services/tool-instance-id.d.ts +8 -7
  139. package/dist/services/tool-instance-id.js +12 -24
  140. package/dist/services/tool-providers/TTSToolProvider.d.ts +20 -58
  141. package/dist/services/tool-providers/TTSToolProvider.js +32 -85
  142. package/dist/services/tool-providers/ToolProviderApi.d.ts +10 -11
  143. package/dist/services/tool-providers/ToolProviderRegistry.d.ts +29 -60
  144. package/dist/services/tool-providers/ToolProviderRegistry.js +128 -144
  145. package/dist/services/tool-request.d.ts +31 -12
  146. package/dist/services/tool-request.js +31 -16
  147. package/dist/services/toolbar-decided-tools.d.ts +16 -0
  148. package/dist/services/toolbar-decided-tools.js +29 -0
  149. package/dist/services/toolbar-items.js +2 -5
  150. package/dist/services/tools-config-normalizer.d.ts +33 -29
  151. package/dist/services/tools-config-normalizer.js +26 -28
  152. package/dist/services/tts/browser-provider.d.ts +39 -6
  153. package/dist/services/tts/browser-provider.js +280 -160
  154. package/dist/services/tts/catalog-span-alignment.js +14 -7
  155. package/dist/services/tts/flat-tree.d.ts +64 -0
  156. package/dist/services/tts/flat-tree.js +269 -0
  157. package/dist/services/tts/generated-speech/assemble-plan.d.ts +3 -1
  158. package/dist/services/tts/generated-speech/assemble-plan.js +3 -1
  159. package/dist/services/tts/generated-speech/dom/build-dom-plan.d.ts +2 -0
  160. package/dist/services/tts/generated-speech/dom/build-dom-plan.js +1 -1
  161. package/dist/services/tts/generated-speech/dom/to-chunk-inputs.d.ts +2 -2
  162. package/dist/services/tts/generated-speech/index.d.ts +1 -1
  163. package/dist/services/tts/generated-speech/index.js +1 -1
  164. package/dist/services/tts/generated-speech/math-speech-cache.d.ts +3 -1
  165. package/dist/services/tts/generated-speech/math-speech-cache.js +5 -1
  166. package/dist/services/tts/generated-speech/types.d.ts +1 -1
  167. package/dist/services/tts/generated-speech/types.js +1 -1
  168. package/dist/services/tts/highlight-pipeline/create-highlight-plan.js +22 -16
  169. package/dist/services/tts/highlight-pipeline/prose-boundary-resolver.js +6 -4
  170. package/dist/services/tts/highlight-pipeline/readable-region.js +3 -2
  171. package/dist/services/tts/highlight-pipeline/types.d.ts +5 -0
  172. package/dist/services/tts/highlight-pipeline/visible-map-range.d.ts +12 -0
  173. package/dist/services/tts/highlight-pipeline/visible-map-range.js +73 -7
  174. package/dist/services/tts/highlight-target-resolver.d.ts +12 -0
  175. package/dist/services/tts/math-aware-text-processing.d.ts +5 -1
  176. package/dist/services/tts/math-aware-text-processing.js +42 -47
  177. package/dist/services/tts/math-control-names.d.ts +21 -0
  178. package/dist/services/tts/math-control-names.js +142 -0
  179. package/dist/services/tts/math-speech.d.ts +12 -1
  180. package/dist/services/tts/math-speech.js +54 -18
  181. package/dist/services/tts/mathml-sanitization.d.ts +7 -0
  182. package/dist/services/tts/mathml-sanitization.js +9 -1
  183. package/dist/services/tts/provider-options.d.ts +52 -0
  184. package/dist/services/tts/provider-options.js +1 -0
  185. package/dist/services/tts/ssml/spoken-text.d.ts +2 -26
  186. package/dist/services/tts/ssml/spoken-text.js +29 -0
  187. package/dist/services/tts/start-failure.d.ts +4 -0
  188. package/dist/services/tts/start-failure.js +19 -0
  189. package/dist/services/tts/text-processing.d.ts +9 -0
  190. package/dist/services/tts/text-processing.js +46 -33
  191. package/dist/services/tts/text-segmentation.d.ts +12 -0
  192. package/dist/services/tts/text-segmentation.js +60 -10
  193. package/dist/services/tts-runtime-config.d.ts +54 -26
  194. package/dist/services/tts-runtime-config.js +27 -112
  195. package/dist/tools/content-capability-resolution.d.ts +9 -11
  196. package/dist/tools/content-capability-resolution.js +8 -45
  197. package/dist/tools/registration.d.ts +59 -0
  198. package/dist/tools/registration.js +55 -0
  199. package/dist/tools/registrations/toolbar-registration-helpers.d.ts +6 -0
  200. package/dist/tools/registrations/toolbar-registration-helpers.js +8 -2
  201. package/dist/tools/tool-surface-host.d.ts +6 -10
  202. package/dist/tools/tool-surface-host.js +45 -50
  203. package/dist/tools/tool-tag-map.d.ts +5 -15
  204. package/dist/tools/tool-tag-map.js +6 -20
  205. package/dist/utils/structural-equality.d.ts +11 -0
  206. package/dist/utils/structural-equality.js +47 -0
  207. package/package.json +15 -29
  208. package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +0 -49
  209. package/dist/attempt/adapters/activity-to-test-attempt-session.js +0 -138
  210. package/dist/components/chunks/ItemToolBar-b9dz5jvd.js +0 -40
  211. package/dist/components/chunks/ItemToolBar-h4xap0t0.js +0 -4
  212. package/dist/components/chunks/ItemToolBar-wr2myaah.js +0 -2
  213. package/dist/components/chunks/sre-engine-wf9s43gg.js +0 -1
  214. package/dist/context/runtime-context-consumer.d.ts +0 -13
  215. package/dist/context/runtime-context-consumer.js +0 -18
  216. package/dist/item-loader.d.ts +0 -44
  217. package/dist/item-loader.js +0 -61
  218. package/dist/policy/core/engine-context.d.ts +0 -29
  219. package/dist/policy/core/engine-context.js +0 -27
  220. package/dist/policy/core/policy-source-tag.d.ts +0 -31
  221. package/dist/policy/core/policy-source-tag.js +0 -28
  222. package/dist/policy/internal.d.ts +0 -25
  223. package/dist/policy/internal.js +0 -25
  224. package/dist/runtime/adapter/coordinator-bridge.d.ts +0 -92
  225. package/dist/runtime/adapter/coordinator-bridge.js +0 -126
  226. package/dist/runtime/adapter/framework-error-bridge.d.ts +0 -36
  227. package/dist/runtime/adapter/framework-error-bridge.js +0 -46
  228. package/dist/runtime/adapter/instrumentation-bridge.d.ts +0 -31
  229. package/dist/runtime/adapter/instrumentation-bridge.js +0 -38
  230. package/dist/runtime/core/engine-stage-derivation.d.ts +0 -18
  231. package/dist/runtime/core/engine-stage-derivation.js +0 -29
  232. package/dist/runtime/engine-context.d.ts +0 -39
  233. package/dist/runtime/engine-context.js +0 -31
  234. package/dist/runtime/internal.d.ts +0 -43
  235. package/dist/runtime/internal.js +0 -45
  236. package/dist/runtime/section-runtime-engine-host-context.d.ts +0 -74
  237. package/dist/runtime/section-runtime-engine-host-context.js +0 -57
  238. package/dist/runtime/stage-emit-gate.d.ts +0 -92
  239. package/dist/runtime/stage-emit-gate.js +0 -82
  240. package/dist/services/ContextVariableStore.d.ts +0 -113
  241. package/dist/services/ContextVariableStore.js +0 -206
  242. package/dist/services/I18nService.d.ts +0 -47
  243. package/dist/services/I18nService.js +0 -84
  244. package/dist/services/ThemeProvider.d.ts +0 -95
  245. package/dist/services/ThemeProvider.js +0 -334
  246. package/dist/services/defaultPersonalNeedsProfile.d.ts +0 -21
  247. package/dist/services/defaultPersonalNeedsProfile.js +0 -26
  248. package/dist/services/pnp-standard-features.d.ts +0 -238
  249. package/dist/services/pnp-standard-features.js +0 -338
  250. package/dist/services/tts-control-events.d.ts +0 -13
  251. package/dist/services/tts-control-events.js +0 -7
  252. package/dist/tools/client.d.ts +0 -10
  253. package/dist/tools/client.js +0 -10
  254. package/dist/tools/internal.d.ts +0 -44
  255. package/dist/tools/internal.js +0 -39
  256. package/dist/utils/logger.d.ts +0 -6
  257. package/dist/utils/logger.js +0 -10
@@ -1,18 +1,31 @@
1
1
  /**
2
- * Tool Registry
2
+ * Tool registry: the registration contract every tool declares itself with,
3
+ * the shape validation `register` and `override` run, and the `ToolRegistry`
4
+ * class.
3
5
  *
4
- * Central registry for all assessment tools. Manages tool metadata, visibility logic,
5
- * and button/instance creation. Supports dynamic registration and override by integrators.
6
+ * Layout: the exported contract types come first, ending with
7
+ * `ToolRegistration`, then `assertToolRegistrationShape`, then the class. Its
8
+ * members run from mutation and change observation, through queries and the
9
+ * filters for the second and third passes of tool resolution (relevance in
10
+ * `filterVisibleInContext`, applicability in `filterDecidedToolIds`; the policy
11
+ * engine owns the first), to module loading with its undefined-element
12
+ * warnings and the toolbar and surface render helpers.
6
13
  */
7
14
  import type { I18nProvider } from "@pie-players/pie-players-shared/i18n/types";
15
+ import type { ToolParametersFor } from "@pie-players/pie-players-shared/types";
8
16
  import type { CatalogOwnerSnapshot } from "./AccessibilityCatalogResolver.js";
17
+ import type { ToolPolicyEntry } from "../policy/core/decision-types.js";
9
18
  import type { ToolContext, ToolLevel } from "./tool-context.js";
10
- import type { ToolComponentOverrides } from "../tools/tool-tag-map.js";
19
+ import type { ToolScopeLevel } from "./tool-instance-id.js";
20
+ import { type ToolComponentOverrides } from "../tools/tool-tag-map.js";
11
21
  import type { AccessibilityCatalogResolverApi, ElementToolStateStoreApi, ToolCoordinatorApi, ToolkitCoordinatorApi, TtsServiceApi } from "./interfaces.js";
12
22
  import type { ToolProviderApi } from "./tool-providers/ToolProviderApi.js";
13
- import type { ToolProviderConfig as ToolRuntimeConfig } from "./tools-config-normalizer.js";
23
+ import type { ToolProviderConfig } from "./tools-config-normalizer.js";
14
24
  import type { ToolConfigDiagnostic } from "./tool-config-validation.js";
25
+ import type { ToolFailurePhase } from "./tool-failure.js";
15
26
  export type ToolModuleLoader = () => Promise<unknown>;
27
+ /** Receives a registration callback's throw, from which the registry recovers. */
28
+ export type ToolCallbackFailureHandler = (toolId: string, phase: Extract<ToolFailurePhase, "tool-visibility" | "tool-applicability">, error: unknown) => void;
16
29
  export type ToolRegistryChangeKind = "register" | "override" | "unregister" | "clear" | "component-overrides" | "module-loaders";
17
30
  /** A successful mutation to discoverable or rendering registry state. */
18
31
  export interface ToolRegistryChangeEvent {
@@ -24,18 +37,16 @@ export interface ToolToolbarButtonDefinition {
24
37
  toolId: string;
25
38
  label: string;
26
39
  /**
27
- * Optional to match what the renderer already does: `ItemToolBar.svelte`
28
- * guards on `button.icon`, and `ToolbarItem.icon` is
29
- * already optional, so requiring it here claimed a guarantee nothing relied
30
- * on. A registration that renders a button still has to declare an icon —
40
+ * Optional to match the renderer: `ItemToolBar.svelte` guards on
41
+ * `button.icon`, and `ToolbarItem.icon` is optional too. A registration that
42
+ * renders a button still has to declare an icon —
31
43
  * `assertToolRegistrationShape` enforces that.
32
44
  */
33
45
  icon?: string;
34
46
  /**
35
47
  * FontAwesome icon name, opting this button into `<nds-icon-button>` rendering
36
48
  * where the host enables NDS icons (`ndsIcons`). Absent means the toolbar keeps
37
- * its own button rendering, which is what every capability got before the NDS
38
- * button existed.
49
+ * its own button rendering.
39
50
  *
40
51
  * A declaration rather than a toolId lookup in the toolbar: which capabilities
41
52
  * a deployment renders through the host's design system is a composition-layer
@@ -51,7 +62,7 @@ export interface ToolToolbarButtonDefinition {
51
62
  }
52
63
  export interface ToolbarContext {
53
64
  scope: {
54
- level: ToolLevel;
65
+ level: ToolScopeLevel;
55
66
  scopeId: string;
56
67
  assessmentId?: string;
57
68
  sectionId?: string;
@@ -65,9 +76,10 @@ export interface ToolbarContext {
65
76
  * Content-alternate language: which authored alternate the catalog resolver
66
77
  * should select. Not the interface locale — see {@link ToolbarContext.i18n}. The
67
78
  * two are independent by QTI 3's own statement, and conflating them is how a
68
- * Spanish passage ends up forcing Spanish widget chrome.
79
+ * Spanish passage ends up forcing Spanish widget chrome. Absent when neither
80
+ * the toolbar's `language` nor the host's `content-language` names one.
69
81
  */
70
- language: string;
82
+ language?: string;
71
83
  /**
72
84
  * Interface-locale provider for this capability's own UI strings.
73
85
  *
@@ -83,17 +95,30 @@ export interface ToolbarContext {
83
95
  size?: string;
84
96
  };
85
97
  getScopeElement?: () => HTMLElement | null;
86
- getGlobalElementId?: () => string | null;
98
+ /**
99
+ * State key of one PIE element in this toolbar's item, by its model id, for
100
+ * `elementToolStateStore`. `null` until the store and the ids it needs are
101
+ * known.
102
+ */
103
+ getGlobalElementId?: (elementId: string) => string | null;
87
104
  toolCoordinator: ToolCoordinatorApi | null;
88
105
  toolkitCoordinator: ToolkitCoordinatorApi | null;
89
106
  ttsService: TtsServiceApi | null;
90
107
  elementToolStateStore: ElementToolStateStoreApi | null;
108
+ /** Toggles this toolbar's instance of a base tool id. */
91
109
  toggleTool: (toolId: string) => void;
110
+ /** Whether this toolbar's instance of a base tool id is shown. */
92
111
  isToolVisible: (toolId: string) => boolean;
93
112
  subscribeVisibility: ((listener: () => void) => () => void) | null;
94
113
  componentOverrides?: ToolComponentOverrides;
95
114
  getResolvedToolContext?: (toolId: string) => ResolvedToolContext | null;
96
115
  getToolRenderParams?: (toolId: string) => Record<string, unknown> | null;
116
+ /**
117
+ * The tool's policy parameters on this toolbar: the item's `toolParameters`
118
+ * entry on an item's own toolbar, else the assessment's `toolParameters` entry.
119
+ * Authored content, so a registration checks what it reads.
120
+ */
121
+ getToolParameters?: <K extends string>(toolId: K) => ToolParametersFor<K> | null;
97
122
  }
98
123
  export interface ToolContextResolverContext {
99
124
  toolId: string;
@@ -207,24 +232,18 @@ export interface HostedToolSize {
207
232
  width: number;
208
233
  height: number;
209
234
  }
235
+ /**
236
+ * How the coordinator builds a tool's provider from the tool's config. The
237
+ * provider registers under the tool's own id, so `ensureProviderReady(toolId)`
238
+ * finds it; `provider.id` in the config selects an implementation and never
239
+ * renames the registration.
240
+ */
210
241
  export interface ToolProviderDescriptor {
211
- getProviderId?: (config: ToolRuntimeConfig | undefined) => string;
212
- createProvider: (config: ToolRuntimeConfig | undefined) => ToolProviderApi;
213
- getInitConfig?: (config: ToolRuntimeConfig | undefined) => Record<string, unknown>;
214
- sanitizeConfig?: (config: ToolRuntimeConfig) => ToolRuntimeConfig;
215
- validateConfig?: (config: ToolRuntimeConfig) => ToolConfigDiagnostic[];
216
- getAuthFetcher?: (config: ToolRuntimeConfig | undefined) => (() => Promise<Record<string, unknown>>) | undefined;
242
+ createProvider: (config: ToolProviderConfig | undefined) => ToolProviderApi;
243
+ getInitConfig?: (config: ToolProviderConfig | undefined) => Record<string, unknown>;
244
+ getAuthFetcher?: (config: ToolProviderConfig | undefined) => (() => Promise<Record<string, unknown>>) | undefined;
217
245
  lazy?: boolean;
218
246
  }
219
- /**
220
- * The id a registration's provider registers under for one tool config: the
221
- * descriptor's answer, then the config's `provider.id`, then the tool id. `null`
222
- * when the registration carries no provider.
223
- *
224
- * The coordinator registers providers under this id and the section player looks
225
- * for them in a host-supplied coordinator by it, so the two resolve it one way.
226
- */
227
- export declare function resolveToolProviderId(registration: Pick<ToolRegistration, "toolId" | "provider">, config: ToolRuntimeConfig | undefined): string | null;
228
247
  export interface ToolToolbarRenderResult {
229
248
  toolId: string;
230
249
  elements?: ToolRenderElement[];
@@ -280,12 +299,18 @@ export interface ToolSurfaceServices {
280
299
  */
281
300
  export interface ToolSurfaceRenderContext {
282
301
  toolId: string;
283
- /** The PNP/AfA support id policy granted for this render. */
284
- featureId: string;
302
+ /**
303
+ * Whether a PNP support, a requirement or a test-administration override
304
+ * granted the capability. `false` for a capability rendered because it is
305
+ * placed with no grant, and for a
306
+ * {@link ToolRegistration.resolvesWithoutGrant} capability answering from
307
+ * content alone.
308
+ */
309
+ granted: boolean;
285
310
  /** Host slot being filled. */
286
311
  surface: string;
287
312
  /** Feature parameters from the policy decision, if any. */
288
- parameters?: unknown;
313
+ parameters?: Record<string, unknown>;
289
314
  /** Resolved content dependency, when the capability declares one. */
290
315
  content?: unknown;
291
316
  services: ToolSurfaceServices;
@@ -296,10 +321,8 @@ export interface ToolSurfaceRenderContext {
296
321
  * present.
297
322
  */
298
323
  export interface ToolContentDependencyContext {
299
- /** The PNP/AfA support id being resolved. */
300
- featureId: string;
301
324
  /** Feature parameters from the policy decision, if any. */
302
- parameters?: unknown;
325
+ parameters?: Record<string, unknown>;
303
326
  /**
304
327
  * Owner-scoped catalog cards, or `null` when no resolver is available.
305
328
  *
@@ -309,7 +332,7 @@ export interface ToolContentDependencyContext {
309
332
  */
310
333
  catalogs: CatalogOwnerSnapshot | null;
311
334
  /**
312
- * Whether policy granted one of this capability's support ids.
335
+ * Whether policy granted this capability's support id.
313
336
  *
314
337
  * `false` reaches `resolve` only for a capability that declares
315
338
  * {@link ToolRegistration.resolvesWithoutGrant}, and it is the signal that the
@@ -327,8 +350,8 @@ export interface ToolContentDependencyContext {
327
350
  * It is intrinsic to the capability, unlike eligibility tier, which is a property
328
351
  * of the program.
329
352
  *
330
- * Two independent things follow from declaring it, and both used to be done by
331
- * naming ids in core:
353
+ * Two independent things follow from declaring it, neither of which needs core
354
+ * to name a capability id:
332
355
  *
333
356
  * 1. **Availability is grant AND content.** The host renders only when policy
334
357
  * granted the feature *and* `resolve` returned something. Neither half
@@ -392,7 +415,8 @@ export interface ToolSurfaceRenderResult {
392
415
  destroy?: () => void;
393
416
  }
394
417
  /**
395
- * Tool registration interface
418
+ * The contract a tool declares itself with; `ToolRegistry.register` validates
419
+ * its shape.
396
420
  */
397
421
  export interface ToolRegistration {
398
422
  /** Unique tool identifier (e.g., 'calculator', 'textToSpeech') */
@@ -448,12 +472,6 @@ export interface ToolRegistration {
448
472
  * Optional singleton scope for activation models that mount exactly one instance.
449
473
  */
450
474
  singletonScope?: ToolSingletonScope;
451
- /**
452
- * PNP support IDs that enable this tool (optional)
453
- * Used by the tool policy engine to determine if a PNP support enables this tool.
454
- * Example: ['calculator', 'basic-calculator', 'scientific-calculator']
455
- */
456
- pnpSupportIds?: string[];
457
475
  /**
458
476
  * Authored content this capability needs before it has anything to show.
459
477
  *
@@ -484,6 +502,16 @@ export interface ToolRegistration {
484
502
  * without hardcoded tool-specific branches.
485
503
  */
486
504
  provider?: ToolProviderDescriptor;
505
+ /**
506
+ * Normalize this tool's `tools.providers.<toolId>` entry. Tools-config
507
+ * validation runs it before {@link ToolRegistration.validateConfig}; a throw is
508
+ * reported as a diagnostic and the entry passes through unchanged.
509
+ */
510
+ sanitizeConfig?: (config: ToolProviderConfig) => ToolProviderConfig;
511
+ /**
512
+ * Diagnostics for this tool's sanitized `tools.providers.<toolId>` entry.
513
+ */
514
+ validateConfig?: (config: ToolProviderConfig) => ToolConfigDiagnostic[];
487
515
  /**
488
516
  * Optional shell-host lifecycle hooks for hosted (floating) tools.
489
517
  */
@@ -491,17 +519,14 @@ export interface ToolRegistration {
491
519
  onHostedResize?: (size: HostedToolSize, element: HTMLElement, context: HostedToolContext) => void | Promise<void>;
492
520
  onHostedUnmount?: (element: HTMLElement, context: HostedToolContext) => void | Promise<void>;
493
521
  /**
494
- * Pass 2: Tool decides if it's relevant in this context
495
- * Called ONLY if orchestrator has already allowed the tool (Pass 1)
522
+ * Whether the tool is relevant in this context (pass 2). Asked only for a
523
+ * tool policy already allows (pass 1).
496
524
  *
497
525
  * Required for the toolbar activations, and meaningless for `activation:
498
526
  * "region"`: a region capability has no toolbar presence to be relevant to, and
499
527
  * the question it *would* answer — is there anything to show here — is
500
528
  * `requiresAuthoredContent`. A registration that omits this is never returned
501
- * by `getVisibleTools`.
502
- *
503
- * @param context - Rich context about where tool is being evaluated
504
- * @returns true if tool should be visible, false to hide
529
+ * by `filterVisibleInContext`.
505
530
  */
506
531
  isVisibleInContext?(context: ToolContext): boolean;
507
532
  /**
@@ -519,9 +544,6 @@ export interface ToolRegistration {
519
544
  * Declare this only where the tool's own controls provably do nothing:
520
545
  * withdrawing a granted accommodation on a false negative is the more
521
546
  * expensive failure. Omitting it means "applicable".
522
- *
523
- * @param context - The item or element context the tool would act on
524
- * @returns false to withdraw the tool from this context
525
547
  */
526
548
  isApplicableToContent?(context: ToolContext): boolean;
527
549
  /**
@@ -547,10 +569,12 @@ export interface ToolRegistration {
547
569
  */
548
570
  export declare class ToolRegistry {
549
571
  private tools;
550
- private pnpIndex;
551
572
  private componentOverrides;
573
+ private watchedUndefinedToolElements;
552
574
  private moduleLoaders;
553
575
  private loadedToolModules;
576
+ private warnedLoaderReplacements;
577
+ private warnedUnregisteredAllowedTools;
554
578
  private moduleLoadPromises;
555
579
  private changeListeners;
556
580
  private emitChange;
@@ -560,71 +584,33 @@ export declare class ToolRegistry {
560
584
  */
561
585
  onRegistryChange(listener: ToolRegistryChangeListener): () => void;
562
586
  /**
563
- * Normalize a single tool alias to canonical toolId.
587
+ * Normalize a single tool id (trims surrounding whitespace).
564
588
  */
565
589
  normalizeToolId(toolId: string): string;
566
590
  /**
567
- * Normalize a list of tool aliases to canonical toolIds.
591
+ * Normalize a list of tool ids (trims surrounding whitespace).
568
592
  */
569
593
  normalizeToolIds(toolIds: string[]): string[];
570
594
  /**
571
- * Register a tool
572
- *
573
- * @param registration - Tool registration
574
- * @throws Error if toolId is already registered
595
+ * Register a tool. Throws when its `toolId` is already registered.
575
596
  */
576
597
  register(registration: ToolRegistration): void;
577
598
  /**
578
- * Override an existing tool registration
579
- *
580
- * @param registration - New tool registration (must have existing toolId)
599
+ * Replace an existing tool registration. Throws when its `toolId` is not
600
+ * registered.
581
601
  */
582
602
  override(registration: ToolRegistration): void;
583
603
  /**
584
- * Unregister a tool
585
- *
586
- * @param toolId - Tool ID to remove
604
+ * Unregister a tool. An unknown id is a no-op and emits no change.
587
605
  */
588
606
  unregister(toolId: string): void;
589
- /**
590
- * Get a tool registration by ID
591
- *
592
- * @param toolId - Tool ID
593
- * @returns Tool registration or undefined
594
- */
595
607
  get(toolId: string): ToolRegistration | undefined;
596
- /**
597
- * Check if a tool is registered
598
- *
599
- * @param toolId - Tool ID
600
- * @returns true if registered
601
- */
602
608
  has(toolId: string): boolean;
603
- /**
604
- * Get all registered tool IDs
605
- *
606
- * @returns Array of tool IDs
607
- */
609
+ /** Registered tool ids, in registration order. */
608
610
  getAllToolIds(): string[];
609
- /**
610
- * Get all tool registrations
611
- *
612
- * @returns Array of tool registrations
613
- */
611
+ /** Registrations, in registration order. */
614
612
  getAllTools(): ToolRegistration[];
615
- /**
616
- * Find tool IDs that support a given PNP support ID
617
- *
618
- * @param pnpSupportId - PNP support ID (e.g., 'calculator')
619
- * @returns Set of tool IDs that support this PNP ID
620
- */
621
- getToolsByPNPSupport(pnpSupportId: string): Set<string>;
622
- /**
623
- * Get tools that support a specific level
624
- *
625
- * @param level - Tool level (assessment, section, item, passage, element)
626
- * @returns Array of tool registrations that support this level
627
- */
613
+ /** Registrations whose `supportedLevels` include `level`. */
628
614
  getToolsByLevel(level: ToolLevel): ToolRegistration[];
629
615
  /**
630
616
  * Resolve tool activation, defaulting to toolbar-toggle.
@@ -644,11 +630,12 @@ export declare class ToolRegistry {
644
630
  */
645
631
  getToolsBySurface(surface: string): ToolRegistration[];
646
632
  /**
647
- * Support ids belonging to capabilities that need authored content.
633
+ * Support ids, which are tool ids, of the capabilities that need authored
634
+ * content.
648
635
  *
649
- * What a host filters a default grant list on, in place of the compile-time
650
- * exclusion array this replaced: granting one of these wholesale grants an
651
- * accommodation to learners with no documented need for it.
636
+ * What a host filters a default grant list on: granting one of these
637
+ * wholesale grants an accommodation to learners with no documented need
638
+ * for it.
652
639
  */
653
640
  getContentDependentSupportIds(): string[];
654
641
  /**
@@ -656,16 +643,14 @@ export declare class ToolRegistry {
656
643
  */
657
644
  filterToolIdsByActivation(toolIds: string[], activation: ToolActivation): string[];
658
645
  /**
659
- * Filter tools by visibility in a given context
646
+ * Pass 2 of tool resolution: the registrations among `allowedToolIds` (the
647
+ * ids policy allowed in pass 1) that support `context.level` and answer
648
+ * `isVisibleInContext` with `true`.
660
649
  *
661
- * Pass 2 of the two-pass model: Given a list of allowed tool IDs (from Pass 1),
662
- * ask each tool if it's relevant in this context.
663
- *
664
- * @param allowedToolIds - Tool IDs that passed Pass 1 (orchestrator approval)
665
- * @param context - Context to evaluate
666
- * @returns Array of visible tool registrations
650
+ * @param onFailure - Receives a relevance check's throw; the tool is then not
651
+ * visible. Logs when omitted.
667
652
  */
668
- filterVisibleInContext(allowedToolIds: string[], context: ToolContext): ToolRegistration[];
653
+ filterVisibleInContext(allowedToolIds: string[], context: ToolContext, onFailure?: ToolCallbackFailureHandler): ToolRegistration[];
669
654
  /**
670
655
  * Whether a tool can act on any of the contexts it would be placed against.
671
656
  * Unlike the relevance pass this is a veto: a `false` here removes the tool
@@ -678,19 +663,39 @@ export declare class ToolRegistry {
678
663
  *
679
664
  * @param toolId - Tool to ask
680
665
  * @param contexts - Every context the tool could act on at this placement
666
+ * @param onFailure - Receives the gate's throw; the tool then counts as
667
+ * applicable. Logs when omitted.
681
668
  */
682
- isApplicableToAnyContext(toolId: string, contexts: readonly ToolContext[]): boolean;
669
+ isApplicableToAnyContext(toolId: string, contexts: readonly ToolContext[], onFailure?: ToolCallbackFailureHandler): boolean;
683
670
  /**
684
- * Get tool metadata for building UIs
685
- * Useful for building PNP configuration interfaces
671
+ * Passes 2 and 3 over a policy decision's tools: the ids a surface at `level`
672
+ * shows against `contexts`, in decision order. This is the rule a toolbar
673
+ * applies, for a host that builds its own tool surface.
674
+ *
675
+ * - A tool that does not support `level` is dropped.
676
+ * - Relevance (`isVisibleInContext`) keeps a tool visible in any one context.
677
+ * It does not run for a granted entry (`required` or `alwaysAvailable`),
678
+ * at section level, whose relevance is item-dependent, or when `contexts`
679
+ * is empty, since content that has not resolved cannot rule a tool out.
680
+ * - Applicability (`isApplicableToContent`) then removes a tool that can act
681
+ * on none of `contexts`, granted or not. It does not run at section level.
686
682
  *
687
- * @returns Array of tool metadata (id, name, description, pnpSupportIds)
683
+ * @param entries - The decision's surviving entries (Pass 1), such as
684
+ * `ToolPolicyDecision.visibleTools`
685
+ * @param level - The level of the surface the tools render on
686
+ * @param contexts - Every context the tools could act on at that surface
687
+ * @param onFailure - Receives a relevance or applicability check's throw.
688
+ * Logs when omitted.
689
+ */
690
+ filterDecidedToolIds(entries: readonly Pick<ToolPolicyEntry, "toolId" | "required" | "alwaysAvailable">[], level: ToolLevel, contexts: readonly ToolContext[], onFailure?: ToolCallbackFailureHandler): string[];
691
+ /**
692
+ * Plain metadata for every registration, in registration order, for UIs
693
+ * such as a PNP configuration screen.
688
694
  */
689
695
  getToolMetadata(): Array<{
690
696
  toolId: string;
691
697
  name: string;
692
698
  description: string;
693
- pnpSupportIds: string[];
694
699
  supportedLevels: ToolLevel[];
695
700
  activation: ToolActivation;
696
701
  singletonScope: ToolSingletonScope | null;
@@ -698,14 +703,6 @@ export declare class ToolRegistry {
698
703
  requiresAuthoredContent: boolean;
699
704
  contentDependencyDescription: string | null;
700
705
  }>;
701
- /**
702
- * Generate PNP support IDs from enabled tools
703
- * Useful for creating PNP profiles
704
- *
705
- * @param enabledToolIds - Tool IDs to enable
706
- * @returns Array of unique PNP support IDs
707
- */
708
- generatePNPSupportsFromTools(enabledToolIds: string[]): string[];
709
706
  /**
710
707
  * Clear all registrations (useful for testing)
711
708
  */
@@ -717,17 +714,39 @@ export declare class ToolRegistry {
717
714
  /**
718
715
  * Register lazy module loaders by toolId.
719
716
  * Toolbars call ensureToolModuleLoaded(toolId) before instance creation.
717
+ * A tool whose module has loaded, or is loading, keeps its loader: its
718
+ * elements are already defined, so a replacement could never take effect.
720
719
  */
721
720
  setToolModuleLoaders(loaders: Partial<Record<string, ToolModuleLoader>>): void;
721
+ private warnLoaderReplacedAfterLoad;
722
722
  /**
723
723
  * Ensure tool module side-effects are loaded exactly once.
724
724
  * Safe to call repeatedly; concurrent callers share the same promise.
725
725
  */
726
726
  ensureToolModuleLoaded(toolId: string): Promise<void>;
727
727
  /**
728
- * Ensure a set of tool modules are loaded.
728
+ * The undefined element tag a tool would render, or `null` when the tool is
729
+ * built by a component factory, its element is defined, or there is no DOM.
730
+ */
731
+ private undefinedToolElementTag;
732
+ /**
733
+ * Warn when a tool's module loader finished without defining the element the
734
+ * tag map points the tool at, as when a host remaps the tag but keeps a
735
+ * loader that defines the packaged element. The tool otherwise renders blank.
736
+ */
737
+ private warnIfLoadedToolElementUndefined;
738
+ /**
739
+ * Warn when a tool with no module loader still has no element definition
740
+ * after the pending-input delay. A registry built without loaders otherwise
741
+ * renders the tool as an unknown element with no error.
742
+ */
743
+ private watchUndefinedToolElement;
744
+ /**
745
+ * Load a set of tool modules, each to completion, and resolve with the error
746
+ * of every tool whose module failed, by tool id. One failure leaves the other
747
+ * tools loaded and usable. A failed tool is retried on the next call.
729
748
  */
730
- ensureToolModulesLoaded(toolIds: string[]): Promise<void>;
749
+ ensureToolModulesLoaded(toolIds: string[]): Promise<Map<string, unknown>>;
731
750
  /**
732
751
  * Whether a tool module has already been loaded.
733
752
  */
@@ -745,7 +764,7 @@ export declare class ToolRegistry {
745
764
  * nothing and fail on every packaged capability. Overrides passed in the
746
765
  * context still win, matching the toolbar path's precedence.
747
766
  */
748
- renderForSurface(toolId: string, context: Omit<ToolSurfaceRenderContext, "componentOverrides"> & {
749
- componentOverrides?: ToolComponentOverrides;
750
- }): ToolSurfaceRenderResult | null;
767
+ renderForSurface(toolId: string, context: ToolSurfaceRenderContext): ToolSurfaceRenderResult | null;
768
+ /** The registry's component overrides, with the caller's taking precedence. */
769
+ private mergeComponentOverrides;
751
770
  }