@pie-players/pie-assessment-toolkit 0.3.73 → 0.3.74
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 +171 -56
- package/dist/attempt/AssessmentSession.d.ts +1 -5
- package/dist/attempt/AssessmentSession.js +0 -29
- package/dist/components/ItemToolBar.custom-element.d.ts +1 -0
- package/dist/components/ItemToolBar.custom-element.js +1 -1
- package/dist/components/PieAssessmentToolkit.custom-element.d.ts +1 -0
- package/dist/components/PieAssessmentToolkit.custom-element.js +14 -14
- package/dist/components/SectionToolBar.custom-element.d.ts +1 -0
- package/dist/components/SectionToolBar.custom-element.js +1 -1
- package/dist/components/chunks/ItemToolBar-b9dz5jvd.js +40 -0
- package/dist/components/chunks/ItemToolBar-gmrryv2v.js +2 -0
- package/dist/components/chunks/ItemToolBar-h4xap0t0.js +4 -0
- package/dist/components/chunks/ItemToolBar-wr2myaah.js +2 -0
- package/dist/components/chunks/sre-engine-wf9s43gg.js +1 -0
- package/dist/context/assessment-toolkit-context.d.ts +5 -0
- package/dist/context/runtime-context-consumer.js +5 -38
- package/dist/index.d.ts +6 -6
- package/dist/index.js +8 -9
- package/dist/policy/core/ToolPolicyEngine.d.ts +8 -2
- package/dist/policy/core/ToolPolicyEngine.js +12 -0
- package/dist/runtime/adapter/SectionEngineAdapter.d.ts +3 -3
- package/dist/runtime/adapter/SectionEngineAdapter.js +3 -3
- package/dist/runtime/registration-events.d.ts +3 -0
- package/dist/runtime/section-runtime-engine-host-context.d.ts +3 -9
- package/dist/runtime/section-runtime-engine-host-context.js +5 -43
- package/dist/runtime/tool-host-contract.d.ts +20 -0
- package/dist/runtime/tool-host-contract.js +21 -0
- package/dist/services/HighlightCoordinator.d.ts +1 -7
- package/dist/services/HighlightCoordinator.js +1 -3
- package/dist/services/TTSService.d.ts +15 -1
- package/dist/services/TTSService.js +88 -35
- package/dist/services/ToolCoordinator.d.ts +1 -7
- package/dist/services/ToolCoordinator.js +1 -3
- package/dist/services/ToolRegistry.d.ts +13 -6
- package/dist/services/ToolRegistry.js +19 -7
- package/dist/services/ToolkitCoordinator.d.ts +110 -18
- package/dist/services/ToolkitCoordinator.js +273 -85
- package/dist/services/catalog-owner.d.ts +11 -0
- package/dist/services/catalog-owner.js +25 -0
- package/dist/services/create-tools-config.d.ts +2 -2
- package/dist/services/framework-error.d.ts +8 -1
- package/dist/services/interfaces.d.ts +9 -9
- package/dist/services/pnp-standard-features.d.ts +1 -1
- package/dist/services/section-controller-types.d.ts +15 -0
- package/dist/services/spoken-audio-cards.js +1 -1
- package/dist/services/tool-config-validation.d.ts +13 -2
- package/dist/services/tool-config-validation.js +33 -16
- package/dist/services/tool-context.js +29 -13
- package/dist/services/tool-providers/TTSToolProvider.d.ts +27 -65
- package/dist/services/tool-providers/TTSToolProvider.js +47 -9
- package/dist/services/tool-providers/ToolProviderRegistry.d.ts +4 -4
- package/dist/services/tool-providers/ToolProviderRegistry.js +4 -16
- package/dist/services/tool-providers/index.d.ts +0 -9
- package/dist/services/tool-providers/index.js +2 -4
- package/dist/services/tools-config-normalizer.d.ts +20 -1
- package/dist/services/tts/catalog-span-alignment.d.ts +2 -17
- package/dist/services/tts/catalog-span-alignment.js +17 -142
- package/dist/services/tts/generated-speech/types.d.ts +0 -12
- package/dist/services/tts/highlight-pipeline/boundary-normalizer.js +12 -62
- package/dist/services/tts/highlight-pipeline/create-highlight-plan.js +26 -1
- package/dist/services/tts/highlight-pipeline/normalize-speech-chunks.js +3 -6
- package/dist/services/tts/math-alignment/index.d.ts +0 -5
- package/dist/services/tts/math-alignment/index.js +5 -25
- package/dist/services/tts/math-alignment/speech-tokenizer.d.ts +9 -1
- package/dist/services/tts/math-alignment/speech-tokenizer.js +38 -36
- package/dist/services/tts/math-alignment/types.d.ts +4 -2
- package/dist/services/tts/math-aware-text-processing.js +44 -2
- package/dist/services/tts/math-speech.d.ts +5 -1
- package/dist/services/tts/math-speech.js +9 -6
- package/dist/services/tts/sre-engine.d.ts +7 -0
- package/dist/services/tts/sre-engine.js +11 -0
- package/dist/services/tts/sre-locales.d.ts +14 -0
- package/dist/services/tts/sre-locales.js +57 -0
- package/dist/services/tts/text-processing.d.ts +0 -1
- package/dist/services/tts/text-processing.js +0 -1
- package/dist/services/tts-runtime-config.d.ts +21 -3
- package/dist/services/tts-runtime-config.js +11 -3
- package/dist/tools/client.d.ts +1 -3
- package/dist/tools/client.js +1 -5
- package/dist/tools/internal.d.ts +6 -5
- package/dist/tools/internal.js +6 -8
- package/package.json +17 -36
- package/dist/components/chunks/ItemToolBar-byq80z42.js +0 -40
- package/dist/components/chunks/ItemToolBar-d36g3aw4.js +0 -49
- package/dist/services/ToolConfigResolver.d.ts +0 -161
- package/dist/services/ToolConfigResolver.js +0 -229
- package/dist/services/catalog-media.d.ts +0 -56
- package/dist/services/catalog-media.js +0 -190
- package/dist/services/createDefaultToolRegistry.d.ts +0 -53
- package/dist/services/createDefaultToolRegistry.js +0 -45
- package/dist/services/tool-providers/CortexToolProvider.d.ts +0 -13
- package/dist/services/tool-providers/CortexToolProvider.js +0 -32
- package/dist/services/tool-providers/DesmosToolProvider.d.ts +0 -14
- package/dist/services/tool-providers/DesmosToolProvider.js +0 -32
- package/dist/services/tool-providers/GeoGebraToolProvider.d.ts +0 -16
- package/dist/services/tool-providers/GeoGebraToolProvider.js +0 -32
- package/dist/services/tool-providers/LazyCalculatorToolProvider.d.ts +0 -35
- package/dist/services/tool-providers/LazyCalculatorToolProvider.js +0 -95
- package/dist/services/tts/visual-line-ranges.d.ts +0 -18
- package/dist/services/tts/visual-line-ranges.js +0 -226
- package/dist/tools/index.d.ts +0 -8
- package/dist/tools/index.js +0 -10
- package/dist/tools/response-discovery.d.ts +0 -61
- package/dist/tools/response-discovery.js +0 -113
- package/dist/tools/types.d.ts +0 -337
- package/dist/tools/types.js +0 -12
- package/dist/tools/variant-resolver.d.ts +0 -41
- package/dist/tools/variant-resolver.js +0 -207
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Response Discovery Service
|
|
3
|
-
* Finds and manages PIE response components for tool-to-response integration
|
|
4
|
-
*
|
|
5
|
-
* Enables tools (e.g., calculator) to insert content into response fields
|
|
6
|
-
* Based on capability-based interface pattern (inspired by VS Code extension API)
|
|
7
|
-
*/
|
|
8
|
-
export class ResponseDiscoveryServiceImpl {
|
|
9
|
-
responses = new Map();
|
|
10
|
-
activeResponseId = null;
|
|
11
|
-
activeResponseListeners = [];
|
|
12
|
-
/**
|
|
13
|
-
* Get currently active (focused) response component
|
|
14
|
-
*/
|
|
15
|
-
getActiveResponse() {
|
|
16
|
-
if (!this.activeResponseId) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return this.responses.get(this.activeResponseId) || null;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Get response by ID
|
|
23
|
-
*/
|
|
24
|
-
getResponse(responseId) {
|
|
25
|
-
return this.responses.get(responseId) || null;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Get all registered responses
|
|
29
|
-
*/
|
|
30
|
-
getAllResponses() {
|
|
31
|
-
return Array.from(this.responses.values());
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Get responses that accept a specific content format
|
|
35
|
-
*/
|
|
36
|
-
getResponsesAccepting(format) {
|
|
37
|
-
return this.getAllResponses().filter((response) => {
|
|
38
|
-
const capabilities = response.getCapabilities();
|
|
39
|
-
return capabilities.supportedFormats.includes(format);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Register a response component
|
|
44
|
-
*/
|
|
45
|
-
registerResponse(response) {
|
|
46
|
-
this.responses.set(response.responseId, response);
|
|
47
|
-
console.log(`[ResponseDiscovery] Registered response: ${response.responseId}`);
|
|
48
|
-
// If this is the first response and no active response, set it as active
|
|
49
|
-
if (!this.activeResponseId && this.responses.size === 1) {
|
|
50
|
-
this.setActiveResponse(response.responseId);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Unregister a response component
|
|
55
|
-
*/
|
|
56
|
-
unregisterResponse(responseId) {
|
|
57
|
-
this.responses.delete(responseId);
|
|
58
|
-
console.log(`[ResponseDiscovery] Unregistered response: ${responseId}`);
|
|
59
|
-
// If active response was removed, clear it
|
|
60
|
-
if (this.activeResponseId === responseId) {
|
|
61
|
-
this.setActiveResponse(null);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Explicitly signal that a registered response is active.
|
|
66
|
-
*/
|
|
67
|
-
signalActive(responseId) {
|
|
68
|
-
if (!this.responses.has(responseId)) {
|
|
69
|
-
console.warn(`[ResponseDiscovery] Cannot mark active: unknown response ${responseId}`);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
this.setActiveResponse(responseId);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Explicitly signal that a response is no longer active.
|
|
76
|
-
*/
|
|
77
|
-
signalInactive(responseId) {
|
|
78
|
-
if (this.activeResponseId !== responseId)
|
|
79
|
-
return;
|
|
80
|
-
this.setActiveResponse(null);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Set active response (internal use)
|
|
84
|
-
*/
|
|
85
|
-
setActiveResponse(responseId) {
|
|
86
|
-
if (this.activeResponseId === responseId)
|
|
87
|
-
return;
|
|
88
|
-
this.activeResponseId = responseId;
|
|
89
|
-
const response = responseId ? this.getResponse(responseId) : null;
|
|
90
|
-
// Notify listeners
|
|
91
|
-
for (const listener of this.activeResponseListeners) {
|
|
92
|
-
listener(response);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Listen for active response changes
|
|
97
|
-
*/
|
|
98
|
-
onActiveResponseChanged(listener) {
|
|
99
|
-
this.activeResponseListeners.push(listener);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Clear all responses (for cleanup)
|
|
103
|
-
*/
|
|
104
|
-
clear() {
|
|
105
|
-
this.responses.clear();
|
|
106
|
-
this.activeResponseId = null;
|
|
107
|
-
this.activeResponseListeners = [];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Singleton instance
|
|
112
|
-
*/
|
|
113
|
-
export const responseDiscovery = new ResponseDiscoveryServiceImpl();
|
package/dist/tools/types.d.ts
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool system type definitions
|
|
3
|
-
*/
|
|
4
|
-
export type { CalculationHistoryEntry, Calculator, CalculatorProvider, CalculatorProviderCapabilities, CalculatorProviderConfig, CalculatorState, CalculatorType, } from "@pie-players/pie-calculator";
|
|
5
|
-
export type ToolId = string;
|
|
6
|
-
export interface ToolState {
|
|
7
|
-
id: ToolId;
|
|
8
|
-
name: string;
|
|
9
|
-
isVisible: boolean;
|
|
10
|
-
isActive: boolean;
|
|
11
|
-
zIndex: number;
|
|
12
|
-
element?: HTMLElement;
|
|
13
|
-
}
|
|
14
|
-
export interface ToolPosition {
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
}
|
|
18
|
-
export interface ToolSize {
|
|
19
|
-
width: number;
|
|
20
|
-
height: number;
|
|
21
|
-
}
|
|
22
|
-
export interface ToolConfig {
|
|
23
|
-
id: ToolId;
|
|
24
|
-
name: string;
|
|
25
|
-
icon?: string;
|
|
26
|
-
enabled: boolean;
|
|
27
|
-
alwaysAvailable?: boolean;
|
|
28
|
-
}
|
|
29
|
-
export interface AssessmentToolConfig {
|
|
30
|
-
enabledTools: ToolId[];
|
|
31
|
-
toolSettings?: Record<ToolId, any>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Tool allowance: "0" = blocked, "1" = allowed
|
|
35
|
-
* Based on existing platform patterns
|
|
36
|
-
*/
|
|
37
|
-
export type ToolAllowance = "0" | "1";
|
|
38
|
-
/**
|
|
39
|
-
* Roster/Test-level tool configuration
|
|
40
|
-
* Defines default tool availability for an assessment
|
|
41
|
-
*/
|
|
42
|
-
export interface RosterToolConfiguration {
|
|
43
|
-
rosterId: string;
|
|
44
|
-
testId?: string;
|
|
45
|
-
toolAllowances: Record<string, ToolAllowance>;
|
|
46
|
-
defaultToolConfigs?: Record<string, ToolConfig>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Configuration source for tool resolution
|
|
50
|
-
*/
|
|
51
|
-
export type ConfigurationSource = "roster-block" | "item-restriction" | "item-requirement" | "student-accommodation" | "roster-default" | "system-default";
|
|
52
|
-
/**
|
|
53
|
-
* Resolved tool configuration with source tracking
|
|
54
|
-
*/
|
|
55
|
-
export interface ResolvedToolConfig extends ToolConfig {
|
|
56
|
-
resolvedFrom: ConfigurationSource;
|
|
57
|
-
required: boolean;
|
|
58
|
-
reason: string;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Tool resolution result
|
|
62
|
-
*/
|
|
63
|
-
export interface ToolResolutionResult {
|
|
64
|
-
allowed: boolean;
|
|
65
|
-
reason: string;
|
|
66
|
-
source: ConfigurationSource;
|
|
67
|
-
config?: ToolConfig;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Item-level tool configuration
|
|
71
|
-
*/
|
|
72
|
-
export interface ItemToolConfig {
|
|
73
|
-
itemId: string;
|
|
74
|
-
requiredTools?: string[];
|
|
75
|
-
restrictedTools?: string[];
|
|
76
|
-
toolParameters?: Record<string, ItemToolParameters>;
|
|
77
|
-
variantConfig?: ItemVariantConfig;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Item tool parameters
|
|
81
|
-
*/
|
|
82
|
-
export interface ItemToolParameters {
|
|
83
|
-
config?: Partial<ToolConfig>;
|
|
84
|
-
hint?: string;
|
|
85
|
-
preOpen?: boolean;
|
|
86
|
-
variants?: Record<string, ItemToolParametersVariant>;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Item tool parameters variant
|
|
90
|
-
*/
|
|
91
|
-
export interface ItemToolParametersVariant {
|
|
92
|
-
config?: Partial<ToolConfig>;
|
|
93
|
-
hint?: string;
|
|
94
|
-
preOpen?: boolean;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Item variant configuration for A/B testing and scaffolding
|
|
98
|
-
*/
|
|
99
|
-
export interface ItemVariantConfig {
|
|
100
|
-
variantId?: string;
|
|
101
|
-
toolOverrides?: Record<string, ItemToolOverride>;
|
|
102
|
-
adaptations?: ContentAdaptation[];
|
|
103
|
-
experimental?: Record<string, any>;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Tool override for item variants
|
|
107
|
-
*/
|
|
108
|
-
export interface ItemToolOverride {
|
|
109
|
-
config?: Partial<ToolConfig>;
|
|
110
|
-
uiVariant?: string;
|
|
111
|
-
parameters?: Record<string, any>;
|
|
112
|
-
replacementTool?: string;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Content adaptation types
|
|
116
|
-
*/
|
|
117
|
-
export interface ContentAdaptation {
|
|
118
|
-
type: "scaffolding" | "difficulty" | "language" | "modality" | "custom";
|
|
119
|
-
level: string | number;
|
|
120
|
-
affectedTools?: string[];
|
|
121
|
-
config?: Record<string, any>;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Variant context for resolution
|
|
125
|
-
*/
|
|
126
|
-
export interface VariantContext {
|
|
127
|
-
studentId: string;
|
|
128
|
-
sessionId: string;
|
|
129
|
-
language?: string;
|
|
130
|
-
scaffoldingLevel?: number;
|
|
131
|
-
difficultyLevel?: string;
|
|
132
|
-
custom?: Record<string, any>;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Resolved item configuration with variants applied
|
|
136
|
-
*/
|
|
137
|
-
export interface ResolvedItemConfig {
|
|
138
|
-
itemId: string;
|
|
139
|
-
requiredTools: string[];
|
|
140
|
-
restrictedTools: string[];
|
|
141
|
-
toolParameters: Record<string, ResolvedItemToolParameters>;
|
|
142
|
-
appliedVariant?: string;
|
|
143
|
-
appliedAdaptations?: ContentAdaptation[];
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Resolved item tool parameters
|
|
147
|
-
*/
|
|
148
|
-
export interface ResolvedItemToolParameters extends ItemToolParameters {
|
|
149
|
-
finalConfig: ToolConfig;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Base interface that all tool components should implement
|
|
153
|
-
*/
|
|
154
|
-
export interface Tool {
|
|
155
|
-
/** Unique identifier for this tool */
|
|
156
|
-
id: ToolId;
|
|
157
|
-
/** Display name */
|
|
158
|
-
name: string;
|
|
159
|
-
/** Show the tool */
|
|
160
|
-
show(): void;
|
|
161
|
-
/** Hide the tool */
|
|
162
|
-
hide(): void;
|
|
163
|
-
/** Toggle visibility */
|
|
164
|
-
toggle(): void;
|
|
165
|
-
/** Cleanup when tool is destroyed */
|
|
166
|
-
destroy?(): void;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Tool categories for organizational purposes
|
|
170
|
-
*/
|
|
171
|
-
export declare enum ToolCategory {
|
|
172
|
-
STANDALONE = "standalone",
|
|
173
|
-
CONTENT_INTERACTIVE = "content-interactive",
|
|
174
|
-
SERVICE_DEPENDENT = "service-dependent"
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Tool metadata
|
|
178
|
-
*/
|
|
179
|
-
export interface ToolMetadata {
|
|
180
|
-
id: ToolId;
|
|
181
|
-
name: string;
|
|
182
|
-
description: string;
|
|
183
|
-
category: ToolCategory;
|
|
184
|
-
icon?: string;
|
|
185
|
-
dependencies?: string[];
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Accommodation Resolver Service
|
|
189
|
-
* Resolves final tool configuration by merging roster, student, and item configs
|
|
190
|
-
* Precedence: Roster block > Item restriction > Item requirement > Student accommodation > Roster default
|
|
191
|
-
*/
|
|
192
|
-
export interface AccommodationResolver {
|
|
193
|
-
/**
|
|
194
|
-
* Resolve final tools for an item given all configuration sources
|
|
195
|
-
*/
|
|
196
|
-
resolveToolsForItem(student: AccommodationProfile, roster: RosterToolConfiguration, item: ItemToolConfig): ResolvedToolConfig[];
|
|
197
|
-
/**
|
|
198
|
-
* Check if a specific tool is allowed
|
|
199
|
-
*/
|
|
200
|
-
isToolAllowed(toolType: string, student: AccommodationProfile, roster: RosterToolConfiguration, item: ItemToolConfig): ToolResolutionResult;
|
|
201
|
-
/**
|
|
202
|
-
* Get resolution trace for debugging
|
|
203
|
-
*/
|
|
204
|
-
getResolutionTrace(toolType: string, student: AccommodationProfile, roster: RosterToolConfiguration, item: ItemToolConfig): ResolutionTrace;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Accommodation profile (student-level tool permissions)
|
|
208
|
-
*/
|
|
209
|
-
export interface AccommodationProfile {
|
|
210
|
-
studentId: string;
|
|
211
|
-
testId?: string;
|
|
212
|
-
rosterId?: string;
|
|
213
|
-
accommodations: Record<string, boolean>;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Resolution trace for debugging
|
|
217
|
-
*/
|
|
218
|
-
export interface ResolutionTrace {
|
|
219
|
-
toolType: string;
|
|
220
|
-
steps: ResolutionStep[];
|
|
221
|
-
finalDecision: ToolResolutionResult;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Resolution step in trace
|
|
225
|
-
*/
|
|
226
|
-
export interface ResolutionStep {
|
|
227
|
-
source: ConfigurationSource;
|
|
228
|
-
decision: "allow" | "block" | "require" | "skip";
|
|
229
|
-
reason: string;
|
|
230
|
-
config?: Partial<ToolConfig>;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Variant Resolver Service
|
|
234
|
-
* Resolves item configuration considering variants
|
|
235
|
-
*/
|
|
236
|
-
export interface VariantResolver {
|
|
237
|
-
/**
|
|
238
|
-
* Resolve variant configuration for an item
|
|
239
|
-
*/
|
|
240
|
-
resolveVariant(itemConfig: ItemToolConfig, context: VariantContext): ResolvedItemConfig;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* PIE Response Component Interface
|
|
244
|
-
* For tool-to-response integration (e.g., calculator inserting into text field)
|
|
245
|
-
*/
|
|
246
|
-
export interface PIEResponseComponent {
|
|
247
|
-
readonly responseId: string;
|
|
248
|
-
readonly responseType: PIEResponseType;
|
|
249
|
-
getCapabilities(): ResponseCapabilities;
|
|
250
|
-
canAccept(content: string, format: ContentFormat): boolean;
|
|
251
|
-
insertContent(content: string, options: InsertionOptions): Promise<InsertionResult>;
|
|
252
|
-
getContent(format?: ContentFormat): string;
|
|
253
|
-
getCursorPosition(): number | null;
|
|
254
|
-
setCursorPosition(position: number): void;
|
|
255
|
-
focus(): void;
|
|
256
|
-
isFocused(): boolean;
|
|
257
|
-
validate(content: string, format: ContentFormat): ValidationResult;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* PIE response types
|
|
261
|
-
*/
|
|
262
|
-
export type PIEResponseType = "text-entry" | "extended-text-entry" | "math-inline" | "math-block" | "numeric" | "multiple-choice" | "custom";
|
|
263
|
-
/**
|
|
264
|
-
* Response capabilities
|
|
265
|
-
*/
|
|
266
|
-
export interface ResponseCapabilities {
|
|
267
|
-
acceptsPlainText?: boolean;
|
|
268
|
-
acceptsLatex?: boolean;
|
|
269
|
-
acceptsNumeric?: boolean;
|
|
270
|
-
acceptsHtml?: boolean;
|
|
271
|
-
acceptsFormattedText?: boolean;
|
|
272
|
-
supportedFormats: ContentFormat[];
|
|
273
|
-
supportsReplacement?: boolean;
|
|
274
|
-
supportsInsertion?: boolean;
|
|
275
|
-
supportsAppend?: boolean;
|
|
276
|
-
maxLength?: number;
|
|
277
|
-
allowedCharacters?: string;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Content formats
|
|
281
|
-
*/
|
|
282
|
-
export type ContentFormat = "plain-text" | "latex" | "mathml" | "numeric" | "html" | "markdown" | "formatted-text";
|
|
283
|
-
/**
|
|
284
|
-
* Insertion options for response content
|
|
285
|
-
*/
|
|
286
|
-
export interface InsertionOptions {
|
|
287
|
-
mode: "replace" | "insert" | "append";
|
|
288
|
-
format: ContentFormat;
|
|
289
|
-
position?: number;
|
|
290
|
-
select?: boolean;
|
|
291
|
-
focus?: boolean;
|
|
292
|
-
source?: {
|
|
293
|
-
toolId: string;
|
|
294
|
-
toolType: string;
|
|
295
|
-
timestamp: number;
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Insertion result
|
|
300
|
-
*/
|
|
301
|
-
export interface InsertionResult {
|
|
302
|
-
success: boolean;
|
|
303
|
-
error?: string;
|
|
304
|
-
insertedLength?: number;
|
|
305
|
-
finalCursorPosition?: number;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Validation result
|
|
309
|
-
*/
|
|
310
|
-
export interface ValidationResult {
|
|
311
|
-
valid: boolean;
|
|
312
|
-
errors?: ValidationError[];
|
|
313
|
-
warnings?: string[];
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Validation error
|
|
317
|
-
*/
|
|
318
|
-
export interface ValidationError {
|
|
319
|
-
code: string;
|
|
320
|
-
message: string;
|
|
321
|
-
position?: number;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Response Discovery Service
|
|
325
|
-
* Finds and manages PIE response components for tool integration
|
|
326
|
-
*/
|
|
327
|
-
export interface ResponseDiscoveryService {
|
|
328
|
-
getActiveResponse(): PIEResponseComponent | null;
|
|
329
|
-
getResponse(responseId: string): PIEResponseComponent | null;
|
|
330
|
-
getAllResponses(): PIEResponseComponent[];
|
|
331
|
-
getResponsesAccepting(format: ContentFormat): PIEResponseComponent[];
|
|
332
|
-
registerResponse(response: PIEResponseComponent): void;
|
|
333
|
-
unregisterResponse(responseId: string): void;
|
|
334
|
-
signalActive(responseId: string): void;
|
|
335
|
-
signalInactive(responseId: string): void;
|
|
336
|
-
onActiveResponseChanged(listener: (response: PIEResponseComponent | null) => void): void;
|
|
337
|
-
}
|
package/dist/tools/types.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool system type definitions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Tool categories for organizational purposes
|
|
6
|
-
*/
|
|
7
|
-
export var ToolCategory;
|
|
8
|
-
(function (ToolCategory) {
|
|
9
|
-
ToolCategory["STANDALONE"] = "standalone";
|
|
10
|
-
ToolCategory["CONTENT_INTERACTIVE"] = "content-interactive";
|
|
11
|
-
ToolCategory["SERVICE_DEPENDENT"] = "service-dependent";
|
|
12
|
-
})(ToolCategory || (ToolCategory = {}));
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Variant Resolver Service
|
|
3
|
-
* Resolves item configuration considering variants for A/B testing, scaffolding, and adaptations
|
|
4
|
-
*
|
|
5
|
-
* Based on architectural enhancements for item-level variant configuration
|
|
6
|
-
*/
|
|
7
|
-
import type { ItemToolConfig, ResolvedItemConfig, VariantContext, VariantResolver } from "./types.js";
|
|
8
|
-
export declare class VariantResolverImpl implements VariantResolver {
|
|
9
|
-
/**
|
|
10
|
-
* Resolve variant configuration for an item
|
|
11
|
-
*/
|
|
12
|
-
resolveVariant(itemConfig: ItemToolConfig, context: VariantContext): ResolvedItemConfig;
|
|
13
|
-
/**
|
|
14
|
-
* Resolve tool parameters considering variant and context
|
|
15
|
-
*/
|
|
16
|
-
private _resolveToolParameters;
|
|
17
|
-
/**
|
|
18
|
-
* Select variant parameters based on context
|
|
19
|
-
*/
|
|
20
|
-
private _selectVariantParameters;
|
|
21
|
-
/**
|
|
22
|
-
* Create tool parameters from override
|
|
23
|
-
*/
|
|
24
|
-
private _createToolParametersFromOverride;
|
|
25
|
-
/**
|
|
26
|
-
* Resolve required tools considering overrides
|
|
27
|
-
*/
|
|
28
|
-
private _resolveRequiredTools;
|
|
29
|
-
/**
|
|
30
|
-
* Filter adaptations based on context
|
|
31
|
-
*/
|
|
32
|
-
private _filterAdaptations;
|
|
33
|
-
/**
|
|
34
|
-
* Build resolved config without variants
|
|
35
|
-
*/
|
|
36
|
-
private _buildResolvedConfig;
|
|
37
|
-
/**
|
|
38
|
-
* Convert tool type to human-readable name
|
|
39
|
-
*/
|
|
40
|
-
private _humanizeName;
|
|
41
|
-
}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Variant Resolver Service
|
|
3
|
-
* Resolves item configuration considering variants for A/B testing, scaffolding, and adaptations
|
|
4
|
-
*
|
|
5
|
-
* Based on architectural enhancements for item-level variant configuration
|
|
6
|
-
*/
|
|
7
|
-
export class VariantResolverImpl {
|
|
8
|
-
/**
|
|
9
|
-
* Resolve variant configuration for an item
|
|
10
|
-
*/
|
|
11
|
-
resolveVariant(itemConfig, context) {
|
|
12
|
-
// If no variant config, return item as-is
|
|
13
|
-
if (!itemConfig.variantConfig) {
|
|
14
|
-
return this._buildResolvedConfig(itemConfig, null, []);
|
|
15
|
-
}
|
|
16
|
-
const { variantConfig } = itemConfig;
|
|
17
|
-
const { variantId, toolOverrides, adaptations } = variantConfig;
|
|
18
|
-
// Apply tool overrides if variant specified
|
|
19
|
-
const resolvedToolParameters = {};
|
|
20
|
-
if (itemConfig.toolParameters) {
|
|
21
|
-
for (const [toolType, params] of Object.entries(itemConfig.toolParameters)) {
|
|
22
|
-
resolvedToolParameters[toolType] = this._resolveToolParameters(toolType, params, toolOverrides, context);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
// Apply tool overrides that aren't in original tool parameters
|
|
26
|
-
if (toolOverrides) {
|
|
27
|
-
for (const [toolType, override] of Object.entries(toolOverrides)) {
|
|
28
|
-
if (!resolvedToolParameters[toolType]) {
|
|
29
|
-
resolvedToolParameters[toolType] =
|
|
30
|
-
this._createToolParametersFromOverride(toolType, override);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// Build final resolved config
|
|
35
|
-
return {
|
|
36
|
-
itemId: itemConfig.itemId,
|
|
37
|
-
requiredTools: this._resolveRequiredTools(itemConfig, toolOverrides),
|
|
38
|
-
restrictedTools: itemConfig.restrictedTools || [],
|
|
39
|
-
toolParameters: resolvedToolParameters,
|
|
40
|
-
appliedVariant: variantId,
|
|
41
|
-
appliedAdaptations: this._filterAdaptations(adaptations, context),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Resolve tool parameters considering variant and context
|
|
46
|
-
*/
|
|
47
|
-
_resolveToolParameters(toolType, params, toolOverrides, context) {
|
|
48
|
-
// Start with base parameters
|
|
49
|
-
let finalConfig = params.config || {};
|
|
50
|
-
let finalHint = params.hint;
|
|
51
|
-
let finalPreOpen = params.preOpen;
|
|
52
|
-
// Apply variant-specific parameters if they exist
|
|
53
|
-
if (params.variants) {
|
|
54
|
-
const variantParams = this._selectVariantParameters(params.variants, context);
|
|
55
|
-
if (variantParams) {
|
|
56
|
-
finalConfig = { ...finalConfig, ...variantParams.config };
|
|
57
|
-
if (variantParams.hint !== undefined)
|
|
58
|
-
finalHint = variantParams.hint;
|
|
59
|
-
if (variantParams.preOpen !== undefined)
|
|
60
|
-
finalPreOpen = variantParams.preOpen;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// Apply tool override from variant config
|
|
64
|
-
if (toolOverrides && toolOverrides[toolType]) {
|
|
65
|
-
const override = toolOverrides[toolType];
|
|
66
|
-
if (override.config) {
|
|
67
|
-
finalConfig = { ...finalConfig, ...override.config };
|
|
68
|
-
}
|
|
69
|
-
if (override.parameters) {
|
|
70
|
-
// Merge additional parameters
|
|
71
|
-
finalConfig = { ...finalConfig, ...override.parameters };
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
config: params.config,
|
|
76
|
-
hint: finalHint,
|
|
77
|
-
preOpen: finalPreOpen,
|
|
78
|
-
variants: params.variants,
|
|
79
|
-
finalConfig: finalConfig,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Select variant parameters based on context
|
|
84
|
-
*/
|
|
85
|
-
_selectVariantParameters(variants, context) {
|
|
86
|
-
// Strategy: Select based on context properties
|
|
87
|
-
// 1. Check for scaffolding level match
|
|
88
|
-
if (context.scaffoldingLevel !== undefined) {
|
|
89
|
-
const scaffoldKey = `scaffolding-${context.scaffoldingLevel}`;
|
|
90
|
-
if (variants[scaffoldKey])
|
|
91
|
-
return variants[scaffoldKey];
|
|
92
|
-
}
|
|
93
|
-
// 2. Check for difficulty level match
|
|
94
|
-
if (context.difficultyLevel) {
|
|
95
|
-
const difficultyKey = `difficulty-${context.difficultyLevel}`;
|
|
96
|
-
if (variants[difficultyKey])
|
|
97
|
-
return variants[difficultyKey];
|
|
98
|
-
}
|
|
99
|
-
// 3. Check for language match
|
|
100
|
-
if (context.language) {
|
|
101
|
-
const langKey = `lang-${context.language}`;
|
|
102
|
-
if (variants[langKey])
|
|
103
|
-
return variants[langKey];
|
|
104
|
-
}
|
|
105
|
-
// 4. Check custom context keys
|
|
106
|
-
if (context.custom) {
|
|
107
|
-
for (const [key, value] of Object.entries(context.custom)) {
|
|
108
|
-
const customKey = `${key}-${value}`;
|
|
109
|
-
if (variants[customKey])
|
|
110
|
-
return variants[customKey];
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
// 5. Check for default variant
|
|
114
|
-
if (variants.default)
|
|
115
|
-
return variants.default;
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Create tool parameters from override
|
|
120
|
-
*/
|
|
121
|
-
_createToolParametersFromOverride(toolType, override) {
|
|
122
|
-
return {
|
|
123
|
-
config: override.config,
|
|
124
|
-
hint: override.hint,
|
|
125
|
-
preOpen: override.preOpen,
|
|
126
|
-
finalConfig: {
|
|
127
|
-
id: toolType,
|
|
128
|
-
name: this._humanizeName(toolType),
|
|
129
|
-
enabled: true,
|
|
130
|
-
...override.config,
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Resolve required tools considering overrides
|
|
136
|
-
*/
|
|
137
|
-
_resolveRequiredTools(itemConfig, toolOverrides) {
|
|
138
|
-
const required = new Set(itemConfig.requiredTools || []);
|
|
139
|
-
// Add tools that have replacements via overrides
|
|
140
|
-
if (toolOverrides) {
|
|
141
|
-
for (const [toolType, override] of Object.entries(toolOverrides)) {
|
|
142
|
-
if (override.replacementTool) {
|
|
143
|
-
required.delete(toolType);
|
|
144
|
-
required.add(override.replacementTool);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return Array.from(required);
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Filter adaptations based on context
|
|
152
|
-
*/
|
|
153
|
-
_filterAdaptations(adaptations, context) {
|
|
154
|
-
if (!adaptations)
|
|
155
|
-
return [];
|
|
156
|
-
return adaptations.filter((adaptation) => {
|
|
157
|
-
// Check if adaptation matches context
|
|
158
|
-
if (adaptation.type === "scaffolding" &&
|
|
159
|
-
context.scaffoldingLevel !== undefined) {
|
|
160
|
-
return adaptation.level === context.scaffoldingLevel;
|
|
161
|
-
}
|
|
162
|
-
if (adaptation.type === "difficulty" && context.difficultyLevel) {
|
|
163
|
-
return adaptation.level === context.difficultyLevel;
|
|
164
|
-
}
|
|
165
|
-
if (adaptation.type === "language" && context.language) {
|
|
166
|
-
return adaptation.level === context.language;
|
|
167
|
-
}
|
|
168
|
-
// Include custom adaptations by default
|
|
169
|
-
return true;
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Build resolved config without variants
|
|
174
|
-
*/
|
|
175
|
-
_buildResolvedConfig(itemConfig, variantId, adaptations) {
|
|
176
|
-
const resolvedToolParameters = {};
|
|
177
|
-
if (itemConfig.toolParameters) {
|
|
178
|
-
for (const [toolType, params] of Object.entries(itemConfig.toolParameters)) {
|
|
179
|
-
resolvedToolParameters[toolType] = {
|
|
180
|
-
...params,
|
|
181
|
-
finalConfig: {
|
|
182
|
-
id: toolType,
|
|
183
|
-
name: this._humanizeName(toolType),
|
|
184
|
-
enabled: true,
|
|
185
|
-
...params.config,
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
itemId: itemConfig.itemId,
|
|
192
|
-
requiredTools: itemConfig.requiredTools || [],
|
|
193
|
-
restrictedTools: itemConfig.restrictedTools || [],
|
|
194
|
-
toolParameters: resolvedToolParameters,
|
|
195
|
-
appliedVariant: variantId || undefined,
|
|
196
|
-
appliedAdaptations: adaptations,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Convert tool type to human-readable name
|
|
201
|
-
*/
|
|
202
|
-
_humanizeName(toolType) {
|
|
203
|
-
return toolType
|
|
204
|
-
.replace(/[-_]/g, " ")
|
|
205
|
-
.replace(/\b\w/g, (char) => char.toUpperCase());
|
|
206
|
-
}
|
|
207
|
-
}
|