@pie-players/pie-assessment-toolkit 0.3.74 → 0.3.75
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.
- package/README.md +349 -313
- package/dist/attempt/TestSession.d.ts +1 -20
- package/dist/attempt/TestSession.js +8 -99
- package/dist/components/ItemScope.custom-element.d.ts +1 -0
- package/dist/components/ItemScope.custom-element.js +1 -0
- package/dist/components/ItemToolBar.custom-element.js +1 -1
- package/dist/components/PieAssessmentToolkit.custom-element.js +14 -14
- package/dist/components/SectionToolBar.custom-element.js +1 -1
- package/dist/components/chunks/ItemToolBar-7tt7v2xp.js +4 -0
- package/dist/components/chunks/{ItemToolBar-gmrryv2v.js → ItemToolBar-97hx60z4.js} +1 -1
- package/dist/components/chunks/ItemToolBar-bxwyhr5p.js +2 -0
- package/dist/components/chunks/ItemToolBar-jx38w99s.js +2 -0
- package/dist/components/chunks/ItemToolBar-rd2bb4p6.js +40 -0
- package/dist/components/chunks/ItemToolBar-vdkyn9f3.js +2 -0
- package/dist/components/chunks/sre-engine-jd8cc08x.js +1 -0
- package/dist/components/item-scope-element.d.ts +2 -0
- package/dist/components/item-scope-element.js +2 -0
- package/dist/context/assessment-toolkit-context.d.ts +27 -6
- package/dist/index.d.ts +22 -47
- package/dist/index.js +12 -36
- package/dist/policy/core/PolicySource.d.ts +1 -1
- package/dist/policy/core/ToolPolicyEngine.d.ts +77 -32
- package/dist/policy/core/ToolPolicyEngine.js +136 -46
- package/dist/policy/core/compose-decision.d.ts +28 -7
- package/dist/policy/core/compose-decision.js +75 -54
- package/dist/policy/core/decision-types.d.ts +65 -34
- package/dist/policy/core/feature-decision.d.ts +16 -9
- package/dist/policy/core/feature-decision.js +14 -8
- package/dist/policy/core/pnp-policy-inputs.d.ts +24 -33
- package/dist/policy/core/pnp-policy-inputs.js +28 -56
- package/dist/policy/core/provenance.d.ts +9 -4
- package/dist/policy/core/provenance.js +1 -1
- package/dist/policy/engine.d.ts +7 -23
- package/dist/policy/engine.js +5 -20
- package/dist/policy/sources/PnpPolicySource.d.ts +44 -61
- package/dist/policy/sources/PnpPolicySource.js +117 -118
- package/dist/runtime/SectionControllerBinding.d.ts +279 -0
- package/dist/runtime/SectionControllerBinding.js +450 -0
- package/dist/runtime/SectionRuntimeEngine.d.ts +26 -289
- package/dist/runtime/SectionRuntimeEngine.js +30 -372
- package/dist/runtime/adapter/SectionEngineAdapter.d.ts +19 -80
- package/dist/runtime/adapter/SectionEngineAdapter.js +19 -92
- package/dist/runtime/adapter/dom-event-bridge.d.ts +15 -30
- package/dist/runtime/adapter/dom-event-bridge.js +17 -44
- package/dist/runtime/adapter/subscriber-fanout.d.ts +1 -2
- package/dist/runtime/adapter/subscriber-fanout.js +1 -2
- package/dist/runtime/catalog-context.d.ts +19 -0
- package/dist/runtime/catalog-context.js +28 -0
- package/dist/runtime/composition-emit-scheduler.d.ts +9 -15
- package/dist/runtime/composition-emit-scheduler.js +9 -15
- package/dist/runtime/content-language.d.ts +32 -0
- package/dist/runtime/content-language.js +46 -0
- package/dist/runtime/content-region.d.ts +17 -0
- package/dist/runtime/content-region.js +29 -0
- package/dist/runtime/content-registration.d.ts +13 -0
- package/dist/runtime/content-registration.js +25 -0
- package/dist/runtime/core/SectionEngineCore.d.ts +2 -2
- package/dist/runtime/core/SectionEngineCore.js +2 -2
- package/dist/runtime/core/cohort.d.ts +1 -1
- package/dist/runtime/core/cohort.js +1 -1
- package/dist/runtime/core/engine-input.d.ts +18 -30
- package/dist/runtime/core/engine-input.js +11 -12
- package/dist/runtime/core/engine-output.d.ts +16 -40
- package/dist/runtime/core/engine-output.js +9 -21
- package/dist/runtime/core/engine-readiness.d.ts +5 -37
- package/dist/runtime/core/engine-readiness.js +8 -41
- package/dist/runtime/core/engine-resolver.d.ts +46 -74
- package/dist/runtime/core/engine-resolver.js +18 -43
- package/dist/runtime/core/engine-state.d.ts +28 -36
- package/dist/runtime/core/engine-state.js +18 -21
- package/dist/runtime/core/engine-transition.d.ts +14 -19
- package/dist/runtime/core/engine-transition.js +71 -51
- package/dist/runtime/engine.d.ts +16 -19
- package/dist/runtime/engine.js +12 -19
- package/dist/runtime/page-warnings.d.ts +13 -0
- package/dist/runtime/page-warnings.js +22 -0
- package/dist/runtime/policy-input-forwarding.d.ts +25 -0
- package/dist/runtime/policy-input-forwarding.js +25 -0
- package/dist/runtime/registration-events.d.ts +11 -0
- package/dist/runtime/runtime-event-claim.d.ts +8 -0
- package/dist/runtime/runtime-event-claim.js +15 -0
- package/dist/runtime/shell-event-bridge.d.ts +45 -0
- package/dist/runtime/shell-event-bridge.js +127 -0
- package/dist/runtime/shell-registration.d.ts +73 -0
- package/dist/runtime/shell-registration.js +95 -0
- package/dist/runtime/shell-scope.d.ts +68 -0
- package/dist/runtime/shell-scope.js +188 -0
- package/dist/runtime/tool-host-contract.d.ts +8 -10
- package/dist/runtime/tool-host-contract.js +11 -11
- package/dist/runtime/unclaimed-registration-watch.d.ts +7 -0
- package/dist/runtime/unclaimed-registration-watch.js +23 -0
- package/dist/services/ElementToolStateStore.d.ts +14 -10
- package/dist/services/ElementToolStateStore.js +37 -13
- package/dist/services/HighlightCoordinator.d.ts +21 -21
- package/dist/services/HighlightCoordinator.js +431 -325
- package/dist/services/RangeSerializer.d.ts +10 -1
- package/dist/services/RangeSerializer.js +87 -14
- package/dist/services/TTSService.d.ts +117 -70
- package/dist/services/TTSService.js +668 -578
- package/dist/services/ToolCoordinator.d.ts +43 -60
- package/dist/services/ToolCoordinator.js +164 -206
- package/dist/services/ToolRegistry.d.ts +74 -57
- package/dist/services/ToolRegistry.js +104 -114
- package/dist/services/ToolkitCoordinator.d.ts +183 -189
- package/dist/services/ToolkitCoordinator.js +477 -431
- package/dist/services/audio-handoff.d.ts +6 -7
- package/dist/services/audio-handoff.js +20 -14
- package/dist/services/catalog-owner.d.ts +0 -1
- package/dist/services/framework-error-bus.d.ts +3 -6
- package/dist/services/framework-error-bus.js +3 -6
- package/dist/services/framework-error.d.ts +22 -7
- package/dist/services/framework-error.js +9 -7
- package/dist/services/interfaces.d.ts +158 -129
- package/dist/services/section-session-assignment.d.ts +21 -0
- package/dist/services/section-session-assignment.js +82 -0
- package/dist/services/spoken-audio-cards.d.ts +0 -2
- package/dist/services/spoken-audio-cards.js +0 -2
- package/dist/services/tool-config-defaults.d.ts +3 -3
- package/dist/services/tool-config-defaults.js +3 -3
- package/dist/services/tool-config-validation.d.ts +4 -5
- package/dist/services/tool-config-validation.js +36 -61
- package/dist/services/tool-context.d.ts +0 -8
- package/dist/services/tool-context.js +0 -12
- package/dist/services/tool-icons.d.ts +4 -3
- package/dist/services/tool-icons.js +4 -3
- package/dist/services/tool-instance-id.d.ts +0 -1
- package/dist/services/tool-instance-id.js +0 -6
- package/dist/services/tool-providers/TTSToolProvider.d.ts +18 -19
- package/dist/services/tool-providers/TTSToolProvider.js +37 -34
- package/dist/services/tool-providers/ToolProviderApi.d.ts +10 -4
- package/dist/services/tool-providers/ToolProviderRegistry.d.ts +30 -26
- package/dist/services/tool-providers/ToolProviderRegistry.js +119 -93
- package/dist/services/tool-request.d.ts +27 -12
- package/dist/services/tool-request.js +24 -14
- package/dist/services/toolbar-decided-tools.d.ts +15 -0
- package/dist/services/toolbar-decided-tools.js +28 -0
- package/dist/services/tools-config-normalizer.d.ts +17 -22
- package/dist/services/tools-config-normalizer.js +2 -10
- package/dist/services/tts/browser-provider.d.ts +38 -2
- package/dist/services/tts/browser-provider.js +276 -140
- package/dist/services/tts/flat-tree.d.ts +71 -0
- package/dist/services/tts/flat-tree.js +269 -0
- package/dist/services/tts/generated-speech/assemble-plan.d.ts +3 -1
- package/dist/services/tts/generated-speech/assemble-plan.js +3 -1
- package/dist/services/tts/generated-speech/dom/build-dom-plan.d.ts +2 -0
- package/dist/services/tts/generated-speech/dom/build-dom-plan.js +1 -1
- package/dist/services/tts/generated-speech/math-speech-cache.d.ts +3 -1
- package/dist/services/tts/generated-speech/math-speech-cache.js +5 -1
- package/dist/services/tts/highlight-pipeline/create-highlight-plan.js +12 -4
- package/dist/services/tts/highlight-pipeline/prose-boundary-resolver.js +6 -4
- package/dist/services/tts/highlight-pipeline/readable-region.js +3 -2
- package/dist/services/tts/highlight-pipeline/types.d.ts +5 -0
- package/dist/services/tts/highlight-pipeline/visible-map-range.d.ts +12 -0
- package/dist/services/tts/highlight-pipeline/visible-map-range.js +73 -7
- package/dist/services/tts/math-aware-text-processing.d.ts +5 -1
- package/dist/services/tts/math-aware-text-processing.js +32 -18
- package/dist/services/tts/math-control-names.d.ts +21 -0
- package/dist/services/tts/math-control-names.js +142 -0
- package/dist/services/tts/math-speech.d.ts +11 -0
- package/dist/services/tts/math-speech.js +51 -18
- package/dist/services/tts/provider-options.d.ts +41 -0
- package/dist/services/tts/provider-options.js +1 -0
- package/dist/services/tts/ssml/spoken-text.d.ts +2 -26
- package/dist/services/tts/ssml/spoken-text.js +29 -0
- package/dist/services/tts/start-failure.d.ts +11 -0
- package/dist/services/tts/start-failure.js +19 -0
- package/dist/services/tts/text-processing.d.ts +9 -0
- package/dist/services/tts/text-processing.js +46 -33
- package/dist/services/tts/text-segmentation.d.ts +7 -0
- package/dist/services/tts/text-segmentation.js +47 -0
- package/dist/services/tts-runtime-config.d.ts +25 -17
- package/dist/services/tts-runtime-config.js +16 -95
- package/dist/tools/content-capability-resolution.d.ts +7 -9
- package/dist/tools/content-capability-resolution.js +8 -45
- package/dist/tools/registration.d.ts +58 -0
- package/dist/tools/registration.js +54 -0
- package/dist/tools/registrations/toolbar-registration-helpers.js +2 -2
- package/dist/tools/tool-surface-host.d.ts +6 -10
- package/dist/tools/tool-surface-host.js +44 -42
- package/dist/tools/tool-tag-map.d.ts +5 -15
- package/dist/tools/tool-tag-map.js +6 -20
- package/dist/utils/structural-equality.d.ts +11 -0
- package/dist/utils/structural-equality.js +47 -0
- package/package.json +13 -29
- package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +0 -49
- package/dist/attempt/adapters/activity-to-test-attempt-session.js +0 -138
- package/dist/components/chunks/ItemToolBar-b9dz5jvd.js +0 -40
- package/dist/components/chunks/ItemToolBar-h4xap0t0.js +0 -4
- package/dist/components/chunks/ItemToolBar-wr2myaah.js +0 -2
- package/dist/components/chunks/sre-engine-wf9s43gg.js +0 -1
- package/dist/context/runtime-context-consumer.d.ts +0 -13
- package/dist/context/runtime-context-consumer.js +0 -18
- package/dist/item-loader.d.ts +0 -44
- package/dist/item-loader.js +0 -61
- package/dist/policy/core/engine-context.d.ts +0 -29
- package/dist/policy/core/engine-context.js +0 -27
- package/dist/policy/core/policy-source-tag.d.ts +0 -31
- package/dist/policy/core/policy-source-tag.js +0 -28
- package/dist/policy/internal.d.ts +0 -25
- package/dist/policy/internal.js +0 -25
- package/dist/runtime/adapter/coordinator-bridge.d.ts +0 -92
- package/dist/runtime/adapter/coordinator-bridge.js +0 -126
- package/dist/runtime/adapter/framework-error-bridge.d.ts +0 -36
- package/dist/runtime/adapter/framework-error-bridge.js +0 -46
- package/dist/runtime/adapter/instrumentation-bridge.d.ts +0 -31
- package/dist/runtime/adapter/instrumentation-bridge.js +0 -38
- package/dist/runtime/core/engine-stage-derivation.d.ts +0 -18
- package/dist/runtime/core/engine-stage-derivation.js +0 -29
- package/dist/runtime/engine-context.d.ts +0 -39
- package/dist/runtime/engine-context.js +0 -31
- package/dist/runtime/internal.d.ts +0 -43
- package/dist/runtime/internal.js +0 -45
- package/dist/runtime/section-runtime-engine-host-context.d.ts +0 -74
- package/dist/runtime/section-runtime-engine-host-context.js +0 -57
- package/dist/runtime/stage-emit-gate.d.ts +0 -92
- package/dist/runtime/stage-emit-gate.js +0 -82
- package/dist/services/I18nService.d.ts +0 -47
- package/dist/services/I18nService.js +0 -84
- package/dist/services/ThemeProvider.d.ts +0 -95
- package/dist/services/ThemeProvider.js +0 -334
- package/dist/services/defaultPersonalNeedsProfile.d.ts +0 -21
- package/dist/services/defaultPersonalNeedsProfile.js +0 -26
- package/dist/services/pnp-standard-features.d.ts +0 -238
- package/dist/services/pnp-standard-features.js +0 -338
- package/dist/tools/client.d.ts +0 -10
- package/dist/tools/client.js +0 -10
- package/dist/tools/internal.d.ts +0 -44
- package/dist/tools/internal.js +0 -39
|
@@ -32,11 +32,11 @@ export class ToolRequestRegistry {
|
|
|
32
32
|
changeListeners = new Set();
|
|
33
33
|
registerTarget(target) {
|
|
34
34
|
this.targets.add(target);
|
|
35
|
-
this.
|
|
35
|
+
this.notifyTargetsChange();
|
|
36
36
|
return () => {
|
|
37
37
|
if (!this.targets.delete(target))
|
|
38
38
|
return;
|
|
39
|
-
this.
|
|
39
|
+
this.notifyTargetsChange();
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
@@ -46,12 +46,12 @@ export class ToolRequestRegistry {
|
|
|
46
46
|
* nothing is worse than an absent one, and availability moves with policy —
|
|
47
47
|
* hence {@link onTargetsChange}.
|
|
48
48
|
*/
|
|
49
|
-
canRequest(toolId, level) {
|
|
50
|
-
return this.findTarget(toolId, level) !== null;
|
|
49
|
+
canRequest(toolId, level, scopeId) {
|
|
50
|
+
return this.findTarget(toolId, level, scopeId) !== null;
|
|
51
51
|
}
|
|
52
52
|
/** Returns whether a target claimed the request. */
|
|
53
53
|
request(request) {
|
|
54
|
-
const target = this.findTarget(request.toolId, request.level);
|
|
54
|
+
const target = this.findTarget(request.toolId, request.level, request.scopeId);
|
|
55
55
|
if (!target)
|
|
56
56
|
return false;
|
|
57
57
|
try {
|
|
@@ -64,12 +64,13 @@ export class ToolRequestRegistry {
|
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
* Fires when a toolbar registers or unregisters
|
|
67
|
+
* Fires when a toolbar registers or unregisters, and on
|
|
68
|
+
* {@link notifyTargetsChange}.
|
|
68
69
|
*
|
|
69
|
-
* Not when a registered toolbar's
|
|
70
|
-
* live, so a caller re-asking `canRequest` gets the current answer. A
|
|
71
|
-
* that needs to notice a policy change should also follow the policy
|
|
72
|
-
* already has.
|
|
70
|
+
* Not when a policy change moves a registered toolbar's visible set: `hostsTool`
|
|
71
|
+
* is read live, so a caller re-asking `canRequest` gets the current answer. A
|
|
72
|
+
* surface that needs to notice a policy change should also follow the policy
|
|
73
|
+
* signal it already has.
|
|
73
74
|
*/
|
|
74
75
|
onTargetsChange(listener) {
|
|
75
76
|
this.changeListeners.add(listener);
|
|
@@ -84,22 +85,26 @@ export class ToolRequestRegistry {
|
|
|
84
85
|
* and still have a section-scoped gateway reach it. Requesting a level explicitly
|
|
85
86
|
* does not fall back, because a requester that named one meant it.
|
|
86
87
|
*/
|
|
87
|
-
findTarget(toolId, level) {
|
|
88
|
-
const preferred = this.findTargetAtLevel(toolId, level ?? DEFAULT_TOOL_REQUEST_LEVEL);
|
|
88
|
+
findTarget(toolId, level, scopeId) {
|
|
89
|
+
const preferred = this.findTargetAtLevel(toolId, level ?? DEFAULT_TOOL_REQUEST_LEVEL, scopeId);
|
|
89
90
|
if (preferred || level !== undefined)
|
|
90
91
|
return preferred;
|
|
91
92
|
for (const target of this.targets) {
|
|
92
93
|
if (target.level === DEFAULT_TOOL_REQUEST_LEVEL)
|
|
93
94
|
continue;
|
|
95
|
+
if (scopeId !== undefined && target.scopeId !== scopeId)
|
|
96
|
+
continue;
|
|
94
97
|
if (this.hostsTool(target, toolId))
|
|
95
98
|
return target;
|
|
96
99
|
}
|
|
97
100
|
return null;
|
|
98
101
|
}
|
|
99
|
-
findTargetAtLevel(toolId, level) {
|
|
102
|
+
findTargetAtLevel(toolId, level, scopeId) {
|
|
100
103
|
for (const target of this.targets) {
|
|
101
104
|
if (target.level !== level)
|
|
102
105
|
continue;
|
|
106
|
+
if (scopeId !== undefined && target.scopeId !== scopeId)
|
|
107
|
+
continue;
|
|
103
108
|
if (this.hostsTool(target, toolId))
|
|
104
109
|
return target;
|
|
105
110
|
}
|
|
@@ -114,7 +119,12 @@ export class ToolRequestRegistry {
|
|
|
114
119
|
return false;
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Tell change listeners that what the targets can claim changed. Registration
|
|
124
|
+
* calls it, and so does the coordinator when a target stops hosting a tool
|
|
125
|
+
* outside a policy change, as when the tool's module fails to load.
|
|
126
|
+
*/
|
|
127
|
+
notifyTargetsChange() {
|
|
118
128
|
for (const listener of this.changeListeners) {
|
|
119
129
|
try {
|
|
120
130
|
listener();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ToolPolicyDecision } from "../policy/core/decision-types.js";
|
|
2
|
+
/** What a toolbar renders from in a policy decision, per visible tool. */
|
|
3
|
+
export interface DecidedToolbarTool {
|
|
4
|
+
toolId: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
alwaysAvailable: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A toolbar's decided tools across re-decisions. The tracker returns its
|
|
10
|
+
* previous list while `renderVersion` is unchanged and the decision shows the
|
|
11
|
+
* same tools, so a re-decision that changes nothing the toolbar renders from
|
|
12
|
+
* keeps the rendered tools: rendering swaps in fresh tool elements, whose state
|
|
13
|
+
* starts over. A new `renderVersion` always yields a new list.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createDecidedToolsTracker(): (decision: ToolPolicyDecision | null, renderVersion: number) => readonly DecidedToolbarTool[] | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { structurallyEqual } from "../utils/structural-equality.js";
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar's decided tools across re-decisions. The tracker returns its
|
|
4
|
+
* previous list while `renderVersion` is unchanged and the decision shows the
|
|
5
|
+
* same tools, so a re-decision that changes nothing the toolbar renders from
|
|
6
|
+
* keeps the rendered tools: rendering swaps in fresh tool elements, whose state
|
|
7
|
+
* starts over. A new `renderVersion` always yields a new list.
|
|
8
|
+
*/
|
|
9
|
+
export function createDecidedToolsTracker() {
|
|
10
|
+
let last = null;
|
|
11
|
+
return (decision, renderVersion) => {
|
|
12
|
+
if (!decision) {
|
|
13
|
+
last = null;
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const tools = decision.visibleTools.map((entry) => ({
|
|
17
|
+
toolId: entry.toolId,
|
|
18
|
+
required: entry.required,
|
|
19
|
+
alwaysAvailable: entry.alwaysAvailable,
|
|
20
|
+
}));
|
|
21
|
+
if (last?.renderVersion === renderVersion &&
|
|
22
|
+
structurallyEqual(last.tools, tools)) {
|
|
23
|
+
return last.tools;
|
|
24
|
+
}
|
|
25
|
+
last = { renderVersion, tools };
|
|
26
|
+
return tools;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CalculatorProviderConfig } from "@pie-players/pie-calculator";
|
|
2
|
-
import type {
|
|
2
|
+
import type { TTSRuntimeSettings } from "./tts-runtime-config.js";
|
|
3
3
|
export type ToolPlacementLevel = "section" | "item" | "passage";
|
|
4
4
|
export interface ToolPolicyConfig {
|
|
5
5
|
allowed?: string[];
|
|
@@ -43,22 +43,22 @@ export interface ToolRuntimeProviderConfig {
|
|
|
43
43
|
init?: Record<string, unknown>;
|
|
44
44
|
runtime?: ToolRuntimeProviderBridge;
|
|
45
45
|
}
|
|
46
|
-
export type TextToSpeechRuntimeProviderId = "polly" | "google" | "custom";
|
|
47
46
|
export interface ToolProviderConfig {
|
|
48
47
|
enabled?: boolean;
|
|
49
48
|
provider?: ToolRuntimeProviderConfig;
|
|
50
49
|
settings?: Record<string, unknown>;
|
|
51
50
|
[key: string]: unknown;
|
|
52
51
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
/**
|
|
53
|
+
* `tools.providers.textToSpeech`, closed to the runtime settings the TTS tool
|
|
54
|
+
* reads plus the registration's `enabled` and runtime `provider`. `Pick` keeps
|
|
55
|
+
* it assignable to the providers index signature, which an interface would not
|
|
56
|
+
* be.
|
|
57
|
+
*/
|
|
58
|
+
export type TextToSpeechToolProviderConfig = Pick<TTSRuntimeSettings, keyof TTSRuntimeSettings> & {
|
|
59
|
+
enabled?: boolean;
|
|
60
|
+
provider?: ToolRuntimeProviderConfig;
|
|
61
|
+
};
|
|
62
62
|
/**
|
|
63
63
|
* `tools.providers.calculator`, closed to the keys the calculator reads, so a
|
|
64
64
|
* misplaced key such as a top-level `authFetcher` fails to compile instead of
|
|
@@ -72,13 +72,11 @@ export type CalculatorToolProviderConfig = Pick<CalculatorProviderConfig, keyof
|
|
|
72
72
|
export interface ToolProvidersConfig {
|
|
73
73
|
textToSpeech?: TextToSpeechToolProviderConfig;
|
|
74
74
|
calculator?: CalculatorToolProviderConfig;
|
|
75
|
-
[key: string]: ToolProviderConfig |
|
|
75
|
+
[key: string]: ToolProviderConfig | undefined;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* PNP/profile enforcement mode
|
|
79
|
-
*
|
|
80
|
-
* `providers` so hosts can pin or opt out of PNP/profile precedence via
|
|
81
|
-
* the runtime config without reaching for the toolkit prop directly.
|
|
78
|
+
* PNP/profile enforcement mode, set as `tools.pnpEnforcement` (on a section
|
|
79
|
+
* player, `runtime.tools.pnpEnforcement`).
|
|
82
80
|
*
|
|
83
81
|
* - `"on"` — force enforcement (engine applies PNP/profile gates).
|
|
84
82
|
* - `"off"` — opt out (engine ignores PNP/profile inputs).
|
|
@@ -93,11 +91,9 @@ export interface CanonicalToolsConfig {
|
|
|
93
91
|
placement: Required<ToolPlacementConfig>;
|
|
94
92
|
providers: ToolProvidersConfig;
|
|
95
93
|
/**
|
|
96
|
-
* Optional PNP/profile enforcement override
|
|
97
|
-
* `
|
|
98
|
-
*
|
|
99
|
-
* embedded path's equivalent of the standalone `pnp-enforcement`
|
|
100
|
-
* attribute. See {@link ToolsPnpEnforcement} for semantics.
|
|
94
|
+
* Optional PNP/profile enforcement override, read by
|
|
95
|
+
* `<pie-assessment-toolkit>` and `ToolkitCoordinator`. See
|
|
96
|
+
* {@link ToolsPnpEnforcement} for semantics.
|
|
101
97
|
*/
|
|
102
98
|
pnpEnforcement?: ToolsPnpEnforcement;
|
|
103
99
|
}
|
|
@@ -108,7 +104,6 @@ export interface CanonicalToolsConfig {
|
|
|
108
104
|
export type ToolsConfigInput = Omit<Partial<CanonicalToolsConfig>, "placement"> & {
|
|
109
105
|
placement?: ToolPlacementConfig;
|
|
110
106
|
};
|
|
111
|
-
export declare function normalizeToolAlias(toolId: string): string;
|
|
112
107
|
export declare function normalizeToolList(toolIds: string[] | undefined | null): string[];
|
|
113
108
|
export declare function parseToolList(input: string | undefined | null): string[];
|
|
114
109
|
export declare function normalizeToolsConfig(input?: ToolsConfigInput | null): CanonicalToolsConfig;
|
|
@@ -42,7 +42,6 @@ function assertProviderConfig(providerId, value) {
|
|
|
42
42
|
throw new Error(`Invalid tools config at "providers.${providerId}": expected an object.`);
|
|
43
43
|
}
|
|
44
44
|
const config = value;
|
|
45
|
-
const isTTSRuntimeProviderId = (provider) => provider === "polly" || provider === "google" || provider === "custom";
|
|
46
45
|
if ("enabled" in config &&
|
|
47
46
|
config.enabled !== undefined &&
|
|
48
47
|
typeof config.enabled !== "boolean") {
|
|
@@ -55,8 +54,7 @@ function assertProviderConfig(providerId, value) {
|
|
|
55
54
|
}
|
|
56
55
|
if ("provider" in config &&
|
|
57
56
|
config.provider !== undefined &&
|
|
58
|
-
!isPlainObject(config.provider)
|
|
59
|
-
!(providerId === "textToSpeech" && isTTSRuntimeProviderId(config.provider))) {
|
|
57
|
+
!isPlainObject(config.provider)) {
|
|
60
58
|
throw new Error(`Invalid tools config at "providers.${providerId}.provider": expected an object.`);
|
|
61
59
|
}
|
|
62
60
|
return config;
|
|
@@ -73,12 +71,6 @@ function assertProvidersConfig(value) {
|
|
|
73
71
|
}
|
|
74
72
|
return normalized;
|
|
75
73
|
}
|
|
76
|
-
export function normalizeToolAlias(toolId) {
|
|
77
|
-
const trimmed = toolId.trim();
|
|
78
|
-
if (!trimmed)
|
|
79
|
-
return "";
|
|
80
|
-
return trimmed;
|
|
81
|
-
}
|
|
82
74
|
export function normalizeToolList(toolIds) {
|
|
83
75
|
if (!toolIds || toolIds.length === 0)
|
|
84
76
|
return [];
|
|
@@ -87,7 +79,7 @@ export function normalizeToolList(toolIds) {
|
|
|
87
79
|
if (typeof rawToolId !== "string") {
|
|
88
80
|
throw new Error("Invalid tools config: tool list entries must be strings.");
|
|
89
81
|
}
|
|
90
|
-
const normalized =
|
|
82
|
+
const normalized = rawToolId.trim();
|
|
91
83
|
if (!normalized)
|
|
92
84
|
continue;
|
|
93
85
|
deduped.add(normalized);
|
|
@@ -6,7 +6,44 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Part of PIE Assessment Toolkit.
|
|
8
8
|
*/
|
|
9
|
-
import type { ITTSProvider, ITTSProviderImplementation, TTSConfig,
|
|
9
|
+
import type { ITTSProvider, ITTSProviderImplementation, TTSConfig, TTSProviderCapabilities } from "@pie-players/pie-tts";
|
|
10
|
+
/**
|
|
11
|
+
* The part of another provider's configuration that keeps its meaning on
|
|
12
|
+
* browser speech. Every path that replaces a provider with browser speech
|
|
13
|
+
* starts it with this.
|
|
14
|
+
*/
|
|
15
|
+
export declare const browserFallbackConfig: (config: Partial<TTSConfig>) => Partial<TTSConfig>;
|
|
16
|
+
/**
|
|
17
|
+
* The voice traits browser voice selection reads. A `SpeechSynthesisVoice` has
|
|
18
|
+
* them all; a host's own voice list may carry a subset.
|
|
19
|
+
*/
|
|
20
|
+
export interface BrowserVoiceTraits {
|
|
21
|
+
voiceURI?: string;
|
|
22
|
+
name?: string;
|
|
23
|
+
lang?: string;
|
|
24
|
+
localService?: boolean;
|
|
25
|
+
default?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether a voice speaks `contentLanguage`, or the browser's own language when
|
|
29
|
+
* the content names none: the same language, or the same primary subtag.
|
|
30
|
+
*/
|
|
31
|
+
export declare const browserVoiceMatchesLanguage: (voice: Pick<BrowserVoiceTraits, "lang">, contentLanguage?: string) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The voice to read with: the configured one, else one for `contentLanguage`
|
|
34
|
+
* (the language of the content being read), else one for the browser's own
|
|
35
|
+
* language.
|
|
36
|
+
*/
|
|
37
|
+
export declare const findBrowserVoice: <Voice extends BrowserVoiceTraits>(voices: readonly Voice[], preferredVoice?: string, contentLanguage?: string) => Voice | null;
|
|
38
|
+
/**
|
|
39
|
+
* Waits for `synth` to publish its voice inventory, which browsers fill
|
|
40
|
+
* asynchronously after page load. Resolves `true` once `getVoices()` is
|
|
41
|
+
* non-empty, at once when it already is; `false` after `timeoutMs`, once
|
|
42
|
+
* `isCurrent` reports the wait superseded, or when `synth` offers no
|
|
43
|
+
* `voiceschanged` channel to wait on. A previous `onvoiceschanged` handler
|
|
44
|
+
* keeps running and is restored afterwards.
|
|
45
|
+
*/
|
|
46
|
+
export declare const waitForBrowserVoices: (synth: SpeechSynthesis, timeoutMs: number, isCurrent?: () => boolean) => Promise<boolean>;
|
|
10
47
|
/**
|
|
11
48
|
* Browser TTS Provider
|
|
12
49
|
*
|
|
@@ -17,7 +54,6 @@ export declare class BrowserTTSProvider implements ITTSProvider {
|
|
|
17
54
|
readonly providerName = "Browser Speech Synthesis";
|
|
18
55
|
readonly version = "1.0.0";
|
|
19
56
|
initialize(config: TTSConfig): Promise<ITTSProviderImplementation>;
|
|
20
|
-
supportsFeature(feature: TTSFeature): boolean;
|
|
21
57
|
getCapabilities(): TTSProviderCapabilities;
|
|
22
58
|
destroy(): void;
|
|
23
59
|
}
|