@pie-players/pie-assessment-toolkit 0.3.47 → 0.3.49

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 (86) hide show
  1. package/dist/attempt/AssessmentSession.js +2 -1
  2. package/dist/attempt/AssessmentSession.js.map +1 -1
  3. package/dist/attempt/adapters/activity-to-test-attempt-session.js +12 -8
  4. package/dist/attempt/adapters/activity-to-test-attempt-session.js.map +1 -1
  5. package/dist/components/ItemToolBar.custom-element.js +56 -17
  6. package/dist/components/PieAssessmentToolkit.custom-element.js +84 -29
  7. package/dist/components/SectionToolBar.custom-element.js +55 -17
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/policy/core/pnp-policy-inputs.js +1 -2
  11. package/dist/policy/core/pnp-policy-inputs.js.map +1 -1
  12. package/dist/policy/core/provenance.js.map +1 -1
  13. package/dist/runtime/SectionRuntimeEngine.js +1 -1
  14. package/dist/runtime/SectionRuntimeEngine.js.map +1 -1
  15. package/dist/runtime/core/cohort.js.map +1 -1
  16. package/dist/runtime/core/engine-input.js.map +1 -1
  17. package/dist/runtime/core/engine-readiness.js.map +1 -1
  18. package/dist/runtime/core/engine-resolver.js.map +1 -1
  19. package/dist/runtime/core/engine-transition.js +1 -3
  20. package/dist/runtime/core/engine-transition.js.map +1 -1
  21. package/dist/runtime/registration-events.js.map +1 -1
  22. package/dist/runtime/session-event-emitter-policy.js.map +1 -1
  23. package/dist/services/HighlightCoordinator.js +2 -1
  24. package/dist/services/HighlightCoordinator.js.map +1 -1
  25. package/dist/services/I18nService.d.ts +1 -1
  26. package/dist/services/I18nService.js.map +1 -1
  27. package/dist/services/SSMLExtractor.js.map +1 -1
  28. package/dist/services/TTSService.js +5 -2
  29. package/dist/services/TTSService.js.map +1 -1
  30. package/dist/services/ThemeProvider.js.map +1 -1
  31. package/dist/services/ToolRegistry.d.ts +1 -1
  32. package/dist/services/ToolRegistry.js.map +1 -1
  33. package/dist/services/ToolkitCoordinator.js +21 -11
  34. package/dist/services/ToolkitCoordinator.js.map +1 -1
  35. package/dist/services/createDefaultToolRegistry.js +4 -2
  36. package/dist/services/createDefaultToolRegistry.js.map +1 -1
  37. package/dist/services/framework-error-bus.js.map +1 -1
  38. package/dist/services/framework-error.js.map +1 -1
  39. package/dist/services/interfaces.js.map +1 -1
  40. package/dist/services/section-controller-types.js.map +1 -1
  41. package/dist/services/tool-config-defaults.js +7 -1
  42. package/dist/services/tool-config-defaults.js.map +1 -1
  43. package/dist/services/tool-config-validation.js +3 -1
  44. package/dist/services/tool-config-validation.js.map +1 -1
  45. package/dist/services/tool-instance-id.js.map +1 -1
  46. package/dist/services/tool-providers/DesmosToolProvider.js.map +1 -1
  47. package/dist/services/tool-providers/TTSToolProvider.js.map +1 -1
  48. package/dist/services/toolbar-items.js.map +1 -1
  49. package/dist/services/tools-config-normalizer.js +1 -2
  50. package/dist/services/tools-config-normalizer.js.map +1 -1
  51. package/dist/services/tts/browser-provider.js +60 -18
  52. package/dist/services/tts/browser-provider.js.map +1 -1
  53. package/dist/services/tts/catalog-span-alignment.js +8 -3
  54. package/dist/services/tts/catalog-span-alignment.js.map +1 -1
  55. package/dist/services/tts/generated-speech/assemble-plan.js.map +1 -1
  56. package/dist/services/tts/generated-speech/index.d.ts +1 -1
  57. package/dist/services/tts/generated-speech/index.js +1 -1
  58. package/dist/services/tts/generated-speech/index.js.map +1 -1
  59. package/dist/services/tts/generated-speech/math-speech-cache.js +3 -1
  60. package/dist/services/tts/generated-speech/math-speech-cache.js.map +1 -1
  61. package/dist/services/tts/highlight-pipeline/boundary-normalizer.js.map +1 -1
  62. package/dist/services/tts/highlight-pipeline/create-highlight-plan.js.map +1 -1
  63. package/dist/services/tts/math-alignment/mathml-tokenizer.js.map +1 -1
  64. package/dist/services/tts/math-alignment/sequence-aligner.js.map +1 -1
  65. package/dist/services/tts/math-alignment/speech-tokenizer.js.map +1 -1
  66. package/dist/services/tts/math-aware-text-processing.js +6 -3
  67. package/dist/services/tts/math-aware-text-processing.js.map +1 -1
  68. package/dist/services/tts/math-speech.js +3 -1
  69. package/dist/services/tts/math-speech.js.map +1 -1
  70. package/dist/services/tts/visual-line-ranges.js.map +1 -1
  71. package/dist/services/tts-runtime-config.js +6 -2
  72. package/dist/services/tts-runtime-config.js.map +1 -1
  73. package/dist/tools/calculators/desmos-provider.js.map +1 -1
  74. package/dist/tools/default-tool-module-loaders.js.map +1 -1
  75. package/dist/tools/registrations/accessibility-tools.js.map +1 -1
  76. package/dist/tools/registrations/calculator.js +1 -1
  77. package/dist/tools/registrations/calculator.js.map +1 -1
  78. package/dist/tools/registrations/interaction-tools.js.map +1 -1
  79. package/dist/tools/registrations/measurement-tools.js.map +1 -1
  80. package/dist/tools/registrations/subject-specific-tools.js +1 -1
  81. package/dist/tools/registrations/subject-specific-tools.js.map +1 -1
  82. package/dist/tools/registrations/tts.js +4 -2
  83. package/dist/tools/registrations/tts.js.map +1 -1
  84. package/dist/tools/types.js.map +1 -1
  85. package/dist/tools/variant-resolver.js.map +1 -1
  86. package/package.json +7 -7
@@ -52,7 +52,8 @@ export function createDefaultToolRegistry(options = {}) {
52
52
  applyOverrides,
53
53
  });
54
54
  }
55
- if (options.toolModuleLoaders && Object.keys(options.toolModuleLoaders).length > 0) {
55
+ if (options.toolModuleLoaders &&
56
+ Object.keys(options.toolModuleLoaders).length > 0) {
56
57
  registry.setToolModuleLoaders(options.toolModuleLoaders);
57
58
  }
58
59
  registry.setComponentOverrides(componentConfig);
@@ -65,7 +66,8 @@ export function registerPackagedTools(registry, options = {}) {
65
66
  const selectedToolIds = options.toolIds && options.toolIds.length > 0
66
67
  ? new Set(options.toolIds)
67
68
  : null;
68
- const applyOverrides = options.applyOverrides || ((registration) => registration);
69
+ const applyOverrides = options.applyOverrides ||
70
+ ((registration) => registration);
69
71
  for (const registration of PACKAGED_TOOL_REGISTRATIONS) {
70
72
  if (selectedToolIds && !selectedToolIds.has(registration.toolId)) {
71
73
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"createDefaultToolRegistry.js","sourceRoot":"","sources":["../../src/services/createDefaultToolRegistry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACN,qBAAqB,EACrB,0BAA0B,GAC1B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,gCAAgC,EAChC,2BAA2B,GAC3B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,0BAA0B,EAC1B,qBAAqB,EACrB,6BAA6B,GAC7B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACN,qBAAqB,EACrB,6BAA6B,GAC7B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,oBAAoB,GAIpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,sBAAsB,EACtB,uBAAuB,GACvB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,2BAA2B,GAAG;IACnC,0BAA0B;IAC1B,mBAAmB;IACnB,qBAAqB;IACrB,0BAA0B;IAC1B,gCAAgC;IAChC,2BAA2B;IAC3B,0BAA0B;IAC1B,qBAAqB;IACrB,6BAA6B;IAC7B,qBAAqB;IACrB,6BAA6B;CACpB,CAAC;AAmCX;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CACxC,UAAsC,EAAE;IAExC,MAAM,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;IACpC,MAAM,eAAe,GAAG;QACvB,UAAU,EAAE;YACX,GAAG,oBAAoB;YACvB,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;SAC7B;QACD,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;QAClD,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;KACtD,CAAC;IAEF,MAAM,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AE;IAEtE,OAAO,yBAAyB,CAAC;QAChC,GAAG,OAAO;QACV,oBAAoB,EAAE,IAAI;KAC1B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,6BAA6B;IAC7B,OAAO;IACP,eAAe;IACf,YAAY;IACZ,cAAc;IACd,eAAe;IACf,YAAY;IACZ,mBAAmB;IACnB,aAAa;IACb,oBAAoB;IACpB,kBAAkB;IAClB,oBAAoB;IACpB,OAAO;IACP,YAAY;IACZ,mBAAmB;IACnB,OAAO;IACP,eAAe;CACN,CAAC","sourcesContent":["/**\n * Default Tool Registry Factory\n *\n * Creates a ToolRegistry pre-populated with all PIE framework tools.\n * Integrators can use this as a starting point and customize as needed.\n */\n\nimport { ToolRegistry } from \"./ToolRegistry.js\";\nimport type { ToolRegistration } from \"./ToolRegistry.js\";\nimport type { ToolModuleLoader } from \"./ToolRegistry.js\";\nimport { calculatorToolRegistration } from \"../tools/registrations/calculator.js\";\nimport { ttsToolRegistration } from \"../tools/registrations/tts.js\";\nimport {\n\trulerToolRegistration,\n\tprotractorToolRegistration,\n} from \"../tools/registrations/measurement-tools.js\";\nimport {\n\tanswerEliminatorToolRegistration,\n\thighlighterToolRegistration,\n} from \"../tools/registrations/interaction-tools.js\";\nimport {\n\tlineReaderToolRegistration,\n\tthemeToolRegistration,\n\tannotationToolbarRegistration,\n} from \"../tools/registrations/accessibility-tools.js\";\nimport {\n\tgraphToolRegistration,\n\tperiodicTableToolRegistration,\n} from \"../tools/registrations/subject-specific-tools.js\";\nimport {\n\tDEFAULT_TOOL_TAG_MAP,\n\ttype ToolComponentFactory,\n\ttype ToolComponentFactoryMap,\n\ttype ToolTagMap,\n} from \"../tools/tool-tag-map.js\";\nimport {\n\tDEFAULT_TOOL_PLACEMENT,\n\tPACKAGED_TOOL_PLACEMENT,\n} from \"./tool-config-defaults.js\";\n\nconst PACKAGED_TOOL_REGISTRATIONS = [\n\tcalculatorToolRegistration,\n\tttsToolRegistration,\n\trulerToolRegistration,\n\tprotractorToolRegistration,\n\tanswerEliminatorToolRegistration,\n\thighlighterToolRegistration,\n\tlineReaderToolRegistration,\n\tthemeToolRegistration,\n\tannotationToolbarRegistration,\n\tgraphToolRegistration,\n\tperiodicTableToolRegistration,\n] as const;\n\nexport interface DefaultToolRegistryOptions {\n\t/**\n\t * Override default tool registrations by toolId.\n\t * This is the highest-precedence extension point.\n\t */\n\toverrides?: Partial<Record<string, ToolRegistration>>;\n\t/**\n\t * Override default component tag mapping used by built-in registrations.\n\t */\n\ttoolTagMap?: Partial<ToolTagMap>;\n\t/**\n\t * Override component factory globally (all tools) or per tool.\n\t */\n\ttoolComponentFactory?: ToolComponentFactory;\n\ttoolComponentFactories?: Partial<ToolComponentFactoryMap>;\n\t/**\n\t * Optional lazy module loaders keyed by toolId.\n\t * Hosts can inject default loaders from an external package.\n\t */\n\ttoolModuleLoaders?: Partial<Record<string, ToolModuleLoader>>;\n\t/**\n\t * Register packaged PIE tools by default.\n\t *\n\t * @default false\n\t */\n\tincludePackagedTools?: boolean;\n\t/**\n\t * Restrict registration to specific packaged tool IDs.\n\t * Ignored when includePackagedTools is false.\n\t */\n\ttoolIds?: string[];\n}\n\n/**\n * Create a tool registry.\n *\n * By default, this creates an empty registry so hosts can explicitly opt in.\n * For convenience, pass { includePackagedTools: true } to register all packaged tools,\n * or use createPackagedToolRegistry().\n *\n * @returns ToolRegistry with all default tools\n */\nexport function createDefaultToolRegistry(\n\toptions: DefaultToolRegistryOptions = {},\n): ToolRegistry {\n\tconst registry = new ToolRegistry();\n\tconst componentConfig = {\n\t\ttoolTagMap: {\n\t\t\t...DEFAULT_TOOL_TAG_MAP,\n\t\t\t...(options.toolTagMap || {}),\n\t\t},\n\t\ttoolComponentFactory: options.toolComponentFactory,\n\t\ttoolComponentFactories: options.toolComponentFactories,\n\t};\n\n\tconst applyOverrides = (registration: ToolRegistration): ToolRegistration =>\n\t\toptions.overrides?.[registration.toolId] || registration;\n\n\tif (options.includePackagedTools) {\n\t\tregisterPackagedTools(registry, {\n\t\t\ttoolIds: options.toolIds,\n\t\t\tapplyOverrides,\n\t\t});\n\t}\n\n\tif (options.toolModuleLoaders && Object.keys(options.toolModuleLoaders).length > 0) {\n\t\tregistry.setToolModuleLoaders(options.toolModuleLoaders);\n\t}\n\n\tregistry.setComponentOverrides(componentConfig);\n\n\treturn registry;\n}\n\nexport interface RegisterPackagedToolsOptions {\n\ttoolIds?: string[];\n\tapplyOverrides?: (registration: ToolRegistration) => ToolRegistration;\n}\n\n/**\n * Register packaged PIE tools onto an existing registry.\n */\nexport function registerPackagedTools(\n\tregistry: ToolRegistry,\n\toptions: RegisterPackagedToolsOptions = {},\n): void {\n\tconst selectedToolIds =\n\t\toptions.toolIds && options.toolIds.length > 0\n\t\t\t? new Set(options.toolIds)\n\t\t\t: null;\n\tconst applyOverrides = options.applyOverrides || ((registration: ToolRegistration) => registration);\n\tfor (const registration of PACKAGED_TOOL_REGISTRATIONS) {\n\t\tif (selectedToolIds && !selectedToolIds.has(registration.toolId)) {\n\t\t\tcontinue;\n\t\t}\n\t\tregistry.register(applyOverrides(registration));\n\t}\n}\n\n/**\n * Convenience factory that registers all packaged PIE tools.\n */\nexport function createPackagedToolRegistry(\n\toptions: Omit<DefaultToolRegistryOptions, \"includePackagedTools\"> = {},\n): ToolRegistry {\n\treturn createDefaultToolRegistry({\n\t\t...options,\n\t\tincludePackagedTools: true,\n\t});\n}\n\n/**\n * Default tool placement configuration\n *\n * Defines which tools appear at which levels by default.\n * Integrators can override this configuration.\n *\n * Categories:\n * - Global tools: theme (assessment/section level)\n * - Context-smart: calculator, graph, periodicTable (item/element, auto-detect)\n * - Reading aids: textToSpeech, lineReader, annotationToolbar (where text exists)\n * - Interaction-specific: answerEliminator (choice questions), highlighter (text)\n * - Measurement: ruler, protractor (element level, diagram/geometry)\n */\nexport { DEFAULT_TOOL_PLACEMENT };\nexport { PACKAGED_TOOL_PLACEMENT };\n\n/**\n * Tool priority order for rendering\n * Tools will be rendered in this order when multiple tools are visible\n */\nexport const DEFAULT_TOOL_ORDER = [\n\t// Global accessibility first\n\t\"theme\",\n\t// Common tools\n\t\"calculator\",\n\t\"textToSpeech\",\n\t// Reading aids\n\t\"lineReader\",\n\t\"annotationToolbar\",\n\t\"highlighter\",\n\t// Interaction tools\n\t\"answerEliminator\",\n\t// Measurement tools\n\t\"ruler\",\n\t\"protractor\",\n\t// Subject-specific\n\t\"graph\",\n\t\"periodicTable\",\n] as const;\n"]}
1
+ {"version":3,"file":"createDefaultToolRegistry.js","sourceRoot":"","sources":["../../src/services/createDefaultToolRegistry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACN,qBAAqB,EACrB,0BAA0B,GAC1B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,gCAAgC,EAChC,2BAA2B,GAC3B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,0BAA0B,EAC1B,qBAAqB,EACrB,6BAA6B,GAC7B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACN,qBAAqB,EACrB,6BAA6B,GAC7B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,oBAAoB,GAIpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,sBAAsB,EACtB,uBAAuB,GACvB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,2BAA2B,GAAG;IACnC,0BAA0B;IAC1B,mBAAmB;IACnB,qBAAqB;IACrB,0BAA0B;IAC1B,gCAAgC;IAChC,2BAA2B;IAC3B,0BAA0B;IAC1B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T,MAAM,cAAc,GACnB,OAAO,CAAC,cAAc;QACtB,CAAC,CAAC,YAA8B,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC;IACpD,KAAK,MAAM,YAAY,IAAI,2BAA2B,EAAE,CAAC;QACxD,IAAI,eAAe,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YAClE,SAAS;QACV,CAAC;QACD,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC;IACjD,CAAC;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACzC,UAAoE,EAAE;IAEtE,OAAO,yBAAyB,CAAC;QAChC,GAAG,OAAO;QACV,oBAAoB,EAAE,IAAI;KAC1B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,6BAA6B;IAC7B,OAAO;IACP,eAAe;IACf,YAAY;IACZ,cAAc;IACd,eAAe;IACf,YAAY;IACZ,mBAAmB;IACnB,aAAa;IACb,oBAAoB;IACpB,kBAAkB;IAClB,oBAAoB;IACpB,OAAO;IACP,YAAY;IACZ,mBAAmB;IACnB,OAAO;IACP,eAAe;CACN,CAAC","sourcesContent":["/**\n * Default Tool Registry Factory\n *\n * Creates a ToolRegistry pre-populated with all PIE framework tools.\n * Integrators can use this as a starting point and customize as needed.\n */\n\nimport { ToolRegistry } from \"./ToolRegistry.js\";\nimport type { ToolRegistration } from \"./ToolRegistry.js\";\nimport type { ToolModuleLoader } from \"./ToolRegistry.js\";\nimport { calculatorToolRegistration } from \"../tools/registrations/calculator.js\";\nimport { ttsToolRegistration } from \"../tools/registrations/tts.js\";\nimport {\n\trulerToolRegistration,\n\tprotractorToolRegistration,\n} from \"../tools/registrations/measurement-tools.js\";\nimport {\n\tanswerEliminatorToolRegistration,\n\thighlighterToolRegistration,\n} from \"../tools/registrations/interaction-tools.js\";\nimport {\n\tlineReaderToolRegistration,\n\tthemeToolRegistration,\n\tannotationToolbarRegistration,\n} from \"../tools/registrations/accessibility-tools.js\";\nimport {\n\tgraphToolRegistration,\n\tperiodicTableToolRegistration,\n} from \"../tools/registrations/subject-specific-tools.js\";\nimport {\n\tDEFAULT_TOOL_TAG_MAP,\n\ttype ToolComponentFactory,\n\ttype ToolComponentFactoryMap,\n\ttype ToolTagMap,\n} from \"../tools/tool-tag-map.js\";\nimport {\n\tDEFAULT_TOOL_PLACEMENT,\n\tPACKAGED_TOOL_PLACEMENT,\n} from \"./tool-config-defaults.js\";\n\nconst PACKAGED_TOOL_REGISTRATIONS = [\n\tcalculatorToolRegistration,\n\tttsToolRegistration,\n\trulerToolRegistration,\n\tprotractorToolRegistration,\n\tanswerEliminatorToolRegistration,\n\thighlighterToolRegistration,\n\tlineReaderToolRegistration,\n\tthemeToolRegistration,\n\tannotationToolbarRegistration,\n\tgraphToolRegistration,\n\tperiodicTableToolRegistration,\n] as const;\n\nexport interface DefaultToolRegistryOptions {\n\t/**\n\t * Override default tool registrations by toolId.\n\t * This is the highest-precedence extension point.\n\t */\n\toverrides?: Partial<Record<string, ToolRegistration>>;\n\t/**\n\t * Override default component tag mapping used by built-in registrations.\n\t */\n\ttoolTagMap?: Partial<ToolTagMap>;\n\t/**\n\t * Override component factory globally (all tools) or per tool.\n\t */\n\ttoolComponentFactory?: ToolComponentFactory;\n\ttoolComponentFactories?: Partial<ToolComponentFactoryMap>;\n\t/**\n\t * Optional lazy module loaders keyed by toolId.\n\t * Hosts can inject default loaders from an external package.\n\t */\n\ttoolModuleLoaders?: Partial<Record<string, ToolModuleLoader>>;\n\t/**\n\t * Register packaged PIE tools by default.\n\t *\n\t * @default false\n\t */\n\tincludePackagedTools?: boolean;\n\t/**\n\t * Restrict registration to specific packaged tool IDs.\n\t * Ignored when includePackagedTools is false.\n\t */\n\ttoolIds?: string[];\n}\n\n/**\n * Create a tool registry.\n *\n * By default, this creates an empty registry so hosts can explicitly opt in.\n * For convenience, pass { includePackagedTools: true } to register all packaged tools,\n * or use createPackagedToolRegistry().\n *\n * @returns ToolRegistry with all default tools\n */\nexport function createDefaultToolRegistry(\n\toptions: DefaultToolRegistryOptions = {},\n): ToolRegistry {\n\tconst registry = new ToolRegistry();\n\tconst componentConfig = {\n\t\ttoolTagMap: {\n\t\t\t...DEFAULT_TOOL_TAG_MAP,\n\t\t\t...(options.toolTagMap || {}),\n\t\t},\n\t\ttoolComponentFactory: options.toolComponentFactory,\n\t\ttoolComponentFactories: options.toolComponentFactories,\n\t};\n\n\tconst applyOverrides = (registration: ToolRegistration): ToolRegistration =>\n\t\toptions.overrides?.[registration.toolId] || registration;\n\n\tif (options.includePackagedTools) {\n\t\tregisterPackagedTools(registry, {\n\t\t\ttoolIds: options.toolIds,\n\t\t\tapplyOverrides,\n\t\t});\n\t}\n\n\tif (\n\t\toptions.toolModuleLoaders &&\n\t\tObject.keys(options.toolModuleLoaders).length > 0\n\t) {\n\t\tregistry.setToolModuleLoaders(options.toolModuleLoaders);\n\t}\n\n\tregistry.setComponentOverrides(componentConfig);\n\n\treturn registry;\n}\n\nexport interface RegisterPackagedToolsOptions {\n\ttoolIds?: string[];\n\tapplyOverrides?: (registration: ToolRegistration) => ToolRegistration;\n}\n\n/**\n * Register packaged PIE tools onto an existing registry.\n */\nexport function registerPackagedTools(\n\tregistry: ToolRegistry,\n\toptions: RegisterPackagedToolsOptions = {},\n): void {\n\tconst selectedToolIds =\n\t\toptions.toolIds && options.toolIds.length > 0\n\t\t\t? new Set(options.toolIds)\n\t\t\t: null;\n\tconst applyOverrides =\n\t\toptions.applyOverrides ||\n\t\t((registration: ToolRegistration) => registration);\n\tfor (const registration of PACKAGED_TOOL_REGISTRATIONS) {\n\t\tif (selectedToolIds && !selectedToolIds.has(registration.toolId)) {\n\t\t\tcontinue;\n\t\t}\n\t\tregistry.register(applyOverrides(registration));\n\t}\n}\n\n/**\n * Convenience factory that registers all packaged PIE tools.\n */\nexport function createPackagedToolRegistry(\n\toptions: Omit<DefaultToolRegistryOptions, \"includePackagedTools\"> = {},\n): ToolRegistry {\n\treturn createDefaultToolRegistry({\n\t\t...options,\n\t\tincludePackagedTools: true,\n\t});\n}\n\n/**\n * Default tool placement configuration\n *\n * Defines which tools appear at which levels by default.\n * Integrators can override this configuration.\n *\n * Categories:\n * - Global tools: theme (assessment/section level)\n * - Context-smart: calculator, graph, periodicTable (item/element, auto-detect)\n * - Reading aids: textToSpeech, lineReader, annotationToolbar (where text exists)\n * - Interaction-specific: answerEliminator (choice questions), highlighter (text)\n * - Measurement: ruler, protractor (element level, diagram/geometry)\n */\nexport { DEFAULT_TOOL_PLACEMENT };\nexport { PACKAGED_TOOL_PLACEMENT };\n\n/**\n * Tool priority order for rendering\n * Tools will be rendered in this order when multiple tools are visible\n */\nexport const DEFAULT_TOOL_ORDER = [\n\t// Global accessibility first\n\t\"theme\",\n\t// Common tools\n\t\"calculator\",\n\t\"textToSpeech\",\n\t// Reading aids\n\t\"lineReader\",\n\t\"annotationToolbar\",\n\t\"highlighter\",\n\t// Interaction tools\n\t\"answerEliminator\",\n\t// Measurement tools\n\t\"ruler\",\n\t\"protractor\",\n\t// Subject-specific\n\t\"graph\",\n\t\"periodicTable\",\n] as const;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"framework-error-bus.js","sourceRoot":"","sources":["../../src/services/framework-error-bus.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,iBAAiB;IACZ,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE/D,wBAAwB,CAAC,QAAgC;QACxD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,OAAO,GAAG,EAAE;YACX,IAAI,CAAC,QAAQ;gBAAE,OAAO;YACtB,QAAQ,GAAG,KAAK,CAAC;YACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC,CAAC;IACH,CAAC;IAED,oBAAoB,CAAC,KAA0B;QAC9C,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5C,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC;gBACJ,QAAQ,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,IAAI,CACX,sCAAsC,EACtC,KAAK,CACL,CAAC;YACH,CAAC;QACF,CAAC;IACF,CAAC;IAED;;OAEG;IACH,OAAO;QACN,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,gBAAgB;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC5B,CAAC;CACD","sourcesContent":["import type { FrameworkErrorModel } from \"./framework-error.js\";\n\n/**\n * Listener invoked once per `reportFrameworkError` call.\n *\n * Listeners are called synchronously, in registration order. A listener\n * that throws is caught and logged; the throw does not stop fan-out to\n * the remaining listeners.\n */\nexport type FrameworkErrorListener = (model: FrameworkErrorModel) => void;\n\n/**\n * Read side of the bus — the surface a host or sub-shell consumes.\n *\n * Mirrors the shape `subscribeTelemetry` exposes on\n * `ToolkitCoordinatorApi`: a `subscribe(listener)` returning a disposer.\n */\nexport interface FrameworkErrorPort {\n\tsubscribeFrameworkErrors(listener: FrameworkErrorListener): () => void;\n}\n\n/**\n * Write side of the bus — the surface an internal failure path uses to\n * publish a model.\n *\n * Kept separate from the read port so callers (e.g. the coordinator)\n * receive only the capability they actually need.\n */\nexport interface FrameworkErrorReporter {\n\treportFrameworkError(model: FrameworkErrorModel): void;\n}\n\n/**\n * Package-internal multi-subscriber framework-error bus.\n *\n * **Design contract.**\n *\n * - **Synchronous fan-out.** `reportFrameworkError(model)` calls every\n * subscribed listener in registration order before returning. There is\n * no buffering, no microtask deferral, no replay of past errors.\n * - **Listener isolation.** A listener that throws is caught and\n * `console.warn`-logged; the throw does not interrupt fan-out to the\n * remaining listeners.\n * - **Snapshot iteration.** The fan-out iterates over a snapshot of the\n * listener set so that a listener that subscribes / unsubscribes\n * during its own delivery does not mutate the in-flight iteration.\n * - **Idempotent unsubscribe.** Calling the returned disposer twice is\n * a no-op; the listener is removed on the first call.\n * - **No replay.** Late subscribers do not see errors emitted before\n * they subscribed. Hosts that need an \"error already happened\" signal\n * should subscribe at construction time. The toolkit CE does this\n * before constructing the coordinator so the `coordinator-init`\n * failure path emits through the same bus.\n *\n * **Why not a public class.** This bus is constructed inside the toolkit\n * CE (`PieAssessmentToolkit.svelte`) and passed into\n * `ToolkitCoordinator`. Hosts subscribe via\n * `ToolkitCoordinatorApi.subscribeFrameworkErrors`, never via the bus\n * class itself. Keeping the class package-internal lets us iterate on\n * its shape without a public-API change.\n */\nexport class FrameworkErrorBus implements FrameworkErrorPort, FrameworkErrorReporter {\n\tprivate readonly listeners = new Set<FrameworkErrorListener>();\n\n\tsubscribeFrameworkErrors(listener: FrameworkErrorListener): () => void {\n\t\tthis.listeners.add(listener);\n\t\tlet attached = true;\n\t\treturn () => {\n\t\t\tif (!attached) return;\n\t\t\tattached = false;\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\treportFrameworkError(model: FrameworkErrorModel): void {\n\t\tconst snapshot = Array.from(this.listeners);\n\t\tfor (const listener of snapshot) {\n\t\t\ttry {\n\t\t\t\tlistener(model);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[FrameworkErrorBus] listener failed:\",\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Detach all listeners. Used by the toolkit CE on disconnect.\n\t */\n\tdispose(): void {\n\t\tthis.listeners.clear();\n\t}\n\n\t/**\n\t * Test-only inspection. Not part of the public contract.\n\t *\n\t * @internal\n\t */\n\tgetListenerCount(): number {\n\t\treturn this.listeners.size;\n\t}\n}\n"]}
1
+ {"version":3,"file":"framework-error-bus.js","sourceRoot":"","sources":["../../src/services/framework-error-bus.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,iBAAiB;IAGZ,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE/D,wBAAwB,CAAC,QAAgC;QACxD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7B,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,OAAO,GAAG,EAAE;YACX,IAAI,CAAC,QAAQ;gBAAE,OAAO;YACtB,QAAQ,GAAG,KAAK,CAAC;YACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC,CAAC;IACH,CAAC;IAED,oBAAoB,CAAC,KAA0B;QAC9C,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5C,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC;gBACJ,QAAQ,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC7D,CAAC;QACF,CAAC;IACF,CAAC;IAED;;OAEG;IACH,OAAO;QACN,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,gBAAgB;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC5B,CAAC;CACD","sourcesContent":["import type { FrameworkErrorModel } from \"./framework-error.js\";\n\n/**\n * Listener invoked once per `reportFrameworkError` call.\n *\n * Listeners are called synchronously, in registration order. A listener\n * that throws is caught and logged; the throw does not stop fan-out to\n * the remaining listeners.\n */\nexport type FrameworkErrorListener = (model: FrameworkErrorModel) => void;\n\n/**\n * Read side of the bus — the surface a host or sub-shell consumes.\n *\n * Mirrors the shape `subscribeTelemetry` exposes on\n * `ToolkitCoordinatorApi`: a `subscribe(listener)` returning a disposer.\n */\nexport interface FrameworkErrorPort {\n\tsubscribeFrameworkErrors(listener: FrameworkErrorListener): () => void;\n}\n\n/**\n * Write side of the bus — the surface an internal failure path uses to\n * publish a model.\n *\n * Kept separate from the read port so callers (e.g. the coordinator)\n * receive only the capability they actually need.\n */\nexport interface FrameworkErrorReporter {\n\treportFrameworkError(model: FrameworkErrorModel): void;\n}\n\n/**\n * Package-internal multi-subscriber framework-error bus.\n *\n * **Design contract.**\n *\n * - **Synchronous fan-out.** `reportFrameworkError(model)` calls every\n * subscribed listener in registration order before returning. There is\n * no buffering, no microtask deferral, no replay of past errors.\n * - **Listener isolation.** A listener that throws is caught and\n * `console.warn`-logged; the throw does not interrupt fan-out to the\n * remaining listeners.\n * - **Snapshot iteration.** The fan-out iterates over a snapshot of the\n * listener set so that a listener that subscribes / unsubscribes\n * during its own delivery does not mutate the in-flight iteration.\n * - **Idempotent unsubscribe.** Calling the returned disposer twice is\n * a no-op; the listener is removed on the first call.\n * - **No replay.** Late subscribers do not see errors emitted before\n * they subscribed. Hosts that need an \"error already happened\" signal\n * should subscribe at construction time. The toolkit CE does this\n * before constructing the coordinator so the `coordinator-init`\n * failure path emits through the same bus.\n *\n * **Why not a public class.** This bus is constructed inside the toolkit\n * CE (`PieAssessmentToolkit.svelte`) and passed into\n * `ToolkitCoordinator`. Hosts subscribe via\n * `ToolkitCoordinatorApi.subscribeFrameworkErrors`, never via the bus\n * class itself. Keeping the class package-internal lets us iterate on\n * its shape without a public-API change.\n */\nexport class FrameworkErrorBus\n\timplements FrameworkErrorPort, FrameworkErrorReporter\n{\n\tprivate readonly listeners = new Set<FrameworkErrorListener>();\n\n\tsubscribeFrameworkErrors(listener: FrameworkErrorListener): () => void {\n\t\tthis.listeners.add(listener);\n\t\tlet attached = true;\n\t\treturn () => {\n\t\t\tif (!attached) return;\n\t\t\tattached = false;\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\treportFrameworkError(model: FrameworkErrorModel): void {\n\t\tconst snapshot = Array.from(this.listeners);\n\t\tfor (const listener of snapshot) {\n\t\t\ttry {\n\t\t\t\tlistener(model);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\"[FrameworkErrorBus] listener failed:\", error);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Detach all listeners. Used by the toolkit CE on disconnect.\n\t */\n\tdispose(): void {\n\t\tthis.listeners.clear();\n\t}\n\n\t/**\n\t * Test-only inspection. Not part of the public contract.\n\t *\n\t * @internal\n\t */\n\tgetListenerCount(): number {\n\t\treturn this.listeners.size;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"framework-error.js","sourceRoot":"","sources":["../../src/services/framework-error.ts"],"names":[],"mappings":"AA4BA,MAAM,UAAU,qBAAqB,CAAC,IAQrC;IACA,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,OAAO;QAClC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QAClC,WAAW,EAAE,IAAI,CAAC,WAAW,KAAK,IAAI;QACtC,KAAK,EAAE,IAAI,CAAC,KAAK;KACjB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAKzC;IACA,MAAM,OAAO,GACZ,IAAI,CAAC,KAAK,YAAY,KAAK,IAAI,IAAI,CAAC,KAAK,CAA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C,UAAU,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,CAC3D,CAAC;IACF,MAAM,OAAO,GACZ,OAAO,CAAC,MAAM,GAAG,CAAC;QACjB,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,8DAA8D,CAAC;IACnE,OAAO,qBAAqB,CAAC;QAC5B,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO;QACP,OAAO;QACP,WAAW,EAAE,IAAI,CAAC,WAAW;KAC7B,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,KAA0B;IACxE,MAAM,MAAM,GAAG,kBAAkB,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;IAC/D,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;IACpE,OAAO,GAAG,MAAM,IAAI,KAAK,CAAC,OAAO,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;AACtE,CAAC","sourcesContent":["import type { ToolConfigDiagnostic } from \"./tool-config-validation.js\";\n\nexport type FrameworkErrorKind =\n\t| \"tool-config\"\n\t| \"runtime-init\"\n\t| \"runtime-dispose\"\n\t| \"coordinator-init\"\n\t| \"provider-init\"\n\t| \"provider-register\"\n\t| \"tts-init\"\n\t| \"tool-state-load\"\n\t| \"tool-state-save\"\n\t| \"section-controller-init\"\n\t| \"section-controller-dispose\"\n\t| \"unknown\";\n\nexport type FrameworkErrorSeverity = \"warning\" | \"error\";\n\nexport interface FrameworkErrorModel {\n\tkind: FrameworkErrorKind;\n\tseverity: FrameworkErrorSeverity;\n\tsource: string;\n\tmessage: string;\n\tdetails: string[];\n\trecoverable: boolean;\n\tcause?: unknown;\n}\n\nexport function toFrameworkErrorModel(args: {\n\tkind: FrameworkErrorKind;\n\tseverity?: FrameworkErrorSeverity;\n\tsource: string;\n\tmessage: string;\n\tdetails?: string[];\n\trecoverable?: boolean;\n\tcause?: unknown;\n}): FrameworkErrorModel {\n\treturn {\n\t\tkind: args.kind,\n\t\tseverity: args.severity ?? \"error\",\n\t\tsource: args.source,\n\t\tmessage: args.message,\n\t\tdetails: [...(args.details || [])],\n\t\trecoverable: args.recoverable === true,\n\t\tcause: args.cause,\n\t};\n}\n\nexport function frameworkErrorFromUnknown(args: {\n\tkind: FrameworkErrorKind;\n\tsource: string;\n\terror: unknown;\n\trecoverable?: boolean;\n}): FrameworkErrorModel {\n\tconst message =\n\t\targs.error instanceof Error && args.error.message.trim().length > 0\n\t\t\t? args.error.message\n\t\t\t: String(args.error || \"Unknown framework error\");\n\treturn toFrameworkErrorModel({\n\t\tkind: args.kind,\n\t\tsource: args.source,\n\t\tmessage,\n\t\trecoverable: args.recoverable,\n\t\tcause: args.error,\n\t});\n}\n\n/**\n * Coordinator-side error context shape consumed by\n * {@link frameworkErrorFromCoordinatorContext}.\n *\n * This is a deliberately small, structural mirror of\n * `ToolkitErrorContext` from `ToolkitCoordinator.ts`. It lives here (and not\n * in `ToolkitCoordinator.ts`) to keep `framework-error.ts` free of a cycle\n * back to the coordinator. `ToolkitErrorContext` remains the source of\n * truth for coordinator code; values of that type satisfy this shape.\n */\nexport interface FrameworkErrorCoordinatorContext {\n\tphase:\n\t\t| \"coordinator-ready\"\n\t\t| \"state-load\"\n\t\t| \"state-save\"\n\t\t| \"provider-register\"\n\t\t| \"provider-init\"\n\t\t| \"tts-init\"\n\t\t| \"section-controller-init\"\n\t\t| \"section-controller-dispose\";\n\tproviderId?: string;\n\tdetails?: Record<string, unknown>;\n}\n\nconst COORDINATOR_PHASE_TO_KIND: Record<\n\tFrameworkErrorCoordinatorContext[\"phase\"],\n\tFrameworkErrorKind\n> = {\n\t\"coordinator-ready\": \"coordinator-init\",\n\t\"state-load\": \"tool-state-load\",\n\t\"state-save\": \"tool-state-save\",\n\t\"provider-register\": \"provider-register\",\n\t\"provider-init\": \"provider-init\",\n\t\"tts-init\": \"tts-init\",\n\t\"section-controller-init\": \"section-controller-init\",\n\t\"section-controller-dispose\": \"section-controller-dispose\",\n};\n\n/**\n * Build a {@link FrameworkErrorModel} from a coordinator-side error +\n * context pair.\n *\n * Maps `context.phase` to the canonical {@link FrameworkErrorKind} and\n * synthesizes a `source` from `context.providerId` when present\n * (`pie-toolkit-coordinator/<providerId>`); falls back to a phase-tagged\n * source (`pie-toolkit-coordinator:<phase>`) otherwise. Forwards the\n * original `error` as `cause` so hosts that care about the underlying\n * `Error` keep getting it.\n *\n * Recoverable defaults to `false` (most coordinator-phase failures are\n * not auto-recovered today). Override with `recoverable: true` for the\n * phases where the coordinator continues operating after the failure.\n */\nexport function frameworkErrorFromCoordinatorContext(args: {\n\terror: unknown;\n\tcontext: FrameworkErrorCoordinatorContext;\n\trecoverable?: boolean;\n}): FrameworkErrorModel {\n\tconst kind = COORDINATOR_PHASE_TO_KIND[args.context.phase];\n\tconst source = args.context.providerId\n\t\t? `pie-toolkit-coordinator/${args.context.providerId}`\n\t\t: `pie-toolkit-coordinator:${args.context.phase}`;\n\treturn frameworkErrorFromUnknown({\n\t\tkind,\n\t\tsource,\n\t\terror: args.error,\n\t\trecoverable: args.recoverable,\n\t});\n}\n\nexport function frameworkErrorFromToolConfigDiagnostics(args: {\n\tsource: string;\n\tdiagnostics: ToolConfigDiagnostic[];\n\trecoverable?: boolean;\n}): FrameworkErrorModel {\n\tconst details = args.diagnostics.map(\n\t\t(diagnostic) => `${diagnostic.path}: ${diagnostic.message}`,\n\t);\n\tconst message =\n\t\tdetails.length > 0\n\t\t\t? \"Invalid tools config.\"\n\t\t\t: \"Invalid tools config (no diagnostics details were provided).\";\n\treturn toFrameworkErrorModel({\n\t\tkind: \"tool-config\",\n\t\tsource: args.source,\n\t\tmessage,\n\t\tdetails,\n\t\trecoverable: args.recoverable,\n\t});\n}\n\nexport function formatFrameworkErrorForConsole(error: FrameworkErrorModel): string {\n\tconst prefix = `[pie-framework:${error.kind}:${error.source}]`;\n\tif (error.details.length === 0) return `${prefix} ${error.message}`;\n\treturn `${prefix} ${error.message}\\n- ${error.details.join(\"\\n- \")}`;\n}\n"]}
1
+ {"version":3,"file":"framework-error.js","sourceRoot":"","sources":["../../src/services/framework-error.ts"],"names":[],"mappings":"AA4BA,MAAM,UAAU,qBAAqB,CAAC,IAQrC;IACA,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,OAAO;QAClC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QAClC,WAAW,EAAE,IAAI,CAAC,WAAW,KAAK,IAAI;QACtC,KAAK,EAAE,IAAI,CAAC,KAAK;KACjB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAKzC;IACA,MAAM,OAAO,GACZ,IAAI,CAAC,KAAK,YAAY,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAClE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO;QACpB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,yBAAyB,CAAC,CAAC;IACpD,OAAO,qBAAqB,CAAC;QAC5B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO;QACP,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;KACjB,CAAC,CAAC;AACJ,CAAC;AA0BD,MAAM,yBAAyB,GAG3B;IACH,mBAAmB,EAAE,kBAAkB;IACvC,YAAY,EAAE,iBAAiB;IAC/B,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AI,KAAK,CAAC,MAAM,GAAG,CAAC;IAC/D,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;IACpE,OAAO,GAAG,MAAM,IAAI,KAAK,CAAC,OAAO,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;AACtE,CAAC","sourcesContent":["import type { ToolConfigDiagnostic } from \"./tool-config-validation.js\";\n\nexport type FrameworkErrorKind =\n\t| \"tool-config\"\n\t| \"runtime-init\"\n\t| \"runtime-dispose\"\n\t| \"coordinator-init\"\n\t| \"provider-init\"\n\t| \"provider-register\"\n\t| \"tts-init\"\n\t| \"tool-state-load\"\n\t| \"tool-state-save\"\n\t| \"section-controller-init\"\n\t| \"section-controller-dispose\"\n\t| \"unknown\";\n\nexport type FrameworkErrorSeverity = \"warning\" | \"error\";\n\nexport interface FrameworkErrorModel {\n\tkind: FrameworkErrorKind;\n\tseverity: FrameworkErrorSeverity;\n\tsource: string;\n\tmessage: string;\n\tdetails: string[];\n\trecoverable: boolean;\n\tcause?: unknown;\n}\n\nexport function toFrameworkErrorModel(args: {\n\tkind: FrameworkErrorKind;\n\tseverity?: FrameworkErrorSeverity;\n\tsource: string;\n\tmessage: string;\n\tdetails?: string[];\n\trecoverable?: boolean;\n\tcause?: unknown;\n}): FrameworkErrorModel {\n\treturn {\n\t\tkind: args.kind,\n\t\tseverity: args.severity ?? \"error\",\n\t\tsource: args.source,\n\t\tmessage: args.message,\n\t\tdetails: [...(args.details || [])],\n\t\trecoverable: args.recoverable === true,\n\t\tcause: args.cause,\n\t};\n}\n\nexport function frameworkErrorFromUnknown(args: {\n\tkind: FrameworkErrorKind;\n\tsource: string;\n\terror: unknown;\n\trecoverable?: boolean;\n}): FrameworkErrorModel {\n\tconst message =\n\t\targs.error instanceof Error && args.error.message.trim().length > 0\n\t\t\t? args.error.message\n\t\t\t: String(args.error || \"Unknown framework error\");\n\treturn toFrameworkErrorModel({\n\t\tkind: args.kind,\n\t\tsource: args.source,\n\t\tmessage,\n\t\trecoverable: args.recoverable,\n\t\tcause: args.error,\n\t});\n}\n\n/**\n * Coordinator-side error context shape consumed by\n * {@link frameworkErrorFromCoordinatorContext}.\n *\n * This is a deliberately small, structural mirror of\n * `ToolkitErrorContext` from `ToolkitCoordinator.ts`. It lives here (and not\n * in `ToolkitCoordinator.ts`) to keep `framework-error.ts` free of a cycle\n * back to the coordinator. `ToolkitErrorContext` remains the source of\n * truth for coordinator code; values of that type satisfy this shape.\n */\nexport interface FrameworkErrorCoordinatorContext {\n\tphase:\n\t\t| \"coordinator-ready\"\n\t\t| \"state-load\"\n\t\t| \"state-save\"\n\t\t| \"provider-register\"\n\t\t| \"provider-init\"\n\t\t| \"tts-init\"\n\t\t| \"section-controller-init\"\n\t\t| \"section-controller-dispose\";\n\tproviderId?: string;\n\tdetails?: Record<string, unknown>;\n}\n\nconst COORDINATOR_PHASE_TO_KIND: Record<\n\tFrameworkErrorCoordinatorContext[\"phase\"],\n\tFrameworkErrorKind\n> = {\n\t\"coordinator-ready\": \"coordinator-init\",\n\t\"state-load\": \"tool-state-load\",\n\t\"state-save\": \"tool-state-save\",\n\t\"provider-register\": \"provider-register\",\n\t\"provider-init\": \"provider-init\",\n\t\"tts-init\": \"tts-init\",\n\t\"section-controller-init\": \"section-controller-init\",\n\t\"section-controller-dispose\": \"section-controller-dispose\",\n};\n\n/**\n * Build a {@link FrameworkErrorModel} from a coordinator-side error +\n * context pair.\n *\n * Maps `context.phase` to the canonical {@link FrameworkErrorKind} and\n * synthesizes a `source` from `context.providerId` when present\n * (`pie-toolkit-coordinator/<providerId>`); falls back to a phase-tagged\n * source (`pie-toolkit-coordinator:<phase>`) otherwise. Forwards the\n * original `error` as `cause` so hosts that care about the underlying\n * `Error` keep getting it.\n *\n * Recoverable defaults to `false` (most coordinator-phase failures are\n * not auto-recovered today). Override with `recoverable: true` for the\n * phases where the coordinator continues operating after the failure.\n */\nexport function frameworkErrorFromCoordinatorContext(args: {\n\terror: unknown;\n\tcontext: FrameworkErrorCoordinatorContext;\n\trecoverable?: boolean;\n}): FrameworkErrorModel {\n\tconst kind = COORDINATOR_PHASE_TO_KIND[args.context.phase];\n\tconst source = args.context.providerId\n\t\t? `pie-toolkit-coordinator/${args.context.providerId}`\n\t\t: `pie-toolkit-coordinator:${args.context.phase}`;\n\treturn frameworkErrorFromUnknown({\n\t\tkind,\n\t\tsource,\n\t\terror: args.error,\n\t\trecoverable: args.recoverable,\n\t});\n}\n\nexport function frameworkErrorFromToolConfigDiagnostics(args: {\n\tsource: string;\n\tdiagnostics: ToolConfigDiagnostic[];\n\trecoverable?: boolean;\n}): FrameworkErrorModel {\n\tconst details = args.diagnostics.map(\n\t\t(diagnostic) => `${diagnostic.path}: ${diagnostic.message}`,\n\t);\n\tconst message =\n\t\tdetails.length > 0\n\t\t\t? \"Invalid tools config.\"\n\t\t\t: \"Invalid tools config (no diagnostics details were provided).\";\n\treturn toFrameworkErrorModel({\n\t\tkind: \"tool-config\",\n\t\tsource: args.source,\n\t\tmessage,\n\t\tdetails,\n\t\trecoverable: args.recoverable,\n\t});\n}\n\nexport function formatFrameworkErrorForConsole(\n\terror: FrameworkErrorModel,\n): string {\n\tconst prefix = `[pie-framework:${error.kind}:${error.source}]`;\n\tif (error.details.length === 0) return `${prefix} ${error.message}`;\n\treturn `${prefix} ${error.message}\\n- ${error.details.join(\"\\n- \")}`;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/services/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;AAg1BH,0EAA0E","sourcesContent":["/**\n * Service Interfaces\n *\n * Public interfaces for all core assessment toolkit services.\n * These interfaces define the contracts that service implementations must fulfill,\n * enabling dependency injection, testing, and custom implementations.\n *\n * Part of PIE Assessment Toolkit.\n */\n\nimport type { I18nServiceApi } from \"@pie-players/pie-players-shared/i18n\";\nimport type {\n\tAccessibilityCatalogResolver,\n\tCatalogLookupContext,\n\tCatalogLookupOptions,\n\tCatalogOwnerContext,\n\tCatalogStatistics,\n\tCatalogType,\n\tResolvedCatalog,\n} from \"./AccessibilityCatalogResolver.js\";\nimport type { FrameworkErrorListener } from \"./framework-error-bus.js\";\nimport type { HighlightColor, HighlightType } from \"./HighlightCoordinator.js\";\nimport type {\n\tSectionControllerHandle,\n\tSectionItemEventSubscriptionArgs,\n\tSectionScopedEventSubscriptionArgs,\n\tSectionEventSubscriptionArgs,\n\tToolkitCoordinatorHooks,\n\tToolkitInitStatus,\n} from \"./ToolkitCoordinator.js\";\nimport type { FontSize, ThemeConfig } from \"./ThemeProvider.js\";\nimport type { ZIndexLayer } from \"./ToolCoordinator.js\";\nimport type { PlaybackState, TTSConfig } from \"./TTSService.js\";\nimport type {\n\tToolPlacementConfig,\n\tToolPlacementLevel,\n\tToolProviderConfig,\n} from \"./tools-config-normalizer.js\";\nimport type { ToolProviderRegistry } from \"./tool-providers/ToolProviderRegistry.js\";\nimport type {\n\tPolicySource,\n\tPnpEnforcementMode,\n\tResolvedEngineInputs,\n\tToolPolicyChangeListener,\n\tToolPolicyDecision,\n\tToolPolicyDecisionRequest,\n} from \"../policy/engine.js\";\nimport type {\n\tAssessmentEntity,\n\tAssessmentItemRef,\n} from \"@pie-players/pie-players-shared/types\";\nimport type {\n\tITTSProvider,\n\tTTSProviderCapabilities,\n} from \"@pie-players/pie-tts\";\nimport type {\n\tResolvedToolContext,\n\tToolContextResolver,\n\tToolContextResolverContext,\n\tToolContextResolverMap,\n} from \"./ToolRegistry.js\";\n\n// Re-export I18nServiceApi from players-shared\nexport type { I18nServiceApi };\n\n/**\n * Theme provider interface\n *\n * Applies consistent accessibility theming across items and tools.\n */\nexport interface ThemeProviderApi {\n\t/**\n\t * Apply theme configuration\n\t */\n\tapplyTheme(config: ThemeConfig): void;\n\n\t/**\n\t * Get current theme configuration\n\t */\n\tgetCurrentTheme(): Required<ThemeConfig>;\n\n\t/**\n\t * Reset to default theme\n\t */\n\treset(): void;\n\n\t/**\n\t * Clean up and remove theme styles\n\t */\n\tdestroy(): void;\n}\n\n/**\n * Highlight coordinator interface\n *\n * Manages content highlighting for TTS, annotations, and selections.\n */\nexport interface HighlightCoordinatorApi {\n\t/**\n\t * Highlight a text range\n\t */\n\thighlightRange(\n\t\trange: Range,\n\t\ttype: HighlightType,\n\t\tcolor: HighlightColor,\n\t): void;\n\n\t/**\n\t * Highlight a word for TTS (temporary)\n\t */\n\thighlightTTSWord(\n\t\ttextNode: Text,\n\t\tstartOffset: number,\n\t\tendOffset: number,\n\t): void;\n\n\t/**\n\t * Highlight a single element as the active TTS word (temporary).\n\t *\n\t * Marks exactly the supplied element (via `data-pie-tts-word-element`)\n\t * without walking up to a containing ancestor. Used for atomic targets that\n\t * have no direct text node to range over — most notably MathJax CHTML tokens\n\t * (e.g. `<mjx-mi><mjx-c/></mjx-mi>`) and whole-expression fallbacks. Painting\n\t * the element itself is what lets a resolved math token highlight as a token\n\t * rather than escalating to the full `<math>` / `<mjx-container>`.\n\t *\n\t * Optional so lightweight coordinator mocks can omit it.\n\t */\n\thighlightTTSWordElement?(element: Element): void;\n\n\t/**\n\t * Highlight sentence(s) for TTS (background layer)\n\t */\n\thighlightTTSSentence(ranges: Range[]): void;\n\n\t/**\n\t * Clear all TTS highlights (word and sentence)\n\t */\n\tclearTTS(): void;\n\n\t/**\n\t * Clear highlights of a specific type\n\t */\n\tclearHighlights(type: HighlightType): void;\n\n\t/**\n\t * Clear all highlights\n\t */\n\tclearAll(): void;\n\n\t/**\n\t * Check if highlighting is supported in current environment\n\t */\n\tisSupported(): boolean;\n\n\t/**\n\t * Update TTS highlight style dynamically\n\t */\n\tupdateTTSHighlightStyle(color: string, opacity: number): void;\n}\n\n/**\n * Tool state interface\n */\nexport interface ToolState {\n\tid: string;\n\tname: string;\n\tisVisible: boolean;\n\telement: HTMLElement | null;\n\tlayer: ZIndexLayer;\n}\n\n/**\n * Tool coordinator interface\n *\n * Manages z-index layering and visibility for floating tools.\n */\nexport interface ToolCoordinatorApi {\n\t/**\n\t * Register a tool with the coordinator\n\t */\n\tregisterTool(\n\t\tid: string,\n\t\tname: string,\n\t\telement?: HTMLElement,\n\t\tlayer?: ZIndexLayer,\n\t): void;\n\n\t/**\n\t * Unregister a tool\n\t */\n\tunregisterTool(id: string): void;\n\n\t/**\n\t * Show a tool\n\t */\n\tshowTool(id: string): void;\n\n\t/**\n\t * Hide a tool\n\t */\n\thideTool(id: string): void;\n\n\t/**\n\t * Toggle tool visibility\n\t */\n\ttoggleTool(id: string): void;\n\n\t/**\n\t * Check if tool is visible\n\t */\n\tisToolVisible(id: string): boolean;\n\n\t/**\n\t * Bring an element to the front of its layer\n\t */\n\tbringToFront(element: HTMLElement): void;\n\n\t/**\n\t * Update the element reference for a tool\n\t */\n\tupdateToolElement(id: string, element: HTMLElement): void;\n\n\t/**\n\t * Get state for a specific tool\n\t */\n\tgetToolState(id: string): ToolState | undefined;\n\n\t/**\n\t * Get all visible tools\n\t */\n\tgetVisibleTools(): ToolState[];\n\n\t/**\n\t * Subscribe to tool state changes\n\t */\n\tsubscribe(listener: () => void): () => void;\n}\n\n/**\n * TTS service interface\n *\n * Provides text-to-speech functionality with provider-based architecture.\n * Supports QTI 3.0 accessibility catalogs for pre-authored spoken content.\n */\nexport interface TtsServiceApi {\n\t/**\n\t * Initialize TTS with a provider\n\t */\n\tinitialize(\n\t\tprovider: ITTSProvider,\n\t\tconfig?: Partial<TTSConfig>,\n\t): Promise<void>;\n\n\t/**\n\t * Speak text with optional catalog support\n\t */\n\tspeak(\n\t\ttext: string,\n\t\toptions?: {\n\t\t\tcatalogId?: string;\n\t\t\tcatalogContext?: CatalogLookupContext;\n\t\t\tlanguage?: string;\n\t\t\tcontentElement?: Element;\n\t\t},\n\t): Promise<void>;\n\n\t/**\n\t * Speak a text range\n\t */\n\tspeakRange(\n\t\trange: Range,\n\t\toptions?: { contentRoot?: Element | null },\n\t): Promise<void>;\n\n\t/**\n\t * Pause playback\n\t */\n\tpause(): void;\n\n\t/**\n\t * Resume playback\n\t */\n\tresume(): void;\n\n\t/**\n\t * Stop playback\n\t */\n\tstop(): void;\n\n\t/**\n\t * Request active TTS controls to hand off/deactivate their UI state.\n\t *\n\t * This is an orchestration hint for TTS tool chrome and does not replace\n\t * playback controls such as stop/pause/resume.\n\t */\n\trequestControlHandoff(): void;\n\n\t/**\n\t * Seek forward by sentence units\n\t */\n\tseekForward(units?: number): Promise<void>;\n\n\t/**\n\t * Seek backward by sentence units\n\t */\n\tseekBackward(units?: number): Promise<void>;\n\n\t/**\n\t * Check if currently playing\n\t */\n\tisPlaying(): boolean;\n\n\t/**\n\t * Check if paused\n\t */\n\tisPaused(): boolean;\n\n\t/**\n\t * Get current playback state\n\t */\n\tgetState(): PlaybackState;\n\n\t/**\n\t * Get currently speaking text\n\t */\n\tgetCurrentText(): string | null;\n\n\t/**\n\t * Subscribe to state changes\n\t */\n\tonStateChange(id: string, callback: (state: PlaybackState) => void): void;\n\n\t/**\n\t * Unsubscribe from state changes\n\t */\n\toffStateChange(id: string, callback: (state: PlaybackState) => void): void;\n\n\t/**\n\t * Get capabilities of current provider\n\t */\n\tgetCapabilities(): TTSProviderCapabilities | null;\n\n\t/**\n\t * Update TTS settings dynamically (rate, pitch, voice)\n\t */\n\tupdateSettings(settings: Partial<TTSConfig>): Promise<void>;\n\n\t/**\n\t * Set highlight coordinator for word highlighting\n\t */\n\tsetHighlightCoordinator(coordinator: HighlightCoordinatorApi): void;\n\n\t/**\n\t * Set accessibility catalog resolver for spoken content\n\t */\n\tsetCatalogResolver(resolver: AccessibilityCatalogResolver): void;\n}\n\n/**\n * Accessibility catalog resolver interface\n *\n * Manages QTI 3.0 accessibility catalogs at assessment and item levels.\n * Provides lookup and resolution services for alternative content representations.\n */\nexport interface AccessibilityCatalogResolverApi {\n\t/**\n\t * Set the default language for fallback resolution\n\t */\n\tsetDefaultLanguage(language: string): void;\n\n\t/**\n\t * Get the default language\n\t */\n\tgetDefaultLanguage(): string;\n\n\t/**\n\t * Add item-level catalogs (called when rendering a new item)\n\t */\n\taddItemCatalogs(catalogs: any[]): void;\n\n\t/**\n\t * Register catalogs scoped to a mounted content owner.\n\t */\n\tregisterCatalogs?(\n\t\tcontext: CatalogOwnerContext,\n\t\tcatalogs: any[],\n\t): () => void;\n\n\t/**\n\t * Clear item-level catalogs (called when leaving an item)\n\t */\n\tclearItemCatalogs(): void;\n\n\t/**\n\t * Check if a catalog exists\n\t */\n\thasCatalog(catalogId: string): boolean;\n\n\t/**\n\t * Get alternative content for a catalog identifier\n\t */\n\tgetAlternative(\n\t\tcatalogId: string,\n\t\toptions: CatalogLookupOptions,\n\t): ResolvedCatalog | null;\n\n\t/**\n\t * Get all available alternatives for a catalog identifier\n\t */\n\tgetAllAlternatives(catalogId: string): ResolvedCatalog[];\n\n\t/**\n\t * Get all catalog identifiers available\n\t */\n\tgetAllCatalogIds(): string[];\n\n\t/**\n\t * Get statistics about available catalogs\n\t */\n\tgetStatistics(): CatalogStatistics;\n\n\t/**\n\t * Check if a specific catalog type is available\n\t */\n\thasAlternativeType(catalogId: string, type: CatalogType): boolean;\n\n\t/**\n\t * Get all catalog IDs that have a specific type of alternative\n\t */\n\tgetCatalogsByType(type: CatalogType): string[];\n\n\t/**\n\t * Reset all catalogs\n\t */\n\treset(): void;\n\n\t/**\n\t * Destroy and cleanup\n\t */\n\tdestroy(): void;\n}\n\n/**\n * Element tool state store interface\n *\n * Manages element-level ephemeral tool state using composite keys for global uniqueness.\n * Tool state is client-only and separate from PIE session data (which is sent to server for scoring).\n */\nexport interface ElementToolStateStoreApi {\n\t/**\n\t * Generate a globally unique element ID from components\n\t */\n\tgetGlobalElementId(\n\t\tassessmentId: string,\n\t\tsectionId: string,\n\t\titemId: string,\n\t\telementId: string,\n\t): string;\n\n\t/**\n\t * Parse a global element ID into its components\n\t */\n\tparseGlobalElementId(globalElementId: string): {\n\t\tassessmentId: string;\n\t\tsectionId: string;\n\t\titemId: string;\n\t\telementId: string;\n\t} | null;\n\n\t/**\n\t * Set state for a specific tool on an element\n\t */\n\tsetState(globalElementId: string, toolId: string, state: any): void;\n\n\t/**\n\t * Get state for a specific tool on an element\n\t */\n\tgetState(globalElementId: string, toolId: string): any | undefined;\n\n\t/**\n\t * Get all tool states for a specific element\n\t */\n\tgetElementState(globalElementId: string): Record<string, any>;\n\n\t/**\n\t * Get all element states\n\t */\n\tgetAllState(): Record<string, Record<string, any>>;\n\n\t/**\n\t * Subscribe to state changes\n\t */\n\tsubscribe(\n\t\tcallback: (state: Map<string, Map<string, any>>) => void,\n\t): () => void;\n\n\t/**\n\t * Set callback for persistence integration\n\t */\n\tsetOnStateChange(\n\t\tcallback: (state: Record<string, Record<string, any>>) => void,\n\t): void;\n\n\t/**\n\t * Load state from persistence\n\t */\n\tloadState(state: Record<string, Record<string, any>>): void;\n\n\t/**\n\t * Clear state for a specific element\n\t */\n\tclearElement(globalElementId: string): void;\n\n\t/**\n\t * Clear state for a specific tool across all elements\n\t */\n\tclearTool(toolId: string): void;\n\n\t/**\n\t * Clear all elements in a specific section\n\t */\n\tclearSection(assessmentId: string, sectionId: string): void;\n\n\t/**\n\t * Clear all state\n\t */\n\tclearAll(): void;\n}\n\n/**\n * Toolkit coordinator interface\n *\n * Orchestrates all toolkit services (TTS, tools, accessibility, state management) from a single entry point.\n * Provides centralized configuration for tool availability and settings.\n */\nexport interface ToolkitCoordinatorApi {\n\t/**\n\t * Assessment identifier\n\t */\n\treadonly assessmentId: string;\n\n\t/**\n\t * Configuration\n\t */\n\treadonly config: {\n\t\ttools?: {\n\t\t\tproviders?: Record<string, ToolProviderConfig | undefined>;\n\t\t};\n\t};\n\n\t/**\n\t * TTS service\n\t */\n\treadonly ttsService: TtsServiceApi;\n\n\t/**\n\t * Tool coordinator\n\t */\n\treadonly toolCoordinator: ToolCoordinatorApi;\n\n\t/**\n\t * Highlight coordinator\n\t */\n\treadonly highlightCoordinator: HighlightCoordinatorApi;\n\n\t/**\n\t * Element tool state store\n\t */\n\treadonly elementToolStateStore: ElementToolStateStoreApi;\n\n\t/**\n\t * Catalog resolver\n\t */\n\treadonly catalogResolver: AccessibilityCatalogResolverApi;\n\n\t/**\n\t * Tool provider registry\n\t */\n\treadonly toolProviderRegistry: ToolProviderRegistry;\n\n\t/**\n\t * Get all services as a bundle\n\t */\n\tgetServiceBundle(): {\n\t\tttsService: TtsServiceApi;\n\t\ttoolCoordinator: ToolCoordinatorApi;\n\t\thighlightCoordinator: HighlightCoordinatorApi;\n\t\telementToolStateStore: ElementToolStateStoreApi;\n\t\tcatalogResolver: AccessibilityCatalogResolverApi;\n\t\ttoolProviderRegistry: ToolProviderRegistry;\n\t};\n\n\t/**\n\t * Ensure TTS service is initialized and ready.\n\t */\n\tensureTTSReady(config?: Record<string, unknown>): Promise<void>;\n\n\t/**\n\t * Ensure a provider is initialized and ready.\n\t */\n\tensureProviderReady(providerId: string): Promise<unknown>;\n\n\t/**\n\t * Wait until coordinator initialization is complete.\n\t */\n\twaitUntilReady(): Promise<void>;\n\n\t/**\n\t * Check if coordinator has completed initialization.\n\t */\n\tisReady(): boolean;\n\n\t/**\n\t * Read current initialization status.\n\t */\n\tgetInitStatus(): ToolkitInitStatus;\n\n\t/**\n\t * Check if a tool is enabled\n\t */\n\tisToolEnabled(toolId: string): boolean;\n\n\t/**\n\t * Get tool configuration\n\t */\n\tgetToolConfig(toolId: string): ToolProviderConfig | null;\n\n\t/**\n\t * Update tool configuration\n\t */\n\tupdateToolConfig(toolId: string, updates: Partial<ToolProviderConfig>): void;\n\n\t/**\n\t * Update the enabled tool list for one placement level.\n\t */\n\tupdateToolPlacement(level: ToolPlacementLevel, toolIds: string[]): void;\n\n\t/**\n\t * Patch one or more placement levels in the canonical tools config.\n\t */\n\tupdateToolsPlacement(partial: ToolPlacementConfig): void;\n\n\t/**\n\t * Register or update lifecycle hooks at runtime.\n\t */\n\tsetHooks(hooks: ToolkitCoordinatorHooks): void;\n\n\t/**\n\t * Return a section controller if already created.\n\t */\n\tgetSectionController(args: {\n\t\tsectionId: string;\n\t\tattemptId?: string;\n\t}): SectionControllerHandle | undefined;\n\n\t/**\n\t * Subscribe to section controller events.\n\t *\n\t * The listener is bound to the toolkit's *active section cohort* and\n\t * automatically migrates across cohort transitions\n\t * (`getOrCreateSectionController` for a different cohort). On every\n\t * migration the listener receives a snapshot replay of the new\n\t * cohort's already-loaded `content-loaded` events followed by the\n\t * aggregate `section-loading-complete`, in the canonical order a\n\t * fresh subscriber would have observed.\n\t *\n\t * Throws if no active section cohort exists; host code must call\n\t * `getOrCreateSectionController(...)` at least once before\n\t * subscribing. (`toolkit-ready` alone is not sufficient — it fires\n\t * once toolkit state has loaded but before any section controller\n\t * has been created.) The typical pattern is to subscribe once\n\t * immediately after the first `getOrCreateSectionController(...)`\n\t * resolves; the subscription then follows the active cohort across\n\t * all subsequent navigation without further wiring.\n\t *\n\t * Subscribing the same `listener` reference twice replaces the prior\n\t * subscription with the new one (filter args from the second call\n\t * win); calling the returned disposer twice is a no-op.\n\t *\n\t * A listener that throws is caught and `console.warn`-logged; the\n\t * throw does not interrupt fan-out to the remaining listeners.\n\t */\n\tsubscribeSectionEvents(args: SectionEventSubscriptionArgs): () => void;\n\n\t/**\n\t * Subscribe to item-scoped section controller events.\n\t *\n\t * Same active-cohort binding contract as {@link subscribeSectionEvents};\n\t * defaults `eventTypes` to the item-scoped subset.\n\t */\n\tsubscribeItemEvents(args: SectionItemEventSubscriptionArgs): () => void;\n\n\t/**\n\t * Subscribe to section-scoped lifecycle/loading/completion/error events.\n\t *\n\t * Same active-cohort binding contract as {@link subscribeSectionEvents};\n\t * defaults `eventTypes` to the section-scoped subset.\n\t */\n\tsubscribeSectionLifecycleEvents(\n\t\targs: SectionScopedEventSubscriptionArgs,\n\t): () => void;\n\n\t/**\n\t * Create or reuse a section controller with single-flight deduplication.\n\t */\n\tgetOrCreateSectionController(args: {\n\t\tsectionId: string;\n\t\tattemptId?: string;\n\t\tinput?: unknown;\n\t\tupdateExisting?: boolean;\n\t\tcreateDefaultController: () =>\n\t\t\t| SectionControllerHandle\n\t\t\t| Promise<SectionControllerHandle>;\n\t}): Promise<SectionControllerHandle>;\n\n\t/**\n\t * Dispose an existing section controller.\n\t */\n\tdisposeSectionController(args: {\n\t\tsectionId: string;\n\t\tattemptId?: string;\n\t\tpersistBeforeDispose?: boolean;\n\t\tclearPersistence?: boolean;\n\t}): Promise<void>;\n\n\t/**\n\t * Subscribe to framework-error events emitted by the coordinator.\n\t *\n\t * Mirrors the shape of {@link subscribeTelemetry} (see\n\t * `ToolkitCoordinator.subscribeTelemetry`): a synchronous,\n\t * multi-subscriber stream where each call to the internal bus's\n\t * `reportFrameworkError` fans out to every active listener exactly once.\n\t *\n\t * The returned function detaches the listener; calling it twice is a\n\t * no-op. A listener that throws is caught and logged; the throw does\n\t * not break fan-out to the remaining listeners.\n\t *\n\t * Use this to wire framework errors into Sentry / Datadog / a custom\n\t * banner without listening on a DOM event. The DOM event\n\t * (`framework-error`) and the canonical `onFrameworkError` prop on\n\t * `<pie-assessment-toolkit>` consume the same bus.\n\t */\n\tsubscribeFrameworkErrors(listener: FrameworkErrorListener): () => void;\n\n\t// ----------------------------------------------------------------\n\t// Tool Policy Engine — public surface (M8 PR 2 / PR 3).\n\t//\n\t// The coordinator owns a single `ToolPolicyEngine` instance and\n\t// exposes its decision and subscription surface through the API\n\t// so that toolbar custom elements (`pie-item-toolbar`,\n\t// `pie-section-toolbar`), the base section player, and bespoke\n\t// host instrumentation (PNP debugger, etc.) all flow through the\n\t// same engine. Hosts that want to drive PNP/profile inputs imperatively\n\t// (instead of binding props on `<pie-assessment-toolkit>`) call\n\t// `updateAssessment` / `updateCurrentItemRef` /\n\t// `setPnpEnforcement` directly.\n\t// ----------------------------------------------------------------\n\n\t/**\n\t * Resolve the visible tool set for a given placement level + scope.\n\t * Returns the engine's full decision (visible tools, diagnostics,\n\t * provenance). Hosts that only need the IDs may map\n\t * `decision.visibleTools` themselves.\n\t */\n\tdecideToolPolicy(request: ToolPolicyDecisionRequest): ToolPolicyDecision;\n\n\t/**\n\t * Subscribe to policy-engine change events. Fires whenever the\n\t * coordinator's bound policy inputs change (`updateToolConfig`,\n\t * `updateToolPlacement`, `updateAssessment`, `updateCurrentItemRef`,\n\t * `setPnpEnforcement`) or a custom `PolicySource` is registered /\n\t * removed. Listeners that need the new visible tool set should\n\t * call `decideToolPolicy(...)` with their level / scope.\n\t */\n\tonPolicyChange(listener: ToolPolicyChangeListener): () => void;\n\n\t/**\n\t * Bind (or clear) the active assessment for PNP/profile policy decisions.\n\t *\n\t * Under auto-mode (no host override via {@link setPnpEnforcement}),\n\t * the engine flips to `pnpEnforcement: \"on\"` iff the assessment\n\t * carries profile precedence material (`personalNeedsProfile`,\n\t * `settings.districtPolicy`, `settings.testAdministration`) or the\n\t * currently-bound item ref carries item-level profile inputs. A bare\n\t * assessment record (just `id` / `name`) keeps `\"off\"`.\n\t *\n\t * The host override set via {@link setPnpEnforcement} is sticky\n\t * across assessment swaps.\n\t */\n\tupdateAssessment(assessment: AssessmentEntity | null): void;\n\n\t/**\n\t * Bind (or clear) the current item reference for policy decisions.\n\t * Used by item-level profile gates (item `requiredTools` /\n\t * `restrictedTools` / `toolParameters`). Item-level profile material\n\t * also feeds the auto-mode helper — navigating to an item with\n\t * profile settings can flip auto-mode to `\"on\"` even when the parent\n\t * assessment carries no profile block of its own.\n\t */\n\tupdateCurrentItemRef(itemRef: AssessmentItemRef | null): void;\n\n\t/**\n\t * Override the auto-mode PNP/profile enforcement decision. Pass `\"on\"` /\n\t * `\"off\"` to pin the mode, or `null` to clear the override and\n\t * return to auto-mode (`\"on\"` iff the bound assessment / item ref\n\t * carries profile material, otherwise `\"off\"`).\n\t */\n\tsetPnpEnforcement(mode: PnpEnforcementMode | null): void;\n\n\t/**\n\t * Read the engine inputs currently driving decisions. Useful for\n\t * debugging / instrumentation; do not mutate.\n\t */\n\tgetPolicyInputs(): Readonly<ResolvedEngineInputs>;\n\n\t/**\n\t * Register a custom `PolicySource`. The source participates in\n\t * every subsequent `decideToolPolicy(...)` call until disposed\n\t * (the returned function detaches).\n\t */\n\tregisterPolicySource(source: PolicySource): () => void;\n\n\t/**\n\t * Register a host-owned resolver for scoped tool render context.\n\t */\n\tregisterToolContextResolver(\n\t\ttoolId: string,\n\t\tresolver: ToolContextResolver,\n\t): () => void;\n\n\t/**\n\t * Replace all host-owned render-context resolvers.\n\t */\n\tsetToolContextResolvers(\n\t\tresolvers: ToolContextResolverMap | null | undefined,\n\t): void;\n\n\t/**\n\t * Whether a host resolver is registered for this tool.\n\t */\n\thasToolContextResolver(toolId: string): boolean;\n\n\t/**\n\t * Resolve render visibility/params for a tool that already survived policy gates.\n\t */\n\tresolveToolContext(\n\t\tcontext: ToolContextResolverContext,\n\t): ResolvedToolContext | null;\n\n\t/**\n\t * Subscribe to resolver registration/removal changes.\n\t */\n\tonToolContextResolverChange(listener: () => void): () => void;\n}\n\n// I18nServiceApi is re-exported from @pie-players/pie-players-shared/i18n\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/services/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;AA60BH,0EAA0E","sourcesContent":["/**\n * Service Interfaces\n *\n * Public interfaces for all core assessment toolkit services.\n * These interfaces define the contracts that service implementations must fulfill,\n * enabling dependency injection, testing, and custom implementations.\n *\n * Part of PIE Assessment Toolkit.\n */\n\nimport type { I18nServiceApi } from \"@pie-players/pie-players-shared/i18n\";\nimport type {\n\tAccessibilityCatalogResolver,\n\tCatalogLookupContext,\n\tCatalogLookupOptions,\n\tCatalogOwnerContext,\n\tCatalogStatistics,\n\tCatalogType,\n\tResolvedCatalog,\n} from \"./AccessibilityCatalogResolver.js\";\nimport type { FrameworkErrorListener } from \"./framework-error-bus.js\";\nimport type { HighlightColor, HighlightType } from \"./HighlightCoordinator.js\";\nimport type {\n\tSectionControllerHandle,\n\tSectionItemEventSubscriptionArgs,\n\tSectionScopedEventSubscriptionArgs,\n\tSectionEventSubscriptionArgs,\n\tToolkitCoordinatorHooks,\n\tToolkitInitStatus,\n} from \"./ToolkitCoordinator.js\";\nimport type { FontSize, ThemeConfig } from \"./ThemeProvider.js\";\nimport type { ZIndexLayer } from \"./ToolCoordinator.js\";\nimport type { PlaybackState, TTSConfig } from \"./TTSService.js\";\nimport type {\n\tToolPlacementConfig,\n\tToolPlacementLevel,\n\tToolProviderConfig,\n} from \"./tools-config-normalizer.js\";\nimport type { ToolProviderRegistry } from \"./tool-providers/ToolProviderRegistry.js\";\nimport type {\n\tPolicySource,\n\tPnpEnforcementMode,\n\tResolvedEngineInputs,\n\tToolPolicyChangeListener,\n\tToolPolicyDecision,\n\tToolPolicyDecisionRequest,\n} from \"../policy/engine.js\";\nimport type {\n\tAssessmentEntity,\n\tAssessmentItemRef,\n} from \"@pie-players/pie-players-shared/types\";\nimport type {\n\tITTSProvider,\n\tTTSProviderCapabilities,\n} from \"@pie-players/pie-tts\";\nimport type {\n\tResolvedToolContext,\n\tToolContextResolver,\n\tToolContextResolverContext,\n\tToolContextResolverMap,\n} from \"./ToolRegistry.js\";\n\n// Re-export I18nServiceApi from players-shared\nexport type { I18nServiceApi };\n\n/**\n * Theme provider interface\n *\n * Applies consistent accessibility theming across items and tools.\n */\nexport interface ThemeProviderApi {\n\t/**\n\t * Apply theme configuration\n\t */\n\tapplyTheme(config: ThemeConfig): void;\n\n\t/**\n\t * Get current theme configuration\n\t */\n\tgetCurrentTheme(): Required<ThemeConfig>;\n\n\t/**\n\t * Reset to default theme\n\t */\n\treset(): void;\n\n\t/**\n\t * Clean up and remove theme styles\n\t */\n\tdestroy(): void;\n}\n\n/**\n * Highlight coordinator interface\n *\n * Manages content highlighting for TTS, annotations, and selections.\n */\nexport interface HighlightCoordinatorApi {\n\t/**\n\t * Highlight a text range\n\t */\n\thighlightRange(\n\t\trange: Range,\n\t\ttype: HighlightType,\n\t\tcolor: HighlightColor,\n\t): void;\n\n\t/**\n\t * Highlight a word for TTS (temporary)\n\t */\n\thighlightTTSWord(\n\t\ttextNode: Text,\n\t\tstartOffset: number,\n\t\tendOffset: number,\n\t): void;\n\n\t/**\n\t * Highlight a single element as the active TTS word (temporary).\n\t *\n\t * Marks exactly the supplied element (via `data-pie-tts-word-element`)\n\t * without walking up to a containing ancestor. Used for atomic targets that\n\t * have no direct text node to range over — most notably MathJax CHTML tokens\n\t * (e.g. `<mjx-mi><mjx-c/></mjx-mi>`) and whole-expression fallbacks. Painting\n\t * the element itself is what lets a resolved math token highlight as a token\n\t * rather than escalating to the full `<math>` / `<mjx-container>`.\n\t *\n\t * Optional so lightweight coordinator mocks can omit it.\n\t */\n\thighlightTTSWordElement?(element: Element): void;\n\n\t/**\n\t * Highlight sentence(s) for TTS (background layer)\n\t */\n\thighlightTTSSentence(ranges: Range[]): void;\n\n\t/**\n\t * Clear all TTS highlights (word and sentence)\n\t */\n\tclearTTS(): void;\n\n\t/**\n\t * Clear highlights of a specific type\n\t */\n\tclearHighlights(type: HighlightType): void;\n\n\t/**\n\t * Clear all highlights\n\t */\n\tclearAll(): void;\n\n\t/**\n\t * Check if highlighting is supported in current environment\n\t */\n\tisSupported(): boolean;\n\n\t/**\n\t * Update TTS highlight style dynamically\n\t */\n\tupdateTTSHighlightStyle(color: string, opacity: number): void;\n}\n\n/**\n * Tool state interface\n */\nexport interface ToolState {\n\tid: string;\n\tname: string;\n\tisVisible: boolean;\n\telement: HTMLElement | null;\n\tlayer: ZIndexLayer;\n}\n\n/**\n * Tool coordinator interface\n *\n * Manages z-index layering and visibility for floating tools.\n */\nexport interface ToolCoordinatorApi {\n\t/**\n\t * Register a tool with the coordinator\n\t */\n\tregisterTool(\n\t\tid: string,\n\t\tname: string,\n\t\telement?: HTMLElement,\n\t\tlayer?: ZIndexLayer,\n\t): void;\n\n\t/**\n\t * Unregister a tool\n\t */\n\tunregisterTool(id: string): void;\n\n\t/**\n\t * Show a tool\n\t */\n\tshowTool(id: string): void;\n\n\t/**\n\t * Hide a tool\n\t */\n\thideTool(id: string): void;\n\n\t/**\n\t * Toggle tool visibility\n\t */\n\ttoggleTool(id: string): void;\n\n\t/**\n\t * Check if tool is visible\n\t */\n\tisToolVisible(id: string): boolean;\n\n\t/**\n\t * Bring an element to the front of its layer\n\t */\n\tbringToFront(element: HTMLElement): void;\n\n\t/**\n\t * Update the element reference for a tool\n\t */\n\tupdateToolElement(id: string, element: HTMLElement): void;\n\n\t/**\n\t * Get state for a specific tool\n\t */\n\tgetToolState(id: string): ToolState | undefined;\n\n\t/**\n\t * Get all visible tools\n\t */\n\tgetVisibleTools(): ToolState[];\n\n\t/**\n\t * Subscribe to tool state changes\n\t */\n\tsubscribe(listener: () => void): () => void;\n}\n\n/**\n * TTS service interface\n *\n * Provides text-to-speech functionality with provider-based architecture.\n * Supports QTI 3.0 accessibility catalogs for pre-authored spoken content.\n */\nexport interface TtsServiceApi {\n\t/**\n\t * Initialize TTS with a provider\n\t */\n\tinitialize(\n\t\tprovider: ITTSProvider,\n\t\tconfig?: Partial<TTSConfig>,\n\t): Promise<void>;\n\n\t/**\n\t * Speak text with optional catalog support\n\t */\n\tspeak(\n\t\ttext: string,\n\t\toptions?: {\n\t\t\tcatalogId?: string;\n\t\t\tcatalogContext?: CatalogLookupContext;\n\t\t\tlanguage?: string;\n\t\t\tcontentElement?: Element;\n\t\t},\n\t): Promise<void>;\n\n\t/**\n\t * Speak a text range\n\t */\n\tspeakRange(\n\t\trange: Range,\n\t\toptions?: { contentRoot?: Element | null },\n\t): Promise<void>;\n\n\t/**\n\t * Pause playback\n\t */\n\tpause(): void;\n\n\t/**\n\t * Resume playback\n\t */\n\tresume(): void;\n\n\t/**\n\t * Stop playback\n\t */\n\tstop(): void;\n\n\t/**\n\t * Request active TTS controls to hand off/deactivate their UI state.\n\t *\n\t * This is an orchestration hint for TTS tool chrome and does not replace\n\t * playback controls such as stop/pause/resume.\n\t */\n\trequestControlHandoff(): void;\n\n\t/**\n\t * Seek forward by sentence units\n\t */\n\tseekForward(units?: number): Promise<void>;\n\n\t/**\n\t * Seek backward by sentence units\n\t */\n\tseekBackward(units?: number): Promise<void>;\n\n\t/**\n\t * Check if currently playing\n\t */\n\tisPlaying(): boolean;\n\n\t/**\n\t * Check if paused\n\t */\n\tisPaused(): boolean;\n\n\t/**\n\t * Get current playback state\n\t */\n\tgetState(): PlaybackState;\n\n\t/**\n\t * Get currently speaking text\n\t */\n\tgetCurrentText(): string | null;\n\n\t/**\n\t * Subscribe to state changes\n\t */\n\tonStateChange(id: string, callback: (state: PlaybackState) => void): void;\n\n\t/**\n\t * Unsubscribe from state changes\n\t */\n\toffStateChange(id: string, callback: (state: PlaybackState) => void): void;\n\n\t/**\n\t * Get capabilities of current provider\n\t */\n\tgetCapabilities(): TTSProviderCapabilities | null;\n\n\t/**\n\t * Update TTS settings dynamically (rate, pitch, voice)\n\t */\n\tupdateSettings(settings: Partial<TTSConfig>): Promise<void>;\n\n\t/**\n\t * Set highlight coordinator for word highlighting\n\t */\n\tsetHighlightCoordinator(coordinator: HighlightCoordinatorApi): void;\n\n\t/**\n\t * Set accessibility catalog resolver for spoken content\n\t */\n\tsetCatalogResolver(resolver: AccessibilityCatalogResolver): void;\n}\n\n/**\n * Accessibility catalog resolver interface\n *\n * Manages QTI 3.0 accessibility catalogs at assessment and item levels.\n * Provides lookup and resolution services for alternative content representations.\n */\nexport interface AccessibilityCatalogResolverApi {\n\t/**\n\t * Set the default language for fallback resolution\n\t */\n\tsetDefaultLanguage(language: string): void;\n\n\t/**\n\t * Get the default language\n\t */\n\tgetDefaultLanguage(): string;\n\n\t/**\n\t * Add item-level catalogs (called when rendering a new item)\n\t */\n\taddItemCatalogs(catalogs: any[]): void;\n\n\t/**\n\t * Register catalogs scoped to a mounted content owner.\n\t */\n\tregisterCatalogs?(context: CatalogOwnerContext, catalogs: any[]): () => void;\n\n\t/**\n\t * Clear item-level catalogs (called when leaving an item)\n\t */\n\tclearItemCatalogs(): void;\n\n\t/**\n\t * Check if a catalog exists\n\t */\n\thasCatalog(catalogId: string): boolean;\n\n\t/**\n\t * Get alternative content for a catalog identifier\n\t */\n\tgetAlternative(\n\t\tcatalogId: string,\n\t\toptions: CatalogLookupOptions,\n\t): ResolvedCatalog | null;\n\n\t/**\n\t * Get all available alternatives for a catalog identifier\n\t */\n\tgetAllAlternatives(catalogId: string): ResolvedCatalog[];\n\n\t/**\n\t * Get all catalog identifiers available\n\t */\n\tgetAllCatalogIds(): string[];\n\n\t/**\n\t * Get statistics about available catalogs\n\t */\n\tgetStatistics(): CatalogStatistics;\n\n\t/**\n\t * Check if a specific catalog type is available\n\t */\n\thasAlternativeType(catalogId: string, type: CatalogType): boolean;\n\n\t/**\n\t * Get all catalog IDs that have a specific type of alternative\n\t */\n\tgetCatalogsByType(type: CatalogType): string[];\n\n\t/**\n\t * Reset all catalogs\n\t */\n\treset(): void;\n\n\t/**\n\t * Destroy and cleanup\n\t */\n\tdestroy(): void;\n}\n\n/**\n * Element tool state store interface\n *\n * Manages element-level ephemeral tool state using composite keys for global uniqueness.\n * Tool state is client-only and separate from PIE session data (which is sent to server for scoring).\n */\nexport interface ElementToolStateStoreApi {\n\t/**\n\t * Generate a globally unique element ID from components\n\t */\n\tgetGlobalElementId(\n\t\tassessmentId: string,\n\t\tsectionId: string,\n\t\titemId: string,\n\t\telementId: string,\n\t): string;\n\n\t/**\n\t * Parse a global element ID into its components\n\t */\n\tparseGlobalElementId(globalElementId: string): {\n\t\tassessmentId: string;\n\t\tsectionId: string;\n\t\titemId: string;\n\t\telementId: string;\n\t} | null;\n\n\t/**\n\t * Set state for a specific tool on an element\n\t */\n\tsetState(globalElementId: string, toolId: string, state: any): void;\n\n\t/**\n\t * Get state for a specific tool on an element\n\t */\n\tgetState(globalElementId: string, toolId: string): any | undefined;\n\n\t/**\n\t * Get all tool states for a specific element\n\t */\n\tgetElementState(globalElementId: string): Record<string, any>;\n\n\t/**\n\t * Get all element states\n\t */\n\tgetAllState(): Record<string, Record<string, any>>;\n\n\t/**\n\t * Subscribe to state changes\n\t */\n\tsubscribe(\n\t\tcallback: (state: Map<string, Map<string, any>>) => void,\n\t): () => void;\n\n\t/**\n\t * Set callback for persistence integration\n\t */\n\tsetOnStateChange(\n\t\tcallback: (state: Record<string, Record<string, any>>) => void,\n\t): void;\n\n\t/**\n\t * Load state from persistence\n\t */\n\tloadState(state: Record<string, Record<string, any>>): void;\n\n\t/**\n\t * Clear state for a specific element\n\t */\n\tclearElement(globalElementId: string): void;\n\n\t/**\n\t * Clear state for a specific tool across all elements\n\t */\n\tclearTool(toolId: string): void;\n\n\t/**\n\t * Clear all elements in a specific section\n\t */\n\tclearSection(assessmentId: string, sectionId: string): void;\n\n\t/**\n\t * Clear all state\n\t */\n\tclearAll(): void;\n}\n\n/**\n * Toolkit coordinator interface\n *\n * Orchestrates all toolkit services (TTS, tools, accessibility, state management) from a single entry point.\n * Provides centralized configuration for tool availability and settings.\n */\nexport interface ToolkitCoordinatorApi {\n\t/**\n\t * Assessment identifier\n\t */\n\treadonly assessmentId: string;\n\n\t/**\n\t * Configuration\n\t */\n\treadonly config: {\n\t\ttools?: {\n\t\t\tproviders?: Record<string, ToolProviderConfig | undefined>;\n\t\t};\n\t};\n\n\t/**\n\t * TTS service\n\t */\n\treadonly ttsService: TtsServiceApi;\n\n\t/**\n\t * Tool coordinator\n\t */\n\treadonly toolCoordinator: ToolCoordinatorApi;\n\n\t/**\n\t * Highlight coordinator\n\t */\n\treadonly highlightCoordinator: HighlightCoordinatorApi;\n\n\t/**\n\t * Element tool state store\n\t */\n\treadonly elementToolStateStore: ElementToolStateStoreApi;\n\n\t/**\n\t * Catalog resolver\n\t */\n\treadonly catalogResolver: AccessibilityCatalogResolverApi;\n\n\t/**\n\t * Tool provider registry\n\t */\n\treadonly toolProviderRegistry: ToolProviderRegistry;\n\n\t/**\n\t * Get all services as a bundle\n\t */\n\tgetServiceBundle(): {\n\t\tttsService: TtsServiceApi;\n\t\ttoolCoordinator: ToolCoordinatorApi;\n\t\thighlightCoordinator: HighlightCoordinatorApi;\n\t\telementToolStateStore: ElementToolStateStoreApi;\n\t\tcatalogResolver: AccessibilityCatalogResolverApi;\n\t\ttoolProviderRegistry: ToolProviderRegistry;\n\t};\n\n\t/**\n\t * Ensure TTS service is initialized and ready.\n\t */\n\tensureTTSReady(config?: Record<string, unknown>): Promise<void>;\n\n\t/**\n\t * Ensure a provider is initialized and ready.\n\t */\n\tensureProviderReady(providerId: string): Promise<unknown>;\n\n\t/**\n\t * Wait until coordinator initialization is complete.\n\t */\n\twaitUntilReady(): Promise<void>;\n\n\t/**\n\t * Check if coordinator has completed initialization.\n\t */\n\tisReady(): boolean;\n\n\t/**\n\t * Read current initialization status.\n\t */\n\tgetInitStatus(): ToolkitInitStatus;\n\n\t/**\n\t * Check if a tool is enabled\n\t */\n\tisToolEnabled(toolId: string): boolean;\n\n\t/**\n\t * Get tool configuration\n\t */\n\tgetToolConfig(toolId: string): ToolProviderConfig | null;\n\n\t/**\n\t * Update tool configuration\n\t */\n\tupdateToolConfig(toolId: string, updates: Partial<ToolProviderConfig>): void;\n\n\t/**\n\t * Update the enabled tool list for one placement level.\n\t */\n\tupdateToolPlacement(level: ToolPlacementLevel, toolIds: string[]): void;\n\n\t/**\n\t * Patch one or more placement levels in the canonical tools config.\n\t */\n\tupdateToolsPlacement(partial: ToolPlacementConfig): void;\n\n\t/**\n\t * Register or update lifecycle hooks at runtime.\n\t */\n\tsetHooks(hooks: ToolkitCoordinatorHooks): void;\n\n\t/**\n\t * Return a section controller if already created.\n\t */\n\tgetSectionController(args: {\n\t\tsectionId: string;\n\t\tattemptId?: string;\n\t}): SectionControllerHandle | undefined;\n\n\t/**\n\t * Subscribe to section controller events.\n\t *\n\t * The listener is bound to the toolkit's *active section cohort* and\n\t * automatically migrates across cohort transitions\n\t * (`getOrCreateSectionController` for a different cohort). On every\n\t * migration the listener receives a snapshot replay of the new\n\t * cohort's already-loaded `content-loaded` events followed by the\n\t * aggregate `section-loading-complete`, in the canonical order a\n\t * fresh subscriber would have observed.\n\t *\n\t * Throws if no active section cohort exists; host code must call\n\t * `getOrCreateSectionController(...)` at least once before\n\t * subscribing. (`toolkit-ready` alone is not sufficient — it fires\n\t * once toolkit state has loaded but before any section controller\n\t * has been created.) The typical pattern is to subscribe once\n\t * immediately after the first `getOrCreateSectionController(...)`\n\t * resolves; the subscription then follows the active cohort across\n\t * all subsequent navigation without further wiring.\n\t *\n\t * Subscribing the same `listener` reference twice replaces the prior\n\t * subscription with the new one (filter args from the second call\n\t * win); calling the returned disposer twice is a no-op.\n\t *\n\t * A listener that throws is caught and `console.warn`-logged; the\n\t * throw does not interrupt fan-out to the remaining listeners.\n\t */\n\tsubscribeSectionEvents(args: SectionEventSubscriptionArgs): () => void;\n\n\t/**\n\t * Subscribe to item-scoped section controller events.\n\t *\n\t * Same active-cohort binding contract as {@link subscribeSectionEvents};\n\t * defaults `eventTypes` to the item-scoped subset.\n\t */\n\tsubscribeItemEvents(args: SectionItemEventSubscriptionArgs): () => void;\n\n\t/**\n\t * Subscribe to section-scoped lifecycle/loading/completion/error events.\n\t *\n\t * Same active-cohort binding contract as {@link subscribeSectionEvents};\n\t * defaults `eventTypes` to the section-scoped subset.\n\t */\n\tsubscribeSectionLifecycleEvents(\n\t\targs: SectionScopedEventSubscriptionArgs,\n\t): () => void;\n\n\t/**\n\t * Create or reuse a section controller with single-flight deduplication.\n\t */\n\tgetOrCreateSectionController(args: {\n\t\tsectionId: string;\n\t\tattemptId?: string;\n\t\tinput?: unknown;\n\t\tupdateExisting?: boolean;\n\t\tcreateDefaultController: () =>\n\t\t\t| SectionControllerHandle\n\t\t\t| Promise<SectionControllerHandle>;\n\t}): Promise<SectionControllerHandle>;\n\n\t/**\n\t * Dispose an existing section controller.\n\t */\n\tdisposeSectionController(args: {\n\t\tsectionId: string;\n\t\tattemptId?: string;\n\t\tpersistBeforeDispose?: boolean;\n\t\tclearPersistence?: boolean;\n\t}): Promise<void>;\n\n\t/**\n\t * Subscribe to framework-error events emitted by the coordinator.\n\t *\n\t * Mirrors the shape of {@link subscribeTelemetry} (see\n\t * `ToolkitCoordinator.subscribeTelemetry`): a synchronous,\n\t * multi-subscriber stream where each call to the internal bus's\n\t * `reportFrameworkError` fans out to every active listener exactly once.\n\t *\n\t * The returned function detaches the listener; calling it twice is a\n\t * no-op. A listener that throws is caught and logged; the throw does\n\t * not break fan-out to the remaining listeners.\n\t *\n\t * Use this to wire framework errors into Sentry / Datadog / a custom\n\t * banner without listening on a DOM event. The DOM event\n\t * (`framework-error`) and the canonical `onFrameworkError` prop on\n\t * `<pie-assessment-toolkit>` consume the same bus.\n\t */\n\tsubscribeFrameworkErrors(listener: FrameworkErrorListener): () => void;\n\n\t// ----------------------------------------------------------------\n\t// Tool Policy Engine — public surface (M8 PR 2 / PR 3).\n\t//\n\t// The coordinator owns a single `ToolPolicyEngine` instance and\n\t// exposes its decision and subscription surface through the API\n\t// so that toolbar custom elements (`pie-item-toolbar`,\n\t// `pie-section-toolbar`), the base section player, and bespoke\n\t// host instrumentation (PNP debugger, etc.) all flow through the\n\t// same engine. Hosts that want to drive PNP/profile inputs imperatively\n\t// (instead of binding props on `<pie-assessment-toolkit>`) call\n\t// `updateAssessment` / `updateCurrentItemRef` /\n\t// `setPnpEnforcement` directly.\n\t// ----------------------------------------------------------------\n\n\t/**\n\t * Resolve the visible tool set for a given placement level + scope.\n\t * Returns the engine's full decision (visible tools, diagnostics,\n\t * provenance). Hosts that only need the IDs may map\n\t * `decision.visibleTools` themselves.\n\t */\n\tdecideToolPolicy(request: ToolPolicyDecisionRequest): ToolPolicyDecision;\n\n\t/**\n\t * Subscribe to policy-engine change events. Fires whenever the\n\t * coordinator's bound policy inputs change (`updateToolConfig`,\n\t * `updateToolPlacement`, `updateAssessment`, `updateCurrentItemRef`,\n\t * `setPnpEnforcement`) or a custom `PolicySource` is registered /\n\t * removed. Listeners that need the new visible tool set should\n\t * call `decideToolPolicy(...)` with their level / scope.\n\t */\n\tonPolicyChange(listener: ToolPolicyChangeListener): () => void;\n\n\t/**\n\t * Bind (or clear) the active assessment for PNP/profile policy decisions.\n\t *\n\t * Under auto-mode (no host override via {@link setPnpEnforcement}),\n\t * the engine flips to `pnpEnforcement: \"on\"` iff the assessment\n\t * carries profile precedence material (`personalNeedsProfile`,\n\t * `settings.districtPolicy`, `settings.testAdministration`) or the\n\t * currently-bound item ref carries item-level profile inputs. A bare\n\t * assessment record (just `id` / `name`) keeps `\"off\"`.\n\t *\n\t * The host override set via {@link setPnpEnforcement} is sticky\n\t * across assessment swaps.\n\t */\n\tupdateAssessment(assessment: AssessmentEntity | null): void;\n\n\t/**\n\t * Bind (or clear) the current item reference for policy decisions.\n\t * Used by item-level profile gates (item `requiredTools` /\n\t * `restrictedTools` / `toolParameters`). Item-level profile material\n\t * also feeds the auto-mode helper — navigating to an item with\n\t * profile settings can flip auto-mode to `\"on\"` even when the parent\n\t * assessment carries no profile block of its own.\n\t */\n\tupdateCurrentItemRef(itemRef: AssessmentItemRef | null): void;\n\n\t/**\n\t * Override the auto-mode PNP/profile enforcement decision. Pass `\"on\"` /\n\t * `\"off\"` to pin the mode, or `null` to clear the override and\n\t * return to auto-mode (`\"on\"` iff the bound assessment / item ref\n\t * carries profile material, otherwise `\"off\"`).\n\t */\n\tsetPnpEnforcement(mode: PnpEnforcementMode | null): void;\n\n\t/**\n\t * Read the engine inputs currently driving decisions. Useful for\n\t * debugging / instrumentation; do not mutate.\n\t */\n\tgetPolicyInputs(): Readonly<ResolvedEngineInputs>;\n\n\t/**\n\t * Register a custom `PolicySource`. The source participates in\n\t * every subsequent `decideToolPolicy(...)` call until disposed\n\t * (the returned function detaches).\n\t */\n\tregisterPolicySource(source: PolicySource): () => void;\n\n\t/**\n\t * Register a host-owned resolver for scoped tool render context.\n\t */\n\tregisterToolContextResolver(\n\t\ttoolId: string,\n\t\tresolver: ToolContextResolver,\n\t): () => void;\n\n\t/**\n\t * Replace all host-owned render-context resolvers.\n\t */\n\tsetToolContextResolvers(\n\t\tresolvers: ToolContextResolverMap | null | undefined,\n\t): void;\n\n\t/**\n\t * Whether a host resolver is registered for this tool.\n\t */\n\thasToolContextResolver(toolId: string): boolean;\n\n\t/**\n\t * Resolve render visibility/params for a tool that already survived policy gates.\n\t */\n\tresolveToolContext(\n\t\tcontext: ToolContextResolverContext,\n\t): ResolvedToolContext | null;\n\n\t/**\n\t * Subscribe to resolver registration/removal changes.\n\t */\n\tonToolContextResolverChange(listener: () => void): () => void;\n}\n\n// I18nServiceApi is re-exported from @pie-players/pie-players-shared/i18n\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"section-controller-types.js","sourceRoot":"","sources":["../../src/services/section-controller-types.ts"],"names":[],"mappings":"","sourcesContent":["export interface SectionControllerKey {\n\tassessmentId: string;\n\tsectionId: string;\n\tattemptId?: string;\n}\n\nexport interface SectionControllerContext {\n\tkey: SectionControllerKey;\n\tcoordinator: unknown;\n\tinput?: unknown;\n}\n\nexport interface SectionSessionPersistenceStrategy {\n\tloadSession(\n\t\tcontext: SectionControllerContext,\n\t): SectionControllerSessionState | null | Promise<SectionControllerSessionState | null>;\n\tsaveSession(\n\t\tcontext: SectionControllerContext,\n\t\tsession: SectionControllerSessionState | null,\n\t): void | Promise<void>;\n\tclearSession?(context: SectionControllerContext): void | Promise<void>;\n}\n\nexport interface SectionSessionPersistenceConfig {\n\tcontext: SectionControllerContext;\n\tstrategy: SectionSessionPersistenceStrategy;\n}\n\nexport interface SectionControllerApplySessionOptions {\n\t/**\n\t * applySession contract:\n\t * - Preferred input is the output of getSession().\n\t * - itemSessions may contain canonical attempt entries\n\t * ({ itemIdentifier, session, isCompleted }) or raw session payloads\n\t * ({ id, data, ... }); controller normalizes these before applying.\n\t */\n\tmode?: \"replace\" | \"merge\";\n}\n\nexport interface SectionControllerLoadedRenderable {\n\titemId: string;\n\tcanonicalItemId: string;\n\tcontentKind: \"item\" | \"passage\" | \"rubric\" | \"unknown\";\n}\n\nexport interface SectionControllerRuntimeState {\n\tsectionId: string;\n\tsectionIdentifier?: string;\n\tcurrentItemIndex: number;\n\tcurrentItemId: string;\n\titemIdentifiers: string[];\n\tvisitedItemIdentifiers: string[];\n\titemSessions: Record<string, unknown>;\n\tloadingComplete: boolean;\n\ttotalRegistered: number;\n\ttotalLoaded: number;\n\titemsComplete: boolean;\n\tcompletedCount: number;\n\ttotalItems: number;\n\t/**\n\t * Renderables (items, passages, rubrics) that have completed loading.\n\t *\n\t * Optional so synthetic test harnesses constructing a runtime state by\n\t * hand can omit it; production `SectionController.getRuntimeState` always\n\t * supplies it, which lets `ToolkitCoordinator` replay\n\t * `content-loaded` events to subscribers that attach after a renderable\n\t * has finished loading (e.g. cohort transitions in the assessment\n\t * runtime).\n\t *\n\t * Order is registration order, matching the order in which `content-loaded`\n\t * fires live; coordinator replay walks this list in-order so late\n\t * subscribers observe the same sequence a live subscriber would have seen.\n\t */\n\tloadedRenderables?: ReadonlyArray<SectionControllerLoadedRenderable>;\n}\n\nexport interface SectionControllerSessionState {\n\tcurrentItemIndex?: number;\n\tvisitedItemIdentifiers?: string[];\n\titemSessions: Record<string, unknown>;\n}\n\ntype SectionControllerEventBase = {\n\ttimestamp: number;\n};\n\nexport type SectionControllerItemSessionDataChangedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"item-session-data-changed\";\n\t\titemId: string;\n\t\tcanonicalItemId: string;\n\t\tsession: unknown;\n\t\tintent?: string;\n\t\tcomplete?: boolean;\n\t\tcomponent?: string;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerItemSessionMetaChangedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"item-session-meta-changed\";\n\t\titemId: string;\n\t\tcanonicalItemId: string;\n\t\tcomplete?: boolean;\n\t\tcomponent?: string;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerItemSelectedEvent = SectionControllerEventBase & {\n\ttype: \"item-selected\";\n\tpreviousItemId: string;\n\tcurrentItemId: string;\n\titemIndex: number;\n\ttotalItems: number;\n\tcurrentItemIndex: number;\n};\n\nexport type SectionControllerSectionNavigationChangedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"section-navigation-change\";\n\t\tpreviousSectionId?: string;\n\t\tcurrentSectionId?: string;\n\t\tattemptId?: string;\n\t\treason?: \"input-change\" | \"runtime-transition\";\n\t};\n\nexport type SectionControllerSectionSessionAppliedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"section-session-applied\";\n\t\tmode: \"replace\" | \"merge\";\n\t\titemSessionCount: number;\n\t\treplay: boolean;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerContentLoadedEvent = SectionControllerEventBase & {\n\ttype: \"content-loaded\";\n\tcontentKind: \"item\" | \"passage\" | \"rubric\" | \"unknown\";\n\titemId: string;\n\tcanonicalItemId: string;\n\tdetail?: unknown;\n\tcurrentItemIndex: number;\n};\n\nexport type SectionControllerItemPlayerErrorEvent = SectionControllerEventBase & {\n\ttype: \"item-player-error\";\n\tcontentKind: \"item\" | \"passage\" | \"rubric\" | \"unknown\";\n\titemId: string;\n\tcanonicalItemId: string;\n\terror: unknown;\n\tcurrentItemIndex: number;\n};\n\nexport type SectionControllerItemCompleteChangedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"item-complete-changed\";\n\t\titemId: string;\n\t\tcanonicalItemId: string;\n\t\tcomplete: boolean;\n\t\tpreviousComplete: boolean;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerSectionLoadingCompleteEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"section-loading-complete\";\n\t\ttotalRegistered: number;\n\t\ttotalLoaded: number;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerSectionItemsCompleteChangedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"section-items-complete-changed\";\n\t\tcomplete: boolean;\n\t\tcompletedCount: number;\n\t\ttotalItems: number;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerSectionErrorEvent = SectionControllerEventBase & {\n\ttype: \"section-error\";\n\tsource: \"item-player\" | \"section-runtime\" | \"toolkit\" | \"controller\";\n\terror: unknown;\n\titemId?: string;\n\tcanonicalItemId?: string;\n\tcontentKind?: \"item\" | \"passage\" | \"rubric\" | \"unknown\";\n\tcurrentItemIndex: number;\n};\n\nexport type SectionControllerEvent =\n\t| SectionControllerItemSessionDataChangedEvent\n\t| SectionControllerItemSessionMetaChangedEvent\n\t| SectionControllerItemSelectedEvent\n\t| SectionControllerSectionNavigationChangedEvent\n\t| SectionControllerSectionSessionAppliedEvent\n\t| SectionControllerContentLoadedEvent\n\t| SectionControllerItemPlayerErrorEvent\n\t| SectionControllerItemCompleteChangedEvent\n\t| SectionControllerSectionLoadingCompleteEvent\n\t| SectionControllerSectionItemsCompleteChangedEvent\n\t| SectionControllerSectionErrorEvent;\n\nexport type SectionControllerEventType = SectionControllerEvent[\"type\"];\n\n/**\n * Host-facing controller for a single section cohort.\n *\n * `SectionControllerHandle` is the primary API surface a host application\n * uses after the toolkit signals readiness (typically the `toolkit-ready`\n * DOM event followed by the first\n * `coordinator.getOrCreateSectionController(...)` resolve, or the convenience\n * `host.waitForSectionController(timeoutMs)` helper exposed by\n * `<pie-section-player*>`).\n *\n * The interface is the contract; the production implementation lives in\n * `packages/section-player/src/controllers/SectionController.ts`. Every\n * member is optional so the toolkit can call into older or partial\n * implementations defensively, but the production controller implements\n * all of them.\n *\n * Typical lifecycle for a host:\n *\n * ```ts\n * const controller = await host.waitForSectionController(5000);\n * controller?.configureSessionPersistence?.({ context, strategy });\n * await controller?.hydrate?.();\n * const unsubscribe = controller?.subscribe?.(handleEvent);\n * // ...later, on save / unload:\n * await controller?.persist?.();\n * unsubscribe?.();\n * ```\n */\nexport interface SectionControllerHandle {\n\t/**\n\t * Bootstrap the controller from composition input (section, view,\n\t * adapter item refs, etc.).\n\t *\n\t * Called by the section runtime when the section first mounts. Hosts\n\t * normally do not call this directly — the section player owns the\n\t * input shape and forwards it.\n\t */\n\tinitialize?(input?: unknown): void | Promise<void>;\n\t/**\n\t * Refresh composition input on a same-cohort change (PnP toggle,\n\t * prompt edit, accommodation flip, etc.) without resetting in-memory\n\t * session state.\n\t *\n\t * Treated as same-cohort when the section identity (`sectionId` /\n\t * `section.identifier`) is unchanged; cross-cohort changes are\n\t * handled by the coordinator creating a new controller instead.\n\t */\n\tupdateInput?(input?: unknown): void | Promise<void>;\n\t/**\n\t * Load and apply a previously persisted session via the strategy\n\t * registered through `configureSessionPersistence(...)`.\n\t *\n\t * No-op if no persistence strategy is configured or the strategy\n\t * returns no snapshot. Internally calls `applySession(snapshot,\n\t * { mode: \"replace\" })`.\n\t */\n\thydrate?(): void | Promise<void>;\n\t/**\n\t * Save the current session via the registered persistence strategy.\n\t *\n\t * Hosts call this on whatever cadence they choose (debounced on\n\t * change, on visibility change, on submit, etc.). No-op if no\n\t * strategy is configured.\n\t */\n\tpersist?(): void | Promise<void>;\n\t/**\n\t * Release listeners and lifecycle tracking. Called by the coordinator\n\t * when the controller's section cohort is being torn down. Hosts\n\t * usually do not call this directly.\n\t */\n\tdispose?(): void | Promise<void>;\n\t/**\n\t * Subscribe to the controller's typed event stream\n\t * (`SectionControllerEvent` discriminated union: `item-selected`,\n\t * `item-session-data-changed`, `content-loaded`,\n\t * `section-loading-complete`, `section-navigation-change`, etc.).\n\t *\n\t * Returns a disposer. The coordinator's\n\t * `subscribeSectionEvents` / `subscribeItemEvents` /\n\t * `subscribeSectionLifecycleEvents` helpers wrap this with\n\t * cohort-aware filtering and event-type defaults; hosts typically\n\t * use those instead of subscribing directly.\n\t */\n\tsubscribe?(listener: (event: SectionControllerEvent) => void): () => void;\n\t/**\n\t * Return a live snapshot of section-scoped runtime state — current\n\t * item, visited items, item sessions, loading + completion progress,\n\t * loaded renderables.\n\t *\n\t * Intended for runtime introspection (debug panels, diagnostics).\n\t * Use `getSession()` for the host-facing persistence shape.\n\t */\n\tgetRuntimeState?(): SectionControllerRuntimeState | null;\n\t/**\n\t * Return the host-facing persistence snapshot\n\t * (`SectionControllerSessionState`).\n\t *\n\t * This is the compact shape designed for serializing / restoring\n\t * across reloads — `currentItemIndex`, `visitedItemIdentifiers`, and\n\t * the item sessions map. The same shape is what\n\t * `SectionSessionPersistenceStrategy.saveSession` receives.\n\t */\n\tgetSession?(): SectionControllerSessionState | null;\n\t/**\n\t * Restore session state into the controller, replacing or merging\n\t * the in-memory state.\n\t *\n\t * - `mode: \"replace\"` (default for `hydrate()`): clear and apply.\n\t * - `mode: \"merge\"`: overlay onto existing state per item.\n\t *\n\t * Accepts the output of `getSession()` directly. Item sessions may\n\t * be canonical attempt entries or raw session payloads — the\n\t * controller normalizes both.\n\t */\n\tapplySession?(\n\t\tsession: SectionControllerSessionState | null,\n\t\toptions?: SectionControllerApplySessionOptions,\n\t): void | Promise<void>;\n\t/**\n\t * Apply a single item's session detail into the in-memory section\n\t * session, emitting the appropriate item-session event\n\t * (`item-session-data-changed` for response data,\n\t * `item-session-meta-changed` for metadata-only updates) so other\n\t * subscribers and the persistence strategy (on the next `persist()`)\n\t * see the update.\n\t *\n\t * Used for fine-grained host updates that should not require a full\n\t * `applySession(...)` round-trip.\n\t */\n\tupdateItemSession?(\n\t\titemId: string,\n\t\tsessionDetail: unknown,\n\t): unknown | Promise<unknown>;\n\t/**\n\t * Register the persistence context and strategy used by `hydrate()`\n\t * and `persist()`.\n\t *\n\t * Hosts typically call this once, immediately after obtaining the\n\t * handle, before invoking `hydrate()`. The same\n\t * `SectionControllerSessionState` shape returned by `getSession()`\n\t * is what the strategy load/save methods exchange.\n\t */\n\tconfigureSessionPersistence?(\n\t\tconfig: SectionSessionPersistenceConfig,\n\t): void | Promise<void>;\n}\n\nexport interface SectionControllerFactoryDefaults {\n\tcreateDefaultController: () =>\n\t\t| SectionControllerHandle\n\t\t| Promise<SectionControllerHandle>;\n}\n\nexport interface SectionPersistenceFactoryDefaults {\n\tcreateDefaultPersistence: () =>\n\t\t| SectionSessionPersistenceStrategy\n\t\t| Promise<SectionSessionPersistenceStrategy>;\n}\n"]}
1
+ {"version":3,"file":"section-controller-types.js","sourceRoot":"","sources":["../../src/services/section-controller-types.ts"],"names":[],"mappings":"","sourcesContent":["export interface SectionControllerKey {\n\tassessmentId: string;\n\tsectionId: string;\n\tattemptId?: string;\n}\n\nexport interface SectionControllerContext {\n\tkey: SectionControllerKey;\n\tcoordinator: unknown;\n\tinput?: unknown;\n}\n\nexport interface SectionSessionPersistenceStrategy {\n\tloadSession(\n\t\tcontext: SectionControllerContext,\n\t):\n\t\t| SectionControllerSessionState\n\t\t| null\n\t\t| Promise<SectionControllerSessionState | null>;\n\tsaveSession(\n\t\tcontext: SectionControllerContext,\n\t\tsession: SectionControllerSessionState | null,\n\t): void | Promise<void>;\n\tclearSession?(context: SectionControllerContext): void | Promise<void>;\n}\n\nexport interface SectionSessionPersistenceConfig {\n\tcontext: SectionControllerContext;\n\tstrategy: SectionSessionPersistenceStrategy;\n}\n\nexport interface SectionControllerApplySessionOptions {\n\t/**\n\t * applySession contract:\n\t * - Preferred input is the output of getSession().\n\t * - itemSessions may contain canonical attempt entries\n\t * ({ itemIdentifier, session, isCompleted }) or raw session payloads\n\t * ({ id, data, ... }); controller normalizes these before applying.\n\t */\n\tmode?: \"replace\" | \"merge\";\n}\n\nexport interface SectionControllerLoadedRenderable {\n\titemId: string;\n\tcanonicalItemId: string;\n\tcontentKind: \"item\" | \"passage\" | \"rubric\" | \"unknown\";\n}\n\nexport interface SectionControllerRuntimeState {\n\tsectionId: string;\n\tsectionIdentifier?: string;\n\tcurrentItemIndex: number;\n\tcurrentItemId: string;\n\titemIdentifiers: string[];\n\tvisitedItemIdentifiers: string[];\n\titemSessions: Record<string, unknown>;\n\tloadingComplete: boolean;\n\ttotalRegistered: number;\n\ttotalLoaded: number;\n\titemsComplete: boolean;\n\tcompletedCount: number;\n\ttotalItems: number;\n\t/**\n\t * Renderables (items, passages, rubrics) that have completed loading.\n\t *\n\t * Optional so synthetic test harnesses constructing a runtime state by\n\t * hand can omit it; production `SectionController.getRuntimeState` always\n\t * supplies it, which lets `ToolkitCoordinator` replay\n\t * `content-loaded` events to subscribers that attach after a renderable\n\t * has finished loading (e.g. cohort transitions in the assessment\n\t * runtime).\n\t *\n\t * Order is registration order, matching the order in which `content-loaded`\n\t * fires live; coordinator replay walks this list in-order so late\n\t * subscribers observe the same sequence a live subscriber would have seen.\n\t */\n\tloadedRenderables?: ReadonlyArray<SectionControllerLoadedRenderable>;\n}\n\nexport interface SectionControllerSessionState {\n\tcurrentItemIndex?: number;\n\tvisitedItemIdentifiers?: string[];\n\titemSessions: Record<string, unknown>;\n}\n\ntype SectionControllerEventBase = {\n\ttimestamp: number;\n};\n\nexport type SectionControllerItemSessionDataChangedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"item-session-data-changed\";\n\t\titemId: string;\n\t\tcanonicalItemId: string;\n\t\tsession: unknown;\n\t\tintent?: string;\n\t\tcomplete?: boolean;\n\t\tcomponent?: string;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerItemSessionMetaChangedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"item-session-meta-changed\";\n\t\titemId: string;\n\t\tcanonicalItemId: string;\n\t\tcomplete?: boolean;\n\t\tcomponent?: string;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerItemSelectedEvent = SectionControllerEventBase & {\n\ttype: \"item-selected\";\n\tpreviousItemId: string;\n\tcurrentItemId: string;\n\titemIndex: number;\n\ttotalItems: number;\n\tcurrentItemIndex: number;\n};\n\nexport type SectionControllerSectionNavigationChangedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"section-navigation-change\";\n\t\tpreviousSectionId?: string;\n\t\tcurrentSectionId?: string;\n\t\tattemptId?: string;\n\t\treason?: \"input-change\" | \"runtime-transition\";\n\t};\n\nexport type SectionControllerSectionSessionAppliedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"section-session-applied\";\n\t\tmode: \"replace\" | \"merge\";\n\t\titemSessionCount: number;\n\t\treplay: boolean;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerContentLoadedEvent = SectionControllerEventBase & {\n\ttype: \"content-loaded\";\n\tcontentKind: \"item\" | \"passage\" | \"rubric\" | \"unknown\";\n\titemId: string;\n\tcanonicalItemId: string;\n\tdetail?: unknown;\n\tcurrentItemIndex: number;\n};\n\nexport type SectionControllerItemPlayerErrorEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"item-player-error\";\n\t\tcontentKind: \"item\" | \"passage\" | \"rubric\" | \"unknown\";\n\t\titemId: string;\n\t\tcanonicalItemId: string;\n\t\terror: unknown;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerItemCompleteChangedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"item-complete-changed\";\n\t\titemId: string;\n\t\tcanonicalItemId: string;\n\t\tcomplete: boolean;\n\t\tpreviousComplete: boolean;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerSectionLoadingCompleteEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"section-loading-complete\";\n\t\ttotalRegistered: number;\n\t\ttotalLoaded: number;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerSectionItemsCompleteChangedEvent =\n\tSectionControllerEventBase & {\n\t\ttype: \"section-items-complete-changed\";\n\t\tcomplete: boolean;\n\t\tcompletedCount: number;\n\t\ttotalItems: number;\n\t\tcurrentItemIndex: number;\n\t};\n\nexport type SectionControllerSectionErrorEvent = SectionControllerEventBase & {\n\ttype: \"section-error\";\n\tsource: \"item-player\" | \"section-runtime\" | \"toolkit\" | \"controller\";\n\terror: unknown;\n\titemId?: string;\n\tcanonicalItemId?: string;\n\tcontentKind?: \"item\" | \"passage\" | \"rubric\" | \"unknown\";\n\tcurrentItemIndex: number;\n};\n\nexport type SectionControllerEvent =\n\t| SectionControllerItemSessionDataChangedEvent\n\t| SectionControllerItemSessionMetaChangedEvent\n\t| SectionControllerItemSelectedEvent\n\t| SectionControllerSectionNavigationChangedEvent\n\t| SectionControllerSectionSessionAppliedEvent\n\t| SectionControllerContentLoadedEvent\n\t| SectionControllerItemPlayerErrorEvent\n\t| SectionControllerItemCompleteChangedEvent\n\t| SectionControllerSectionLoadingCompleteEvent\n\t| SectionControllerSectionItemsCompleteChangedEvent\n\t| SectionControllerSectionErrorEvent;\n\nexport type SectionControllerEventType = SectionControllerEvent[\"type\"];\n\n/**\n * Host-facing controller for a single section cohort.\n *\n * `SectionControllerHandle` is the primary API surface a host application\n * uses after the toolkit signals readiness (typically the `toolkit-ready`\n * DOM event followed by the first\n * `coordinator.getOrCreateSectionController(...)` resolve, or the convenience\n * `host.waitForSectionController(timeoutMs)` helper exposed by\n * `<pie-section-player*>`).\n *\n * The interface is the contract; the production implementation lives in\n * `packages/section-player/src/controllers/SectionController.ts`. Every\n * member is optional so the toolkit can call into older or partial\n * implementations defensively, but the production controller implements\n * all of them.\n *\n * Typical lifecycle for a host:\n *\n * ```ts\n * const controller = await host.waitForSectionController(5000);\n * controller?.configureSessionPersistence?.({ context, strategy });\n * await controller?.hydrate?.();\n * const unsubscribe = controller?.subscribe?.(handleEvent);\n * // ...later, on save / unload:\n * await controller?.persist?.();\n * unsubscribe?.();\n * ```\n */\nexport interface SectionControllerHandle {\n\t/**\n\t * Bootstrap the controller from composition input (section, view,\n\t * adapter item refs, etc.).\n\t *\n\t * Called by the section runtime when the section first mounts. Hosts\n\t * normally do not call this directly — the section player owns the\n\t * input shape and forwards it.\n\t */\n\tinitialize?(input?: unknown): void | Promise<void>;\n\t/**\n\t * Refresh composition input on a same-cohort change (PnP toggle,\n\t * prompt edit, accommodation flip, etc.) without resetting in-memory\n\t * session state.\n\t *\n\t * Treated as same-cohort when the section identity (`sectionId` /\n\t * `section.identifier`) is unchanged; cross-cohort changes are\n\t * handled by the coordinator creating a new controller instead.\n\t */\n\tupdateInput?(input?: unknown): void | Promise<void>;\n\t/**\n\t * Load and apply a previously persisted session via the strategy\n\t * registered through `configureSessionPersistence(...)`.\n\t *\n\t * No-op if no persistence strategy is configured or the strategy\n\t * returns no snapshot. Internally calls `applySession(snapshot,\n\t * { mode: \"replace\" })`.\n\t */\n\thydrate?(): void | Promise<void>;\n\t/**\n\t * Save the current session via the registered persistence strategy.\n\t *\n\t * Hosts call this on whatever cadence they choose (debounced on\n\t * change, on visibility change, on submit, etc.). No-op if no\n\t * strategy is configured.\n\t */\n\tpersist?(): void | Promise<void>;\n\t/**\n\t * Release listeners and lifecycle tracking. Called by the coordinator\n\t * when the controller's section cohort is being torn down. Hosts\n\t * usually do not call this directly.\n\t */\n\tdispose?(): void | Promise<void>;\n\t/**\n\t * Subscribe to the controller's typed event stream\n\t * (`SectionControllerEvent` discriminated union: `item-selected`,\n\t * `item-session-data-changed`, `content-loaded`,\n\t * `section-loading-complete`, `section-navigation-change`, etc.).\n\t *\n\t * Returns a disposer. The coordinator's\n\t * `subscribeSectionEvents` / `subscribeItemEvents` /\n\t * `subscribeSectionLifecycleEvents` helpers wrap this with\n\t * cohort-aware filtering and event-type defaults; hosts typically\n\t * use those instead of subscribing directly.\n\t */\n\tsubscribe?(listener: (event: SectionControllerEvent) => void): () => void;\n\t/**\n\t * Return a live snapshot of section-scoped runtime state — current\n\t * item, visited items, item sessions, loading + completion progress,\n\t * loaded renderables.\n\t *\n\t * Intended for runtime introspection (debug panels, diagnostics).\n\t * Use `getSession()` for the host-facing persistence shape.\n\t */\n\tgetRuntimeState?(): SectionControllerRuntimeState | null;\n\t/**\n\t * Return the host-facing persistence snapshot\n\t * (`SectionControllerSessionState`).\n\t *\n\t * This is the compact shape designed for serializing / restoring\n\t * across reloads — `currentItemIndex`, `visitedItemIdentifiers`, and\n\t * the item sessions map. The same shape is what\n\t * `SectionSessionPersistenceStrategy.saveSession` receives.\n\t */\n\tgetSession?(): SectionControllerSessionState | null;\n\t/**\n\t * Restore session state into the controller, replacing or merging\n\t * the in-memory state.\n\t *\n\t * - `mode: \"replace\"` (default for `hydrate()`): clear and apply.\n\t * - `mode: \"merge\"`: overlay onto existing state per item.\n\t *\n\t * Accepts the output of `getSession()` directly. Item sessions may\n\t * be canonical attempt entries or raw session payloads — the\n\t * controller normalizes both.\n\t */\n\tapplySession?(\n\t\tsession: SectionControllerSessionState | null,\n\t\toptions?: SectionControllerApplySessionOptions,\n\t): void | Promise<void>;\n\t/**\n\t * Apply a single item's session detail into the in-memory section\n\t * session, emitting the appropriate item-session event\n\t * (`item-session-data-changed` for response data,\n\t * `item-session-meta-changed` for metadata-only updates) so other\n\t * subscribers and the persistence strategy (on the next `persist()`)\n\t * see the update.\n\t *\n\t * Used for fine-grained host updates that should not require a full\n\t * `applySession(...)` round-trip.\n\t */\n\tupdateItemSession?(\n\t\titemId: string,\n\t\tsessionDetail: unknown,\n\t): unknown | Promise<unknown>;\n\t/**\n\t * Register the persistence context and strategy used by `hydrate()`\n\t * and `persist()`.\n\t *\n\t * Hosts typically call this once, immediately after obtaining the\n\t * handle, before invoking `hydrate()`. The same\n\t * `SectionControllerSessionState` shape returned by `getSession()`\n\t * is what the strategy load/save methods exchange.\n\t */\n\tconfigureSessionPersistence?(\n\t\tconfig: SectionSessionPersistenceConfig,\n\t): void | Promise<void>;\n}\n\nexport interface SectionControllerFactoryDefaults {\n\tcreateDefaultController: () =>\n\t\t| SectionControllerHandle\n\t\t| Promise<SectionControllerHandle>;\n}\n\nexport interface SectionPersistenceFactoryDefaults {\n\tcreateDefaultPersistence: () =>\n\t\t| SectionSessionPersistenceStrategy\n\t\t| Promise<SectionSessionPersistenceStrategy>;\n}\n"]}
@@ -13,7 +13,13 @@ export const DEFAULT_TOOL_PLACEMENT = {
13
13
  export const PACKAGED_TOOL_PLACEMENT = {
14
14
  assessment: ["theme"],
15
15
  section: ["theme"],
16
- item: ["textToSpeech", "highlighter", "annotationToolbar", "graph", "periodicTable"],
16
+ item: [
17
+ "textToSpeech",
18
+ "highlighter",
19
+ "annotationToolbar",
20
+ "graph",
21
+ "periodicTable",
22
+ ],
17
23
  passage: ["textToSpeech", "highlighter", "annotationToolbar", "lineReader"],
18
24
  rubric: ["textToSpeech", "highlighter", "annotationToolbar", "lineReader"],
19
25
  element: [
@@ -1 +1 @@
1
- {"version":3,"file":"tool-config-defaults.js","sourceRoot":"","sources":["../../src/services/tool-config-defaults.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;CACF,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,UAAU,EAAE,CAAC,OAAO,CAAC;IACrB,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,IAAI,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,OAAO,EAAE,eAAe,CAAC;IACpF,OAAO,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,CAAC;IAC3E,MAAM,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,CAAC;IAC1E,OAAO,EAAE;QACR,YAAY;QACZ,kBAAkB;QAClB,cAAc;QACd,OAAO;QACP,YAAY;QACZ,aAAa;QACb,mBAAmB;QACnB,OAAO;QACP,eAAe;KACf;CACQ,CAAC","sourcesContent":["export const DEFAULT_TOOL_PLACEMENT = {\n\tassessment: [],\n\tsection: [],\n\titem: [],\n\tpassage: [],\n\trubric: [],\n\telement: [],\n} as const;\n\n/**\n * Complete placement preset for hosts that want to enable all packaged tools.\n * Prefer explicit host configuration over implicit defaults.\n */\nexport const PACKAGED_TOOL_PLACEMENT = {\n\tassessment: [\"theme\"],\n\tsection: [\"theme\"],\n\titem: [\"textToSpeech\", \"highlighter\", \"annotationToolbar\", \"graph\", \"periodicTable\"],\n\tpassage: [\"textToSpeech\", \"highlighter\", \"annotationToolbar\", \"lineReader\"],\n\trubric: [\"textToSpeech\", \"highlighter\", \"annotationToolbar\", \"lineReader\"],\n\telement: [\n\t\t\"calculator\",\n\t\t\"answerEliminator\",\n\t\t\"textToSpeech\",\n\t\t\"ruler\",\n\t\t\"protractor\",\n\t\t\"highlighter\",\n\t\t\"annotationToolbar\",\n\t\t\"graph\",\n\t\t\"periodicTable\",\n\t],\n} as const;\n"]}
1
+ {"version":3,"file":"tool-config-defaults.js","sourceRoot":"","sources":["../../src/services/tool-config-defaults.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;CACF,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,UAAU,EAAE,CAAC,OAAO,CAAC;IACrB,OAAO,EAAE,CAAC,OAAO,CAAC;IAClB,IAAI,EAAE;QACL,cAAc;QACd,aAAa;QACb,mBAAmB;QACnB,OAAO;QACP,eAAe;KACf;IACD,OAAO,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,CAAC;IAC3E,MAAM,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,CAAC;IAC1E,OAAO,EAAE;QACR,YAAY;QACZ,kBAAkB;QAClB,cAAc;QACd,OAAO;QACP,YAAY;QACZ,aAAa;QACb,mBAAmB;QACnB,OAAO;QACP,eAAe;KACf;CACQ,CAAC","sourcesContent":["export const DEFAULT_TOOL_PLACEMENT = {\n\tassessment: [],\n\tsection: [],\n\titem: [],\n\tpassage: [],\n\trubric: [],\n\telement: [],\n} as const;\n\n/**\n * Complete placement preset for hosts that want to enable all packaged tools.\n * Prefer explicit host configuration over implicit defaults.\n */\nexport const PACKAGED_TOOL_PLACEMENT = {\n\tassessment: [\"theme\"],\n\tsection: [\"theme\"],\n\titem: [\n\t\t\"textToSpeech\",\n\t\t\"highlighter\",\n\t\t\"annotationToolbar\",\n\t\t\"graph\",\n\t\t\"periodicTable\",\n\t],\n\tpassage: [\"textToSpeech\", \"highlighter\", \"annotationToolbar\", \"lineReader\"],\n\trubric: [\"textToSpeech\", \"highlighter\", \"annotationToolbar\", \"lineReader\"],\n\telement: [\n\t\t\"calculator\",\n\t\t\"answerEliminator\",\n\t\t\"textToSpeech\",\n\t\t\"ruler\",\n\t\t\"protractor\",\n\t\t\"highlighter\",\n\t\t\"annotationToolbar\",\n\t\t\"graph\",\n\t\t\"periodicTable\",\n\t],\n} as const;\n"]}
@@ -40,7 +40,9 @@ function sanitizeProviderConfig(providerId, providerConfig, tool, diagnostics) {
40
40
  return providerConfig;
41
41
  try {
42
42
  const sanitized = tool.provider.sanitizeConfig(providerConfig);
43
- if (!sanitized || typeof sanitized !== "object" || Array.isArray(sanitized)) {
43
+ if (!sanitized ||
44
+ typeof sanitized !== "object" ||
45
+ Array.isArray(sanitized)) {
44
46
  diagnostics.push(createDiagnostic({
45
47
  code: "tools.providerSanitizeFailed",
46
48
  severity: "error",
@@ -1 +1 @@
1
- {"version":3,"file":"tool-config-validation.js","sourceRoot":"","sources":["../../src/services/tool-config-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,GAKpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,uCAAuC,EACvC,yBAAyB,GAEzB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAiC5E,MAAM,UAAU,sCAAsC,CAAC,IAKtD;IACA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpE,OAAO,uCAAuC,CAAC;YAC9C,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,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CAAC;IAC3C,CAAC;IAED,OAAO;QACN,MAAM,EAAE,UAAU;QAClB,WAAW;KACX,CAAC;AACH,CAAC","sourcesContent":["import {\n\tnormalizeToolsConfig,\n\ttype CanonicalToolsConfig,\n\ttype ToolPlacementLevel,\n\ttype ToolProviderConfig,\n\ttype TextToSpeechToolProviderConfig,\n} from \"./tools-config-normalizer.js\";\nimport {\n\tframeworkErrorFromToolConfigDiagnostics,\n\tframeworkErrorFromUnknown,\n\ttype FrameworkErrorModel,\n} from \"./framework-error.js\";\nimport type { ToolRegistration, ToolRegistry } from \"./ToolRegistry.js\";\nimport { createPackagedToolRegistry } from \"./createDefaultToolRegistry.js\";\n\nexport type ToolConfigStrictness = \"off\" | \"warn\" | \"error\";\n\nexport type ToolConfigDiagnosticSeverity = \"warning\" | \"error\";\n\nexport interface ToolConfigDiagnostic {\n\tcode:\n\t\t| \"tools.unknownToolId\"\n\t\t| \"tools.unsupportedLevel\"\n\t\t| \"tools.unknownProviderKey\"\n\t\t| \"tools.removedProviderKey\"\n\t\t| \"tools.providerSanitizeFailed\"\n\t\t| \"tools.providerValidateFailed\"\n\t\t| \"tools.invalidProviderValidation\";\n\tseverity: ToolConfigDiagnosticSeverity;\n\tpath: string;\n\tmessage: string;\n\ttoolId?: string;\n\tproviderId?: string;\n}\n\nexport interface ToolConfigValidationOptions {\n\tstrictness?: ToolConfigStrictness;\n\tsource?: string;\n\ttoolRegistry?: ToolRegistry | null;\n}\n\nexport interface ToolConfigValidationResult {\n\tconfig: CanonicalToolsConfig;\n\tdiagnostics: ToolConfigDiagnostic[];\n}\n\nexport function frameworkErrorFromToolConfigValidation(args: {\n\tsource: string;\n\tdiagnostics?: ToolConfigDiagnostic[] | null;\n\terror?: unknown;\n\trecoverable?: boolean;\n}): FrameworkErrorModel {\n\tif (Array.isArray(args.diagnostics) && args.diagnostics.length > 0) {\n\t\treturn frameworkErrorFromToolConfigDiagnostics({\n\t\t\tsource: args.source,\n\t\t\tdiagnostics: args.diagnostics,\n\t\t\trecoverable: args.recoverable,\n\t\t});\n\t}\n\treturn frameworkErrorFromUnknown({\n\t\tkind: \"tool-config\",\n\t\tsource: args.source,\n\t\terror: args.error ?? new Error(\"Invalid tools config\"),\n\t\trecoverable: args.recoverable,\n\t});\n}\n\nconst DEFAULT_STRICTNESS: ToolConfigStrictness = \"error\";\n\nexport function normalizeToolConfigStrictness(\n\tvalue: unknown,\n): ToolConfigStrictness {\n\tif (value === \"off\" || value === \"warn\" || value === \"error\") {\n\t\treturn value;\n\t}\n\treturn DEFAULT_STRICTNESS;\n}\n\nfunction createDiagnostic(\n\tdiagnostic: ToolConfigDiagnostic,\n): ToolConfigDiagnostic {\n\treturn diagnostic;\n}\n\nfunction getRegistryToolMap(\n\ttoolRegistry: ToolRegistry | null | undefined,\n): Map<string, ToolRegistration> {\n\tif (!toolRegistry) return new Map();\n\treturn new Map(\n\t\ttoolRegistry\n\t\t\t.getAllTools()\n\t\t\t.slice()\n\t\t\t.sort((left, right) => left.toolId.localeCompare(right.toolId))\n\t\t\t.map((tool) => [tool.toolId, tool]),\n\t);\n}\n\nfunction sanitizeProviderConfig(\n\tproviderId: string,\n\tproviderConfig: ToolProviderConfig | TextToSpeechToolProviderConfig | undefined,\n\ttool: ToolRegistration | undefined,\n\tdiagnostics: ToolConfigDiagnostic[],\n): ToolProviderConfig | TextToSpeechToolProviderConfig | undefined {\n\tif (!providerConfig || !tool?.provider?.sanitizeConfig) return providerConfig;\n\ttry {\n\t\tconst sanitized = tool.provider.sanitizeConfig(\n\t\t\tproviderConfig as ToolProviderConfig,\n\t\t);\n\t\tif (!sanitized || typeof sanitized !== \"object\" || Array.isArray(sanitized)) {\n\t\t\tdiagnostics.push(\n\t\t\t\tcreateDiagnostic({\n\t\t\t\t\tcode: \"tools.providerSanitizeFailed\",\n\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\tpath: `providers.${providerId}`,\n\t\t\t\t\tmessage: `Provider sanitizer for \"${providerId}\" must return an object.`,\n\t\t\t\t\tproviderId,\n\t\t\t\t\ttoolId: providerId,\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn providerConfig;\n\t\t}\n\t\treturn sanitized as ToolProviderConfig | TextToSpeechToolProviderConfig;\n\t} catch (error) {\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.providerSanitizeFailed\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: `providers.${providerId}`,\n\t\t\t\tmessage: `Provider sanitizer failed for \"${providerId}\": ${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t}`,\n\t\t\t\tproviderId,\n\t\t\t\ttoolId: providerId,\n\t\t\t}),\n\t\t);\n\t\treturn providerConfig;\n\t}\n}\n\nfunction validateProviderConfig(\n\tproviderId: string,\n\tproviderConfig: ToolProviderConfig | TextToSpeechToolProviderConfig | undefined,\n\ttool: ToolRegistration | undefined,\n\tdiagnostics: ToolConfigDiagnostic[],\n): void {\n\tif (!providerConfig || !tool?.provider?.validateConfig) return;\n\ttry {\n\t\tconst providerDiagnostics = tool.provider.validateConfig(\n\t\t\tproviderConfig as ToolProviderConfig,\n\t\t);\n\t\tif (!Array.isArray(providerDiagnostics)) {\n\t\t\tdiagnostics.push(\n\t\t\t\tcreateDiagnostic({\n\t\t\t\t\tcode: \"tools.invalidProviderValidation\",\n\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\tpath: `providers.${providerId}`,\n\t\t\t\t\tmessage: `Provider validator for \"${providerId}\" must return an array.`,\n\t\t\t\t\tproviderId,\n\t\t\t\t\ttoolId: providerId,\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tfor (const diagnostic of providerDiagnostics) {\n\t\t\tdiagnostics.push({\n\t\t\t\t...diagnostic,\n\t\t\t\tpath: diagnostic.path || `providers.${providerId}`,\n\t\t\t\tproviderId: diagnostic.providerId || providerId,\n\t\t\t\ttoolId: diagnostic.toolId || providerId,\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.providerValidateFailed\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: `providers.${providerId}`,\n\t\t\t\tmessage: `Provider validator failed for \"${providerId}\": ${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t}`,\n\t\t\t\tproviderId,\n\t\t\t\ttoolId: providerId,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nfunction collectPlacementDiagnostics(\n\tconfig: CanonicalToolsConfig,\n\ttoolMap: Map<string, ToolRegistration>,\n\tdiagnostics: ToolConfigDiagnostic[],\n): void {\n\tif (toolMap.size === 0) return;\n\tconst levelOrder: ToolPlacementLevel[] = [\"section\", \"item\", \"passage\"];\n\tfor (const level of levelOrder) {\n\t\tfor (const toolId of config.placement[level]) {\n\t\t\tconst tool = toolMap.get(toolId);\n\t\t\tif (!tool) {\n\t\t\t\tdiagnostics.push(\n\t\t\t\t\tcreateDiagnostic({\n\t\t\t\t\t\tcode: \"tools.unknownToolId\",\n\t\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\t\tpath: `placement.${level}`,\n\t\t\t\t\t\tmessage: `Unknown tool id \"${toolId}\" in placement.${level}.`,\n\t\t\t\t\t\ttoolId,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst supportsLevel = tool.supportedLevels.includes(level);\n\t\t\t// Leniency policy: section-capable tools are tolerated in item placement.\n\t\t\t// This avoids strict failures for common host config patterns while still\n\t\t\t// enforcing upward-invalid placements (for example item-only -> section).\n\t\t\tconst allowSectionToolInItemPlacement =\n\t\t\t\tlevel === \"item\" && tool.supportedLevels.includes(\"section\");\n\t\t\tif (!supportsLevel && !allowSectionToolInItemPlacement) {\n\t\t\t\tdiagnostics.push(\n\t\t\t\t\tcreateDiagnostic({\n\t\t\t\t\t\tcode: \"tools.unsupportedLevel\",\n\t\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\t\tpath: `placement.${level}`,\n\t\t\t\t\t\tmessage: `Tool \"${toolId}\" does not support level \"${level}\".`,\n\t\t\t\t\t\ttoolId,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction collectPolicyDiagnostics(\n\tconfig: CanonicalToolsConfig,\n\ttoolMap: Map<string, ToolRegistration>,\n\tdiagnostics: ToolConfigDiagnostic[],\n): void {\n\tif (toolMap.size === 0) return;\n\tfor (const toolId of config.policy.allowed || []) {\n\t\tif (toolMap.has(toolId)) continue;\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.unknownToolId\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: \"policy.allowed\",\n\t\t\t\tmessage: `Unknown tool id \"${toolId}\" in policy.allowed.`,\n\t\t\t\ttoolId,\n\t\t\t}),\n\t\t);\n\t}\n\tfor (const toolId of config.policy.blocked || []) {\n\t\tif (toolMap.has(toolId)) continue;\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.unknownToolId\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: \"policy.blocked\",\n\t\t\t\tmessage: `Unknown tool id \"${toolId}\" in policy.blocked.`,\n\t\t\t\ttoolId,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nfunction collectProviderKeyDiagnostics(\n\tconfig: CanonicalToolsConfig,\n\ttoolMap: Map<string, ToolRegistration>,\n\thasRemovedTtsKey: boolean,\n\tdiagnostics: ToolConfigDiagnostic[],\n): void {\n\tif (hasRemovedTtsKey) {\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.removedProviderKey\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: \"providers.tts\",\n\t\t\t\tmessage:\n\t\t\t\t\t`Provider key \"tts\" is no longer supported. Use \"providers.textToSpeech\".`,\n\t\t\t\tproviderId: \"tts\",\n\t\t\t\ttoolId: \"textToSpeech\",\n\t\t\t}),\n\t\t);\n\t}\n\tfor (const providerId of Object.keys(config.providers).sort()) {\n\t\tif (toolMap.size === 0 || toolMap.has(providerId)) continue;\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.unknownProviderKey\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: `providers.${providerId}`,\n\t\t\t\tmessage: `Unknown provider key \"${providerId}\".`,\n\t\t\t\tproviderId,\n\t\t\t\ttoolId: providerId,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nfunction emitWarnings(\n\tdiagnostics: ToolConfigDiagnostic[],\n\tsource: string,\n): void {\n\tif (diagnostics.length === 0) return;\n\tfor (const diagnostic of diagnostics) {\n\t\tconst prefix = `[tool-config-validation:${source}]`;\n\t\tconsole.warn(`${prefix} ${diagnostic.path} - ${diagnostic.message}`);\n\t}\n}\n\nfunction throwValidationError(\n\tdiagnostics: ToolConfigDiagnostic[],\n\tsource: string,\n): never {\n\tconst formatted = diagnostics\n\t\t.map((diagnostic) => `- ${diagnostic.path}: ${diagnostic.message}`)\n\t\t.join(\"\\n\");\n\tthrow new Error(`[tool-config-validation:${source}] Invalid tools config:\\n${formatted}`);\n}\n\nexport function normalizeAndValidateToolsConfig(\n\tinput?: Partial<CanonicalToolsConfig> | null,\n\toptions: ToolConfigValidationOptions = {},\n): ToolConfigValidationResult {\n\tconst strictness = normalizeToolConfigStrictness(options.strictness);\n\tconst source = options.source ?? \"tools\";\n\tconst registryTools = getRegistryToolMap(\n\t\toptions.toolRegistry ?? createPackagedToolRegistry(),\n\t);\n\tconst normalized = normalizeToolsConfig(input);\n\tconst diagnostics: ToolConfigDiagnostic[] = [];\n\tconst hasRemovedTtsKey = Object.hasOwn(\n\t\tnormalized.providers,\n\t\t\"tts\",\n\t);\n\n\tconst nextProviders: CanonicalToolsConfig[\"providers\"] = {\n\t\t...(normalized.providers || {}),\n\t};\n\tfor (const providerId of Object.keys(nextProviders).sort()) {\n\t\tif (providerId === \"tts\") {\n\t\t\tdelete nextProviders.tts;\n\t\t\tcontinue;\n\t\t}\n\t\tconst tool = registryTools.get(providerId);\n\t\tnextProviders[providerId] = sanitizeProviderConfig(\n\t\t\tproviderId,\n\t\t\tnextProviders[providerId],\n\t\t\ttool,\n\t\t\tdiagnostics,\n\t\t);\n\t\tvalidateProviderConfig(providerId, nextProviders[providerId], tool, diagnostics);\n\t}\n\tconst nextConfig: CanonicalToolsConfig = {\n\t\t...normalized,\n\t\tproviders: nextProviders,\n\t};\n\n\tcollectPlacementDiagnostics(nextConfig, registryTools, diagnostics);\n\tcollectPolicyDiagnostics(nextConfig, registryTools, diagnostics);\n\tcollectProviderKeyDiagnostics(\n\t\tnextConfig,\n\t\tregistryTools,\n\t\thasRemovedTtsKey,\n\t\tdiagnostics,\n\t);\n\tif (hasRemovedTtsKey) {\n\t\tthrowValidationError(\n\t\t\tdiagnostics.filter(\n\t\t\t\t(entry) => entry.code === \"tools.removedProviderKey\",\n\t\t\t),\n\t\t\tsource,\n\t\t);\n\t}\n\n\tif (strictness === \"warn\") {\n\t\temitWarnings(diagnostics, source);\n\t}\n\tif (strictness === \"error\" && diagnostics.length > 0) {\n\t\tthrowValidationError(diagnostics, source);\n\t}\n\n\treturn {\n\t\tconfig: nextConfig,\n\t\tdiagnostics,\n\t};\n}\n"]}
1
+ {"version":3,"file":"tool-config-validation.js","sourceRoot":"","sources":["../../src/services/tool-config-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,GAKpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,uCAAuC,EACvC,yBAAyB,GAEzB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAiC5E,MAAM,UAAU,sCAAsC,CAAC,IAKtD;IACA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,WAA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AO,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtD,oBAAoB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO;QACN,MAAM,EAAE,UAAU;QAClB,WAAW;KACX,CAAC;AACH,CAAC","sourcesContent":["import {\n\tnormalizeToolsConfig,\n\ttype CanonicalToolsConfig,\n\ttype ToolPlacementLevel,\n\ttype ToolProviderConfig,\n\ttype TextToSpeechToolProviderConfig,\n} from \"./tools-config-normalizer.js\";\nimport {\n\tframeworkErrorFromToolConfigDiagnostics,\n\tframeworkErrorFromUnknown,\n\ttype FrameworkErrorModel,\n} from \"./framework-error.js\";\nimport type { ToolRegistration, ToolRegistry } from \"./ToolRegistry.js\";\nimport { createPackagedToolRegistry } from \"./createDefaultToolRegistry.js\";\n\nexport type ToolConfigStrictness = \"off\" | \"warn\" | \"error\";\n\nexport type ToolConfigDiagnosticSeverity = \"warning\" | \"error\";\n\nexport interface ToolConfigDiagnostic {\n\tcode:\n\t\t| \"tools.unknownToolId\"\n\t\t| \"tools.unsupportedLevel\"\n\t\t| \"tools.unknownProviderKey\"\n\t\t| \"tools.removedProviderKey\"\n\t\t| \"tools.providerSanitizeFailed\"\n\t\t| \"tools.providerValidateFailed\"\n\t\t| \"tools.invalidProviderValidation\";\n\tseverity: ToolConfigDiagnosticSeverity;\n\tpath: string;\n\tmessage: string;\n\ttoolId?: string;\n\tproviderId?: string;\n}\n\nexport interface ToolConfigValidationOptions {\n\tstrictness?: ToolConfigStrictness;\n\tsource?: string;\n\ttoolRegistry?: ToolRegistry | null;\n}\n\nexport interface ToolConfigValidationResult {\n\tconfig: CanonicalToolsConfig;\n\tdiagnostics: ToolConfigDiagnostic[];\n}\n\nexport function frameworkErrorFromToolConfigValidation(args: {\n\tsource: string;\n\tdiagnostics?: ToolConfigDiagnostic[] | null;\n\terror?: unknown;\n\trecoverable?: boolean;\n}): FrameworkErrorModel {\n\tif (Array.isArray(args.diagnostics) && args.diagnostics.length > 0) {\n\t\treturn frameworkErrorFromToolConfigDiagnostics({\n\t\t\tsource: args.source,\n\t\t\tdiagnostics: args.diagnostics,\n\t\t\trecoverable: args.recoverable,\n\t\t});\n\t}\n\treturn frameworkErrorFromUnknown({\n\t\tkind: \"tool-config\",\n\t\tsource: args.source,\n\t\terror: args.error ?? new Error(\"Invalid tools config\"),\n\t\trecoverable: args.recoverable,\n\t});\n}\n\nconst DEFAULT_STRICTNESS: ToolConfigStrictness = \"error\";\n\nexport function normalizeToolConfigStrictness(\n\tvalue: unknown,\n): ToolConfigStrictness {\n\tif (value === \"off\" || value === \"warn\" || value === \"error\") {\n\t\treturn value;\n\t}\n\treturn DEFAULT_STRICTNESS;\n}\n\nfunction createDiagnostic(\n\tdiagnostic: ToolConfigDiagnostic,\n): ToolConfigDiagnostic {\n\treturn diagnostic;\n}\n\nfunction getRegistryToolMap(\n\ttoolRegistry: ToolRegistry | null | undefined,\n): Map<string, ToolRegistration> {\n\tif (!toolRegistry) return new Map();\n\treturn new Map(\n\t\ttoolRegistry\n\t\t\t.getAllTools()\n\t\t\t.slice()\n\t\t\t.sort((left, right) => left.toolId.localeCompare(right.toolId))\n\t\t\t.map((tool) => [tool.toolId, tool]),\n\t);\n}\n\nfunction sanitizeProviderConfig(\n\tproviderId: string,\n\tproviderConfig:\n\t\t| ToolProviderConfig\n\t\t| TextToSpeechToolProviderConfig\n\t\t| undefined,\n\ttool: ToolRegistration | undefined,\n\tdiagnostics: ToolConfigDiagnostic[],\n): ToolProviderConfig | TextToSpeechToolProviderConfig | undefined {\n\tif (!providerConfig || !tool?.provider?.sanitizeConfig) return providerConfig;\n\ttry {\n\t\tconst sanitized = tool.provider.sanitizeConfig(\n\t\t\tproviderConfig as ToolProviderConfig,\n\t\t);\n\t\tif (\n\t\t\t!sanitized ||\n\t\t\ttypeof sanitized !== \"object\" ||\n\t\t\tArray.isArray(sanitized)\n\t\t) {\n\t\t\tdiagnostics.push(\n\t\t\t\tcreateDiagnostic({\n\t\t\t\t\tcode: \"tools.providerSanitizeFailed\",\n\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\tpath: `providers.${providerId}`,\n\t\t\t\t\tmessage: `Provider sanitizer for \"${providerId}\" must return an object.`,\n\t\t\t\t\tproviderId,\n\t\t\t\t\ttoolId: providerId,\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn providerConfig;\n\t\t}\n\t\treturn sanitized as ToolProviderConfig | TextToSpeechToolProviderConfig;\n\t} catch (error) {\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.providerSanitizeFailed\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: `providers.${providerId}`,\n\t\t\t\tmessage: `Provider sanitizer failed for \"${providerId}\": ${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t}`,\n\t\t\t\tproviderId,\n\t\t\t\ttoolId: providerId,\n\t\t\t}),\n\t\t);\n\t\treturn providerConfig;\n\t}\n}\n\nfunction validateProviderConfig(\n\tproviderId: string,\n\tproviderConfig:\n\t\t| ToolProviderConfig\n\t\t| TextToSpeechToolProviderConfig\n\t\t| undefined,\n\ttool: ToolRegistration | undefined,\n\tdiagnostics: ToolConfigDiagnostic[],\n): void {\n\tif (!providerConfig || !tool?.provider?.validateConfig) return;\n\ttry {\n\t\tconst providerDiagnostics = tool.provider.validateConfig(\n\t\t\tproviderConfig as ToolProviderConfig,\n\t\t);\n\t\tif (!Array.isArray(providerDiagnostics)) {\n\t\t\tdiagnostics.push(\n\t\t\t\tcreateDiagnostic({\n\t\t\t\t\tcode: \"tools.invalidProviderValidation\",\n\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\tpath: `providers.${providerId}`,\n\t\t\t\t\tmessage: `Provider validator for \"${providerId}\" must return an array.`,\n\t\t\t\t\tproviderId,\n\t\t\t\t\ttoolId: providerId,\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tfor (const diagnostic of providerDiagnostics) {\n\t\t\tdiagnostics.push({\n\t\t\t\t...diagnostic,\n\t\t\t\tpath: diagnostic.path || `providers.${providerId}`,\n\t\t\t\tproviderId: diagnostic.providerId || providerId,\n\t\t\t\ttoolId: diagnostic.toolId || providerId,\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.providerValidateFailed\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: `providers.${providerId}`,\n\t\t\t\tmessage: `Provider validator failed for \"${providerId}\": ${\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t}`,\n\t\t\t\tproviderId,\n\t\t\t\ttoolId: providerId,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nfunction collectPlacementDiagnostics(\n\tconfig: CanonicalToolsConfig,\n\ttoolMap: Map<string, ToolRegistration>,\n\tdiagnostics: ToolConfigDiagnostic[],\n): void {\n\tif (toolMap.size === 0) return;\n\tconst levelOrder: ToolPlacementLevel[] = [\"section\", \"item\", \"passage\"];\n\tfor (const level of levelOrder) {\n\t\tfor (const toolId of config.placement[level]) {\n\t\t\tconst tool = toolMap.get(toolId);\n\t\t\tif (!tool) {\n\t\t\t\tdiagnostics.push(\n\t\t\t\t\tcreateDiagnostic({\n\t\t\t\t\t\tcode: \"tools.unknownToolId\",\n\t\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\t\tpath: `placement.${level}`,\n\t\t\t\t\t\tmessage: `Unknown tool id \"${toolId}\" in placement.${level}.`,\n\t\t\t\t\t\ttoolId,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst supportsLevel = tool.supportedLevels.includes(level);\n\t\t\t// Leniency policy: section-capable tools are tolerated in item placement.\n\t\t\t// This avoids strict failures for common host config patterns while still\n\t\t\t// enforcing upward-invalid placements (for example item-only -> section).\n\t\t\tconst allowSectionToolInItemPlacement =\n\t\t\t\tlevel === \"item\" && tool.supportedLevels.includes(\"section\");\n\t\t\tif (!supportsLevel && !allowSectionToolInItemPlacement) {\n\t\t\t\tdiagnostics.push(\n\t\t\t\t\tcreateDiagnostic({\n\t\t\t\t\t\tcode: \"tools.unsupportedLevel\",\n\t\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\t\tpath: `placement.${level}`,\n\t\t\t\t\t\tmessage: `Tool \"${toolId}\" does not support level \"${level}\".`,\n\t\t\t\t\t\ttoolId,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction collectPolicyDiagnostics(\n\tconfig: CanonicalToolsConfig,\n\ttoolMap: Map<string, ToolRegistration>,\n\tdiagnostics: ToolConfigDiagnostic[],\n): void {\n\tif (toolMap.size === 0) return;\n\tfor (const toolId of config.policy.allowed || []) {\n\t\tif (toolMap.has(toolId)) continue;\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.unknownToolId\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: \"policy.allowed\",\n\t\t\t\tmessage: `Unknown tool id \"${toolId}\" in policy.allowed.`,\n\t\t\t\ttoolId,\n\t\t\t}),\n\t\t);\n\t}\n\tfor (const toolId of config.policy.blocked || []) {\n\t\tif (toolMap.has(toolId)) continue;\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.unknownToolId\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: \"policy.blocked\",\n\t\t\t\tmessage: `Unknown tool id \"${toolId}\" in policy.blocked.`,\n\t\t\t\ttoolId,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nfunction collectProviderKeyDiagnostics(\n\tconfig: CanonicalToolsConfig,\n\ttoolMap: Map<string, ToolRegistration>,\n\thasRemovedTtsKey: boolean,\n\tdiagnostics: ToolConfigDiagnostic[],\n): void {\n\tif (hasRemovedTtsKey) {\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.removedProviderKey\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: \"providers.tts\",\n\t\t\t\tmessage: `Provider key \"tts\" is no longer supported. Use \"providers.textToSpeech\".`,\n\t\t\t\tproviderId: \"tts\",\n\t\t\t\ttoolId: \"textToSpeech\",\n\t\t\t}),\n\t\t);\n\t}\n\tfor (const providerId of Object.keys(config.providers).sort()) {\n\t\tif (toolMap.size === 0 || toolMap.has(providerId)) continue;\n\t\tdiagnostics.push(\n\t\t\tcreateDiagnostic({\n\t\t\t\tcode: \"tools.unknownProviderKey\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tpath: `providers.${providerId}`,\n\t\t\t\tmessage: `Unknown provider key \"${providerId}\".`,\n\t\t\t\tproviderId,\n\t\t\t\ttoolId: providerId,\n\t\t\t}),\n\t\t);\n\t}\n}\n\nfunction emitWarnings(\n\tdiagnostics: ToolConfigDiagnostic[],\n\tsource: string,\n): void {\n\tif (diagnostics.length === 0) return;\n\tfor (const diagnostic of diagnostics) {\n\t\tconst prefix = `[tool-config-validation:${source}]`;\n\t\tconsole.warn(`${prefix} ${diagnostic.path} - ${diagnostic.message}`);\n\t}\n}\n\nfunction throwValidationError(\n\tdiagnostics: ToolConfigDiagnostic[],\n\tsource: string,\n): never {\n\tconst formatted = diagnostics\n\t\t.map((diagnostic) => `- ${diagnostic.path}: ${diagnostic.message}`)\n\t\t.join(\"\\n\");\n\tthrow new Error(\n\t\t`[tool-config-validation:${source}] Invalid tools config:\\n${formatted}`,\n\t);\n}\n\nexport function normalizeAndValidateToolsConfig(\n\tinput?: Partial<CanonicalToolsConfig> | null,\n\toptions: ToolConfigValidationOptions = {},\n): ToolConfigValidationResult {\n\tconst strictness = normalizeToolConfigStrictness(options.strictness);\n\tconst source = options.source ?? \"tools\";\n\tconst registryTools = getRegistryToolMap(\n\t\toptions.toolRegistry ?? createPackagedToolRegistry(),\n\t);\n\tconst normalized = normalizeToolsConfig(input);\n\tconst diagnostics: ToolConfigDiagnostic[] = [];\n\tconst hasRemovedTtsKey = Object.hasOwn(normalized.providers, \"tts\");\n\n\tconst nextProviders: CanonicalToolsConfig[\"providers\"] = {\n\t\t...(normalized.providers || {}),\n\t};\n\tfor (const providerId of Object.keys(nextProviders).sort()) {\n\t\tif (providerId === \"tts\") {\n\t\t\tdelete nextProviders.tts;\n\t\t\tcontinue;\n\t\t}\n\t\tconst tool = registryTools.get(providerId);\n\t\tnextProviders[providerId] = sanitizeProviderConfig(\n\t\t\tproviderId,\n\t\t\tnextProviders[providerId],\n\t\t\ttool,\n\t\t\tdiagnostics,\n\t\t);\n\t\tvalidateProviderConfig(\n\t\t\tproviderId,\n\t\t\tnextProviders[providerId],\n\t\t\ttool,\n\t\t\tdiagnostics,\n\t\t);\n\t}\n\tconst nextConfig: CanonicalToolsConfig = {\n\t\t...normalized,\n\t\tproviders: nextProviders,\n\t};\n\n\tcollectPlacementDiagnostics(nextConfig, registryTools, diagnostics);\n\tcollectPolicyDiagnostics(nextConfig, registryTools, diagnostics);\n\tcollectProviderKeyDiagnostics(\n\t\tnextConfig,\n\t\tregistryTools,\n\t\thasRemovedTtsKey,\n\t\tdiagnostics,\n\t);\n\tif (hasRemovedTtsKey) {\n\t\tthrowValidationError(\n\t\t\tdiagnostics.filter((entry) => entry.code === \"tools.removedProviderKey\"),\n\t\t\tsource,\n\t\t);\n\t}\n\n\tif (strictness === \"warn\") {\n\t\temitWarnings(diagnostics, source);\n\t}\n\tif (strictness === \"error\" && diagnostics.length > 0) {\n\t\tthrowValidationError(diagnostics, source);\n\t}\n\n\treturn {\n\t\tconfig: nextConfig,\n\t\tdiagnostics,\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tool-instance-id.js","sourceRoot":"","sources":["../../src/services/tool-instance-id.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,YAAY;IACZ,SAAS;IACT,MAAM;IACN,SAAS;IACT,QAAQ;CAC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AAM,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;IACnD,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IACzC,IAAI,CAAC,0BAA0B,CAAC,aAAa,CAAC,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO;QACN,UAAU;QACV,UAAU,EAAE,aAAa;QACzB,OAAO;KACP,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAU;IACzC,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACrC,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO,kBAAkB,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;AACjF,CAAC","sourcesContent":["export const DEFAULT_TOOL_SCOPE_LEVELS = [\n\t\"assessment\",\n\t\"section\",\n\t\"item\",\n\t\"passage\",\n\t\"rubric\",\n] as const;\n\nexport type BuiltinToolScopeLevel = (typeof DEFAULT_TOOL_SCOPE_LEVELS)[number];\nexport type ToolScopeLevel = BuiltinToolScopeLevel | (string & {});\n\nexport interface ParsedToolInstanceId {\n\tbaseToolId: string;\n\tscopeLevel: ToolScopeLevel;\n\tscopeId: string;\n}\n\nconst registeredToolScopeLevels = new Set<string>(DEFAULT_TOOL_SCOPE_LEVELS);\n\nexport function getRegisteredToolScopeLevels(): string[] {\n\treturn Array.from(registeredToolScopeLevels.values());\n}\n\nexport function registerToolScopeLevel(scopeLevel: string): void {\n\tconst normalized = scopeLevel.trim();\n\tif (!normalized) {\n\t\tthrow new Error(\"Tool scope level must be a non-empty string\");\n\t}\n\tregisteredToolScopeLevels.add(normalized);\n}\n\nexport function isRegisteredToolScopeLevel(\n\tscopeLevel: string,\n): scopeLevel is ToolScopeLevel {\n\treturn registeredToolScopeLevels.has(scopeLevel);\n}\n\nexport function createScopedToolId(\n\tbaseToolId: string,\n\tscopeLevel: ToolScopeLevel,\n\tscopeId: string,\n): string {\n\tconst normalizedBase = baseToolId.trim();\n\tconst normalizedScopeId = scopeId.trim();\n\tif (!normalizedBase || !normalizedScopeId) {\n\t\tthrow new Error(\"Tool instance ids require non-empty tool and scope ids\");\n\t}\n\tif (!isRegisteredToolScopeLevel(scopeLevel)) {\n\t\tthrow new Error(\n\t\t\t`Unknown tool scope level '${scopeLevel}'. Register custom levels with registerToolScopeLevel().`,\n\t\t);\n\t}\n\treturn `${normalizedBase}:${scopeLevel}:${normalizedScopeId}`;\n}\n\nexport function parseScopedToolId(id: string): ParsedToolInstanceId | null {\n\tconst parts = id.split(\":\");\n\tif (parts.length !== 3) return null;\n\tconst [baseToolId, scopeLevelRaw, scopeId] = parts;\n\tif (!baseToolId || !scopeId) return null;\n\tif (!isRegisteredToolScopeLevel(scopeLevelRaw)) {\n\t\treturn null;\n\t}\n\treturn {\n\t\tbaseToolId,\n\t\tscopeLevel: scopeLevelRaw,\n\t\tscopeId,\n\t};\n}\n\nexport function toOverlayToolId(id: string): string {\n\tconst parsed = parseScopedToolId(id);\n\tif (!parsed) return id;\n\treturn createScopedToolId(parsed.baseToolId, parsed.scopeLevel, parsed.scopeId);\n}\n"]}
1
+ {"version":3,"file":"tool-instance-id.js","sourceRoot":"","sources":["../../src/services/tool-instance-id.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,YAAY;IACZ,SAAS;IACT,MAAM;IACN,SAAS;IACT,QAAQ;CACC,CAAC;AAWX,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAS,yBAAyB,CAAC,CAAC;AAE7E,MAAM,UAAU,4BAA4B;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,MAAM,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,UAAkB;IACxD,MAAM,UAAU,GAAG,UAAU,C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E,aAAa;QACzB,OAAO;KACP,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAU;IACzC,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACrC,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO,kBAAkB,CACxB,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,OAAO,CACd,CAAC;AACH,CAAC","sourcesContent":["export const DEFAULT_TOOL_SCOPE_LEVELS = [\n\t\"assessment\",\n\t\"section\",\n\t\"item\",\n\t\"passage\",\n\t\"rubric\",\n] as const;\n\nexport type BuiltinToolScopeLevel = (typeof DEFAULT_TOOL_SCOPE_LEVELS)[number];\nexport type ToolScopeLevel = BuiltinToolScopeLevel | (string & {});\n\nexport interface ParsedToolInstanceId {\n\tbaseToolId: string;\n\tscopeLevel: ToolScopeLevel;\n\tscopeId: string;\n}\n\nconst registeredToolScopeLevels = new Set<string>(DEFAULT_TOOL_SCOPE_LEVELS);\n\nexport function getRegisteredToolScopeLevels(): string[] {\n\treturn Array.from(registeredToolScopeLevels.values());\n}\n\nexport function registerToolScopeLevel(scopeLevel: string): void {\n\tconst normalized = scopeLevel.trim();\n\tif (!normalized) {\n\t\tthrow new Error(\"Tool scope level must be a non-empty string\");\n\t}\n\tregisteredToolScopeLevels.add(normalized);\n}\n\nexport function isRegisteredToolScopeLevel(\n\tscopeLevel: string,\n): scopeLevel is ToolScopeLevel {\n\treturn registeredToolScopeLevels.has(scopeLevel);\n}\n\nexport function createScopedToolId(\n\tbaseToolId: string,\n\tscopeLevel: ToolScopeLevel,\n\tscopeId: string,\n): string {\n\tconst normalizedBase = baseToolId.trim();\n\tconst normalizedScopeId = scopeId.trim();\n\tif (!normalizedBase || !normalizedScopeId) {\n\t\tthrow new Error(\"Tool instance ids require non-empty tool and scope ids\");\n\t}\n\tif (!isRegisteredToolScopeLevel(scopeLevel)) {\n\t\tthrow new Error(\n\t\t\t`Unknown tool scope level '${scopeLevel}'. Register custom levels with registerToolScopeLevel().`,\n\t\t);\n\t}\n\treturn `${normalizedBase}:${scopeLevel}:${normalizedScopeId}`;\n}\n\nexport function parseScopedToolId(id: string): ParsedToolInstanceId | null {\n\tconst parts = id.split(\":\");\n\tif (parts.length !== 3) return null;\n\tconst [baseToolId, scopeLevelRaw, scopeId] = parts;\n\tif (!baseToolId || !scopeId) return null;\n\tif (!isRegisteredToolScopeLevel(scopeLevelRaw)) {\n\t\treturn null;\n\t}\n\treturn {\n\t\tbaseToolId,\n\t\tscopeLevel: scopeLevelRaw,\n\t\tscopeId,\n\t};\n}\n\nexport function toOverlayToolId(id: string): string {\n\tconst parsed = parseScopedToolId(id);\n\tif (!parsed) return id;\n\treturn createScopedToolId(\n\t\tparsed.baseToolId,\n\t\tparsed.scopeLevel,\n\t\tparsed.scopeId,\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DesmosToolProvider.js","sourceRoot":"","sources":["../../../src/services/tool-providers/DesmosToolProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA2CH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,kBAAkB;IAGrB,UAAU,GAAG,mBAAmB,CAAC;IACjC,YAAY,GAAG,mBAAmB,CAAC;IACnC,QAAQ,GAAG,YAAqB,CAAC;IACjC,OAAO,GAAG,MAAM,CAAC;IACjB,YAAY,GAAG,IAAI,CAAC;IAErB,cAAc,GAWZ,IAAI,CAAC;IACP,MAAM,GAAoC,IAAI,CAAC;IAE/C,KAAK,CAAC,aAAa,CAC1B,SAAiB,EACjB,OAAiC;QAEjC,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,iDAAiD,EAAE,KAAK,CAAC,CAAC;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KAAK,IAAI,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,OAAO;QACN,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;YAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC/C,CAAC;CACD","sourcesContent":["/**\n * Desmos Calculator Tool Provider\n *\n * Provides Desmos calculators (basic, scientific, graphing)\n * with authentication and proxy support.\n *\n * SECURITY BEST PRACTICE:\n * - Development: Pass apiKey directly for local testing\n * - Production: Use proxyEndpoint or authFetcher to keep API key server-side\n *\n * Part of PIE Assessment Toolkit.\n */\n\nimport type {\n\tCalculatorProvider,\n\tDesmosCalculatorConfig,\n} from \"@pie-players/pie-calculator\";\nimport type { ToolProviderApi, ToolProviderCapabilities } from \"./ToolProviderApi.js\";\n\n/**\n * Desmos tool provider configuration\n */\nexport interface DesmosToolProviderConfig {\n\t/**\n\t * Desmos API key (DEVELOPMENT ONLY)\n\t * Never expose in production client code!\n\t *\n\t * Obtain from: https://www.desmos.com/api\n\t */\n\tapiKey?: string;\n\n\t/**\n\t * Server proxy endpoint (PRODUCTION RECOMMENDED)\n\t * Backend handles API key securely\n\t *\n\t * @example '/api/desmos/token'\n\t * @example 'https://api.myapp.com/tools/desmos/auth'\n\t */\n\tproxyEndpoint?: string;\n\n\t/**\n\t * Default calculator configuration applied to all instances\n\t */\n\tdefaultConfig?: DesmosCalculatorConfig;\n\n\t/**\n\t * Optional telemetry callback for tool/backend instrumentation.\n\t */\n\tonTelemetry?: (\n\t\teventName: string,\n\t\tpayload?: Record<string, unknown>,\n\t) => void | Promise<void>;\n}\n\n/**\n * Desmos Calculator Tool Provider\n *\n * Wraps DesmosCalculatorProvider with the ToolProviderApi interface\n * for use in the ToolProviderRegistry.\n *\n * @example\n * ```typescript\n * const provider = new DesmosToolProvider();\n *\n * await provider.initialize({\n * apiKey: 'your-api-key', // Development only\n * proxyEndpoint: '/api/desmos/token', // Production\n * });\n *\n * const calculatorProvider = await provider.createInstance();\n * ```\n */\nexport class DesmosToolProvider\n\timplements ToolProviderApi<DesmosToolProviderConfig, CalculatorProvider>\n{\n\treadonly providerId = \"desmos-calculator\";\n\treadonly providerName = \"Desmos Calculator\";\n\treadonly category = \"calculator\" as const;\n\treadonly version = \"1.10\";\n\treadonly requiresAuth = true;\n\n\tprivate desmosProvider:\n\t\t| (CalculatorProvider & {\n\t\t\t\tinitialize(config: {\n\t\t\t\t\tapiKey?: string;\n\t\t\t\t\tproxyEndpoint?: string;\n\t\t\t\t\tonTelemetry?: (\n\t\t\t\t\t\teventName: string,\n\t\t\t\t\t\tpayload?: Record<string, unknown>,\n\t\t\t\t\t) => void | Promise<void>;\n\t\t\t\t}): Promise<void>;\n\t\t })\n\t\t| null = null;\n\tprivate config: DesmosToolProviderConfig | null = null;\n\n\tprivate async emitTelemetry(\n\t\teventName: string,\n\t\tpayload?: Record<string, unknown>,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait this.config?.onTelemetry?.(eventName, payload);\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"[DesmosToolProvider] telemetry callback failed:\", error);\n\t\t}\n\t}\n\n\t/**\n\t * Initialize Desmos calculator provider\n\t *\n\t * Loads the Desmos API library and authenticates with provided credentials.\n\t *\n\t * @param config Configuration with API key or proxy endpoint\n\t * @throws Error if initialization fails\n\t */\n\tasync initialize(config: DesmosToolProviderConfig): Promise<void> {\n\t\tif (this.desmosProvider) {\n\t\t\tconsole.warn(\n\t\t\t\t\"[DesmosToolProvider] Already initialized, skipping reinitialization\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.config = config;\n\t\tconst moduleLoadStartedAt = Date.now();\n\t\tawait this.emitTelemetry(\"pie-tool-library-load-start\", {\n\t\t\ttoolId: \"calculator\",\n\t\t\toperation: \"desmos-provider-module-import\",\n\t\t\tbackend: \"desmos\",\n\t\t});\n\t\tconst desmosModule = await (async () => {\n\t\t\ttry {\n\t\t\t\tconst loaded = (await import(\"@pie-players/pie-calculator-desmos\")) as {\n\t\t\t\t\tDesmosCalculatorProvider: new () => CalculatorProvider & {\n\t\t\t\t\t\tinitialize(config: {\n\t\t\t\t\t\t\tapiKey?: string;\n\t\t\t\t\t\t\tproxyEndpoint?: string;\n\t\t\t\t\t\t\tonTelemetry?: (\n\t\t\t\t\t\t\t\teventName: string,\n\t\t\t\t\t\t\t\tpayload?: Record<string, unknown>,\n\t\t\t\t\t\t\t) => void | Promise<void>;\n\t\t\t\t\t\t}): Promise<void>;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\tawait this.emitTelemetry(\"pie-tool-library-load-success\", {\n\t\t\t\t\ttoolId: \"calculator\",\n\t\t\t\t\toperation: \"desmos-provider-module-import\",\n\t\t\t\t\tbackend: \"desmos\",\n\t\t\t\t\tduration: Date.now() - moduleLoadStartedAt,\n\t\t\t\t});\n\t\t\t\treturn loaded;\n\t\t\t} catch (error) {\n\t\t\t\tawait this.emitTelemetry(\"pie-tool-library-load-error\", {\n\t\t\t\t\ttoolId: \"calculator\",\n\t\t\t\t\toperation: \"desmos-provider-module-import\",\n\t\t\t\t\tbackend: \"desmos\",\n\t\t\t\t\tduration: Date.now() - moduleLoadStartedAt,\n\t\t\t\t\terrorType: \"ToolLibraryLoadError\",\n\t\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\t});\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\t\tthis.desmosProvider = new desmosModule.DesmosCalculatorProvider();\n\n\t\t// Initialize with API key or proxy\n\t\ttry {\n\t\t\tawait this.desmosProvider.initialize({\n\t\t\t\tapiKey: config.apiKey,\n\t\t\t\tproxyEndpoint: config.proxyEndpoint,\n\t\t\t\tonTelemetry: config.onTelemetry,\n\t\t\t});\n\n\t\t\tconsole.log(\n\t\t\t\t`[DesmosToolProvider] Initialized successfully ${\n\t\t\t\t\tconfig.proxyEndpoint\n\t\t\t\t\t\t? \"(using proxy)\"\n\t\t\t\t\t\t: config.apiKey\n\t\t\t\t\t\t\t? \"(direct API key)\"\n\t\t\t\t\t\t\t: \"(no auth)\"\n\t\t\t\t}`,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"[DesmosToolProvider] Initialization failed:\", error);\n\t\t\tthrow new Error(\n\t\t\t\t\"Failed to initialize Desmos calculator provider. Check API key or proxy endpoint.\",\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a calculator provider instance\n\t *\n\t * Returns the initialized Desmos calculator provider.\n\t *\n\t * @param config Optional instance-specific configuration (currently unused)\n\t * @returns Desmos calculator provider\n\t * @throws Error if provider not initialized\n\t */\n\tasync createInstance(\n\t\tconfig?: Partial<DesmosToolProviderConfig>,\n\t): Promise<CalculatorProvider> {\n\t\tif (!this.desmosProvider) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[DesmosToolProvider] Provider not initialized. Call initialize() first.\",\n\t\t\t);\n\t\t}\n\n\t\treturn this.desmosProvider;\n\t}\n\n\t/**\n\t * Get provider capabilities\n\t *\n\t * @returns Desmos calculator capabilities\n\t */\n\tgetCapabilities(): ToolProviderCapabilities {\n\t\treturn {\n\t\t\tsupportsOffline: false, // Requires Desmos CDN\n\t\t\trequiresAuth: true,\n\t\t\tmaxInstances: null, // Unlimited calculator instances\n\t\t\tfeatures: {\n\t\t\t\tbasic: true,\n\t\t\t\tscientific: true,\n\t\t\t\tgraphing: true,\n\t\t\t\tfourFunction: true,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Check if provider is ready\n\t *\n\t * @returns true if provider is initialized\n\t */\n\tisReady(): boolean {\n\t\treturn this.desmosProvider !== null;\n\t}\n\n\t/**\n\t * Clean up provider resources\n\t *\n\t * Destroys the Desmos calculator provider and releases resources.\n\t */\n\tdestroy(): void {\n\t\tif (this.desmosProvider) {\n\t\t\tthis.desmosProvider.destroy();\n\t\t\tthis.desmosProvider = null;\n\t\t}\n\t\tthis.config = null;\n\t\tconsole.log(\"[DesmosToolProvider] Destroyed\");\n\t}\n}\n"]}
1
+ {"version":3,"file":"DesmosToolProvider.js","sourceRoot":"","sources":["../../../src/services/tool-providers/DesmosToolProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA8CH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,kBAAkB;IAGrB,UAAU,GAAG,mBAAmB,CAAC;IACjC,YAAY,GAAG,mBAAmB,CAAC;IACnC,QAAQ,GAAG,YAAqB,CAAC;IACjC,OAAO,GAAG,MAAM,CAAC;IACjB,YAAY,GAAG,IAAI,CAAC;IAErB,cAAc,GAWZ,IAAI,CAAC;IACP,MAAM,GAAoC,IAAI,CAAC;IAE/C,KAAK,CAAC,aAAa,CAC1B,SAAiB,EACjB,OAAiC;QAEjC,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,iDAAiD,EAAE,KAAK,CAAC,CAAC;QACxE,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CAAC,MAAgC;QAChD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CACX,qEAAqE,CACrE,CAAC;YACF,OAAO;QACR,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,MAAM,mBAAmB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvC,MAAM,IAAI,CAAC,aAAa,CAAC,6BAA6B,EAAE;YACvD,MAAM,EAAE,YAAY;YACpB,SAAS,EAAE,+BAA+B;YAC1C,OAAO,EAAE,QAAQ;SACjB,CAAC,CAAC;QACH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M;oBACd,CAAC,CAAC,kBAAkB;oBACpB,CAAC,CAAC,WACL,EAAE,CACF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;YACpE,MAAM,IAAI,KAAK,CACd,mFAAmF,CACnF,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,cAAc,CACnB,MAA0C;QAE1C,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACd,yEAAyE,CACzE,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC,cAAc,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,eAAe;QACd,OAAO;YACN,eAAe,EAAE,KAAK,EAAE,sBAAsB;YAC9C,YAAY,EAAE,IAAI;YAClB,YAAY,EAAE,IAAI,EAAE,iCAAiC;YACrD,QAAQ,EAAE;gBACT,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,IAAI;gBAChB,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;aAClB;SACD,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,OAAO;QACN,OAAO,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,OAAO;QACN,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;YAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC/C,CAAC;CACD","sourcesContent":["/**\n * Desmos Calculator Tool Provider\n *\n * Provides Desmos calculators (basic, scientific, graphing)\n * with authentication and proxy support.\n *\n * SECURITY BEST PRACTICE:\n * - Development: Pass apiKey directly for local testing\n * - Production: Use proxyEndpoint or authFetcher to keep API key server-side\n *\n * Part of PIE Assessment Toolkit.\n */\n\nimport type {\n\tCalculatorProvider,\n\tDesmosCalculatorConfig,\n} from \"@pie-players/pie-calculator\";\nimport type {\n\tToolProviderApi,\n\tToolProviderCapabilities,\n} from \"./ToolProviderApi.js\";\n\n/**\n * Desmos tool provider configuration\n */\nexport interface DesmosToolProviderConfig {\n\t/**\n\t * Desmos API key (DEVELOPMENT ONLY)\n\t * Never expose in production client code!\n\t *\n\t * Obtain from: https://www.desmos.com/api\n\t */\n\tapiKey?: string;\n\n\t/**\n\t * Server proxy endpoint (PRODUCTION RECOMMENDED)\n\t * Backend handles API key securely\n\t *\n\t * @example '/api/desmos/token'\n\t * @example 'https://api.myapp.com/tools/desmos/auth'\n\t */\n\tproxyEndpoint?: string;\n\n\t/**\n\t * Default calculator configuration applied to all instances\n\t */\n\tdefaultConfig?: DesmosCalculatorConfig;\n\n\t/**\n\t * Optional telemetry callback for tool/backend instrumentation.\n\t */\n\tonTelemetry?: (\n\t\teventName: string,\n\t\tpayload?: Record<string, unknown>,\n\t) => void | Promise<void>;\n}\n\n/**\n * Desmos Calculator Tool Provider\n *\n * Wraps DesmosCalculatorProvider with the ToolProviderApi interface\n * for use in the ToolProviderRegistry.\n *\n * @example\n * ```typescript\n * const provider = new DesmosToolProvider();\n *\n * await provider.initialize({\n * apiKey: 'your-api-key', // Development only\n * proxyEndpoint: '/api/desmos/token', // Production\n * });\n *\n * const calculatorProvider = await provider.createInstance();\n * ```\n */\nexport class DesmosToolProvider\n\timplements ToolProviderApi<DesmosToolProviderConfig, CalculatorProvider>\n{\n\treadonly providerId = \"desmos-calculator\";\n\treadonly providerName = \"Desmos Calculator\";\n\treadonly category = \"calculator\" as const;\n\treadonly version = \"1.10\";\n\treadonly requiresAuth = true;\n\n\tprivate desmosProvider:\n\t\t| (CalculatorProvider & {\n\t\t\t\tinitialize(config: {\n\t\t\t\t\tapiKey?: string;\n\t\t\t\t\tproxyEndpoint?: string;\n\t\t\t\t\tonTelemetry?: (\n\t\t\t\t\t\teventName: string,\n\t\t\t\t\t\tpayload?: Record<string, unknown>,\n\t\t\t\t\t) => void | Promise<void>;\n\t\t\t\t}): Promise<void>;\n\t\t })\n\t\t| null = null;\n\tprivate config: DesmosToolProviderConfig | null = null;\n\n\tprivate async emitTelemetry(\n\t\teventName: string,\n\t\tpayload?: Record<string, unknown>,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tawait this.config?.onTelemetry?.(eventName, payload);\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"[DesmosToolProvider] telemetry callback failed:\", error);\n\t\t}\n\t}\n\n\t/**\n\t * Initialize Desmos calculator provider\n\t *\n\t * Loads the Desmos API library and authenticates with provided credentials.\n\t *\n\t * @param config Configuration with API key or proxy endpoint\n\t * @throws Error if initialization fails\n\t */\n\tasync initialize(config: DesmosToolProviderConfig): Promise<void> {\n\t\tif (this.desmosProvider) {\n\t\t\tconsole.warn(\n\t\t\t\t\"[DesmosToolProvider] Already initialized, skipping reinitialization\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.config = config;\n\t\tconst moduleLoadStartedAt = Date.now();\n\t\tawait this.emitTelemetry(\"pie-tool-library-load-start\", {\n\t\t\ttoolId: \"calculator\",\n\t\t\toperation: \"desmos-provider-module-import\",\n\t\t\tbackend: \"desmos\",\n\t\t});\n\t\tconst desmosModule = await (async () => {\n\t\t\ttry {\n\t\t\t\tconst loaded = (await import(\"@pie-players/pie-calculator-desmos\")) as {\n\t\t\t\t\tDesmosCalculatorProvider: new () => CalculatorProvider & {\n\t\t\t\t\t\tinitialize(config: {\n\t\t\t\t\t\t\tapiKey?: string;\n\t\t\t\t\t\t\tproxyEndpoint?: string;\n\t\t\t\t\t\t\tonTelemetry?: (\n\t\t\t\t\t\t\t\teventName: string,\n\t\t\t\t\t\t\t\tpayload?: Record<string, unknown>,\n\t\t\t\t\t\t\t) => void | Promise<void>;\n\t\t\t\t\t\t}): Promise<void>;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t\tawait this.emitTelemetry(\"pie-tool-library-load-success\", {\n\t\t\t\t\ttoolId: \"calculator\",\n\t\t\t\t\toperation: \"desmos-provider-module-import\",\n\t\t\t\t\tbackend: \"desmos\",\n\t\t\t\t\tduration: Date.now() - moduleLoadStartedAt,\n\t\t\t\t});\n\t\t\t\treturn loaded;\n\t\t\t} catch (error) {\n\t\t\t\tawait this.emitTelemetry(\"pie-tool-library-load-error\", {\n\t\t\t\t\ttoolId: \"calculator\",\n\t\t\t\t\toperation: \"desmos-provider-module-import\",\n\t\t\t\t\tbackend: \"desmos\",\n\t\t\t\t\tduration: Date.now() - moduleLoadStartedAt,\n\t\t\t\t\terrorType: \"ToolLibraryLoadError\",\n\t\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\t});\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})();\n\t\tthis.desmosProvider = new desmosModule.DesmosCalculatorProvider();\n\n\t\t// Initialize with API key or proxy\n\t\ttry {\n\t\t\tawait this.desmosProvider.initialize({\n\t\t\t\tapiKey: config.apiKey,\n\t\t\t\tproxyEndpoint: config.proxyEndpoint,\n\t\t\t\tonTelemetry: config.onTelemetry,\n\t\t\t});\n\n\t\t\tconsole.log(\n\t\t\t\t`[DesmosToolProvider] Initialized successfully ${\n\t\t\t\t\tconfig.proxyEndpoint\n\t\t\t\t\t\t? \"(using proxy)\"\n\t\t\t\t\t\t: config.apiKey\n\t\t\t\t\t\t\t? \"(direct API key)\"\n\t\t\t\t\t\t\t: \"(no auth)\"\n\t\t\t\t}`,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"[DesmosToolProvider] Initialization failed:\", error);\n\t\t\tthrow new Error(\n\t\t\t\t\"Failed to initialize Desmos calculator provider. Check API key or proxy endpoint.\",\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a calculator provider instance\n\t *\n\t * Returns the initialized Desmos calculator provider.\n\t *\n\t * @param config Optional instance-specific configuration (currently unused)\n\t * @returns Desmos calculator provider\n\t * @throws Error if provider not initialized\n\t */\n\tasync createInstance(\n\t\tconfig?: Partial<DesmosToolProviderConfig>,\n\t): Promise<CalculatorProvider> {\n\t\tif (!this.desmosProvider) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[DesmosToolProvider] Provider not initialized. Call initialize() first.\",\n\t\t\t);\n\t\t}\n\n\t\treturn this.desmosProvider;\n\t}\n\n\t/**\n\t * Get provider capabilities\n\t *\n\t * @returns Desmos calculator capabilities\n\t */\n\tgetCapabilities(): ToolProviderCapabilities {\n\t\treturn {\n\t\t\tsupportsOffline: false, // Requires Desmos CDN\n\t\t\trequiresAuth: true,\n\t\t\tmaxInstances: null, // Unlimited calculator instances\n\t\t\tfeatures: {\n\t\t\t\tbasic: true,\n\t\t\t\tscientific: true,\n\t\t\t\tgraphing: true,\n\t\t\t\tfourFunction: true,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Check if provider is ready\n\t *\n\t * @returns true if provider is initialized\n\t */\n\tisReady(): boolean {\n\t\treturn this.desmosProvider !== null;\n\t}\n\n\t/**\n\t * Clean up provider resources\n\t *\n\t * Destroys the Desmos calculator provider and releases resources.\n\t */\n\tdestroy(): void {\n\t\tif (this.desmosProvider) {\n\t\t\tthis.desmosProvider.destroy();\n\t\t\tthis.desmosProvider = null;\n\t\t}\n\t\tthis.config = null;\n\t\tconsole.log(\"[DesmosToolProvider] Destroyed\");\n\t}\n}\n"]}