UNPKG

@mastra/core

Version:
1 lines • 38.6 kB
{"version":3,"file":"index.cjs","names":["MastraBase","getOrCreateSpan","EntityType","resolveCurrentSpan","retryWithExponentialBackoff","APICallError","DecisionUnsupportedQuestionTypeError"],"sources":["../../src/classifier/index.ts"],"sourcesContent":["import { retryWithExponentialBackoff } from '@ai-sdk/provider-utils-v7';\nimport {\n APICallError,\n Experimental_DecisionUnsupportedQuestionTypeError as DecisionUnsupportedQuestionTypeError,\n} from '@ai-sdk/provider-v7';\nimport type {\n Experimental_DecisionModelV4 as DecisionModelV4,\n Experimental_DecisionModelV4Answer as DecisionModelV4Answer,\n Experimental_DecisionModelV4CallOptions as DecisionModelV4CallOptions,\n Experimental_DecisionModelV4Input as DecisionModelV4Input,\n Experimental_DecisionModelV4Question as DecisionModelV4Question,\n Experimental_DecisionModelV4Result as DecisionModelV4Result,\n Experimental_DecisionModelV4State as DecisionModelV4State,\n Experimental_EvaluationModelV4 as EvaluationModelV4,\n SharedV4ProviderMetadata,\n SharedV4ProviderOptions,\n SharedV4Warning,\n} from '@ai-sdk/provider-v7';\n\nimport { MastraBase } from '../base';\nimport type { Mastra } from '../mastra';\nimport { EntityType, SpanType } from '../observability/types';\nimport { getOrCreateSpan, resolveCurrentSpan } from '../observability/utils';\n\nexport type ClassifierState = DecisionModelV4Input;\nexport type DecisionModelResult = DecisionModelV4Result;\n/** @deprecated Use `DecisionModelResult` instead. */\nexport type EvaluationModelResult = DecisionModelResult;\n\n/**\n * A model accepted by `Classifier`: an AI SDK decision model (`doDecide`), or a\n * legacy evaluation model (`doEvaluate`) kept for backwards compatibility.\n */\nexport type ClassifierModel = DecisionModelV4 | EvaluationModelV4;\n\nexport interface MastraDecisionModelInterface {\n readonly specificationVersion: 'v4';\n readonly provider: string;\n readonly modelId: string;\n readonly supportedQuestionTypes: DecisionModelV4['supportedQuestionTypes'];\n doDecide(options: DecisionModelV4CallOptions): Promise<DecisionModelResult>;\n /** @deprecated Use `doDecide` instead. */\n doEvaluate(options: DecisionModelV4CallOptions): Promise<DecisionModelResult>;\n}\n\n/** @deprecated Use `MastraDecisionModelInterface` instead. */\nexport interface MastraEvaluationModelInterface extends Omit<MastraDecisionModelInterface, 'doDecide'> {}\n\nexport class MastraDecisionModel extends MastraBase implements MastraDecisionModelInterface {\n readonly specificationVersion = 'v4' as const;\n readonly provider: string;\n readonly modelId: string;\n readonly supportedQuestionTypes: DecisionModelV4['supportedQuestionTypes'];\n readonly #model: ClassifierModel;\n\n constructor(model: ClassifierModel) {\n super({ name: 'decision-model' });\n this.#model = model;\n this.provider = model.provider;\n this.modelId = model.modelId;\n this.supportedQuestionTypes = model.supportedQuestionTypes;\n }\n\n async doDecide(options: DecisionModelV4CallOptions): Promise<DecisionModelResult> {\n const model = this.#model;\n const result = 'doDecide' in model ? await model.doDecide(options) : await model.doEvaluate(options);\n return this.transformResult(result);\n }\n\n /** @deprecated Use `doDecide` instead. */\n doEvaluate(options: DecisionModelV4CallOptions): Promise<DecisionModelResult> {\n return this.doDecide(options);\n }\n\n protected transformResult(result: DecisionModelResult): DecisionModelResult {\n return result;\n }\n}\n\n/** @deprecated Use `MastraDecisionModel` instead. `MastraEvaluationModel` will be removed in a future release. */\nexport class MastraEvaluationModel extends MastraDecisionModel {}\n\nexport type ChoiceQuestion<\n CRITERIA extends Readonly<Record<string, DecisionModelV4Input | null>> = Readonly<\n Record<string, DecisionModelV4Input | null>\n >,\n> = {\n readonly type: 'choice';\n readonly instructions?: DecisionModelV4Input;\n readonly criteria: CRITERIA;\n};\n\nexport type ScoreQuestion<\n CRITERIA extends readonly (DecisionModelV4Input | null)[] = readonly (DecisionModelV4Input | null)[],\n> = {\n readonly type: 'score';\n readonly instructions?: DecisionModelV4Input;\n readonly criteria: CRITERIA;\n};\n\nexport type BooleanQuestion = {\n readonly type: 'boolean';\n readonly instructions?: DecisionModelV4Input;\n readonly criteria?: {\n readonly true?: DecisionModelV4Input | null;\n readonly false?: DecisionModelV4Input | null;\n };\n};\n\nexport type ClassifierQuestion = ChoiceQuestion | ScoreQuestion | BooleanQuestion;\nexport type ClassifierQuestions = Readonly<Record<string, ClassifierQuestion>>;\n\nexport type ChoiceAnswer<OPTION extends string = string> = {\n type: 'choice';\n choice: OPTION;\n probabilities?: Record<OPTION, number>;\n};\n\nexport type ScoreAnswer = {\n type: 'score';\n score: number;\n probabilities?: Record<string, number>;\n};\n\nexport type BooleanAnswer = {\n type: 'boolean';\n probability: number;\n};\n\n/**\n * The decision model declined to answer the question. Valid for any question type.\n *\n * The answer fields are typed as absent so equality checks such as\n * `answers.route.choice === 'billing'` keep compiling and evaluate to `false` on a refusal.\n */\nexport type RefusalAnswer = {\n type: 'refusal';\n choice?: never;\n score?: never;\n probability?: never;\n probabilities?: never;\n};\n\nexport type ClassifierAnswer<QUESTION extends ClassifierQuestion> = QUESTION extends {\n type: 'choice';\n criteria: infer CRITERIA extends Readonly<Record<string, DecisionModelV4Input | null>>;\n}\n ? ChoiceAnswer<Extract<keyof CRITERIA, string>> | RefusalAnswer\n : QUESTION extends { type: 'score' }\n ? ScoreAnswer | RefusalAnswer\n : QUESTION extends { type: 'boolean' }\n ? BooleanAnswer | RefusalAnswer\n : never;\n\nexport type ClassifierAnswers<QUESTIONS extends ClassifierQuestions> = {\n -readonly [KEY in keyof QUESTIONS]: ClassifierAnswer<QUESTIONS[KEY]>;\n};\n\nexport type ClassifierUsage = {\n inputTokens?: number;\n outputTokens?: number;\n totalTokens: number;\n};\n\nexport type ClassifierResult<QUESTIONS extends ClassifierQuestions> = {\n answers: ClassifierAnswers<QUESTIONS>;\n usage: ClassifierUsage;\n warnings: SharedV4Warning[];\n rounding?: {\n probabilityDecimals?: number;\n scoreDecimals?: number;\n };\n providerMetadata?: SharedV4ProviderMetadata;\n response: {\n id?: string;\n timestamp: Date;\n modelId: string;\n headers?: Record<string, string | undefined>;\n body?: unknown;\n };\n};\n\n/** Ids of the run a classifier decision belongs to. Each one is set only when the caller knows it. */\nexport type ClassifierDecisionIds = {\n runId?: string;\n threadId?: string;\n resourceId?: string;\n messageId?: string;\n traceId?: string;\n spanId?: string;\n};\n\n/**\n * A classifier call and its result, as passed to audit callbacks such as `ClassifierProcessor`'s `onDecision`.\n * `result` is set when the classifier answered and `error` when the call failed.\n */\nexport type ClassifierDecision<QUESTIONS extends ClassifierQuestions> = {\n classifierId: string;\n /** The state sent to the classifier. */\n state: ClassifierState;\n /** Time spent in the classifier call, including retries. */\n durationMs: number;\n ids: ClassifierDecisionIds;\n} & (ClassifierDecisionSuccess<QUESTIONS> | ClassifierDecisionError);\n\n/** A successful classifier decision, containing the result and no error. */\ntype ClassifierDecisionSuccess<QUESTIONS extends ClassifierQuestions> = {\n result: ClassifierResult<QUESTIONS>;\n error?: never;\n};\n\n/** A failed classifier decision, containing the error and no result. */\ntype ClassifierDecisionError = {\n result?: never;\n error: unknown;\n};\n\ntype CommonDecideOptions = {\n state: ClassifierState;\n abortSignal?: AbortSignal;\n providerOptions?: SharedV4ProviderOptions;\n maxRetries?: number;\n};\n\nexport type ConfiguredClassifierDecideOptions = CommonDecideOptions & {\n questions?: never;\n};\n\nexport type PerCallClassifierDecideOptions<QUESTIONS extends ClassifierQuestions> = CommonDecideOptions & {\n questions: QUESTIONS;\n};\n\n/** @deprecated Use `ConfiguredClassifierDecideOptions` instead. */\nexport type ConfiguredClassifierEvaluateOptions = ConfiguredClassifierDecideOptions;\n/** @deprecated Use `PerCallClassifierDecideOptions` instead. */\nexport type PerCallClassifierEvaluateOptions<QUESTIONS extends ClassifierQuestions> =\n PerCallClassifierDecideOptions<QUESTIONS>;\n\nexport type ConfiguredClassifierOptions<QUESTIONS extends ClassifierQuestions> = {\n id: string;\n model: ClassifierModel | MastraDecisionModel;\n questions: QUESTIONS;\n};\n\nexport type PerCallClassifierOptions = {\n id: string;\n model: ClassifierModel | MastraDecisionModel;\n questions?: never;\n};\n\nexport interface ClassifierInterface<CONFIGURED_QUESTIONS extends ClassifierQuestions | undefined = undefined> {\n readonly id: string;\n readonly model: MastraDecisionModelInterface;\n readonly questions: CONFIGURED_QUESTIONS;\n decide(\n options: CONFIGURED_QUESTIONS extends ClassifierQuestions ? ConfiguredClassifierDecideOptions : never,\n ): Promise<CONFIGURED_QUESTIONS extends ClassifierQuestions ? ClassifierResult<CONFIGURED_QUESTIONS> : never>;\n decide<const QUESTIONS extends ClassifierQuestions>(\n options: CONFIGURED_QUESTIONS extends undefined ? PerCallClassifierDecideOptions<QUESTIONS> : never,\n ): Promise<ClassifierResult<QUESTIONS>>;\n /** @deprecated Use `decide` instead. */\n evaluate(\n options: CONFIGURED_QUESTIONS extends ClassifierQuestions ? ConfiguredClassifierDecideOptions : never,\n ): Promise<CONFIGURED_QUESTIONS extends ClassifierQuestions ? ClassifierResult<CONFIGURED_QUESTIONS> : never>;\n /** @deprecated Use `decide` instead. */\n evaluate<const QUESTIONS extends ClassifierQuestions>(\n options: CONFIGURED_QUESTIONS extends undefined ? PerCallClassifierDecideOptions<QUESTIONS> : never,\n ): Promise<ClassifierResult<QUESTIONS>>;\n}\n\nexport class Classifier<CONFIGURED_QUESTIONS extends ClassifierQuestions | undefined = undefined>\n extends MastraBase\n implements ClassifierInterface<CONFIGURED_QUESTIONS>\n{\n readonly id: string;\n readonly model: MastraDecisionModel;\n readonly questions: CONFIGURED_QUESTIONS;\n #mastra?: Mastra;\n\n constructor(\n options: CONFIGURED_QUESTIONS extends ClassifierQuestions\n ? ConfiguredClassifierOptions<CONFIGURED_QUESTIONS>\n : PerCallClassifierOptions,\n ) {\n super({ name: options.id });\n\n if (typeof options.id !== 'string' || options.id.trim().length === 0) {\n throw new TypeError('Classifier id must be a non-empty string.');\n }\n\n this.id = options.id;\n this.model = options.model instanceof MastraDecisionModel ? options.model : new MastraDecisionModel(options.model);\n this.questions = options.questions as CONFIGURED_QUESTIONS;\n\n if (this.questions !== undefined) {\n validateQuestions(this.questions, this.model);\n }\n }\n\n /**\n * Internal: called by `Mastra.addClassifier()` so evaluations can start root spans\n * through the registered observability instance when no span is active.\n */\n __registerMastra(mastra: Mastra): void {\n this.#mastra = mastra;\n }\n\n /** @deprecated Use `decide` instead. `evaluate` will be removed in a future release. */\n async evaluate(\n options: CONFIGURED_QUESTIONS extends ClassifierQuestions ? ConfiguredClassifierDecideOptions : never,\n ): Promise<CONFIGURED_QUESTIONS extends ClassifierQuestions ? ClassifierResult<CONFIGURED_QUESTIONS> : never>;\n /** @deprecated Use `decide` instead. `evaluate` will be removed in a future release. */\n async evaluate<const QUESTIONS extends ClassifierQuestions>(\n options: CONFIGURED_QUESTIONS extends undefined ? PerCallClassifierDecideOptions<QUESTIONS> : never,\n ): Promise<ClassifierResult<QUESTIONS>>;\n async evaluate(\n options: ConfiguredClassifierDecideOptions | PerCallClassifierDecideOptions<ClassifierQuestions>,\n ): Promise<ClassifierResult<ClassifierQuestions>> {\n return this.decide(options as never);\n }\n\n async decide(\n options: CONFIGURED_QUESTIONS extends ClassifierQuestions ? ConfiguredClassifierDecideOptions : never,\n ): Promise<CONFIGURED_QUESTIONS extends ClassifierQuestions ? ClassifierResult<CONFIGURED_QUESTIONS> : never>;\n async decide<const QUESTIONS extends ClassifierQuestions>(\n options: CONFIGURED_QUESTIONS extends undefined ? PerCallClassifierDecideOptions<QUESTIONS> : never,\n ): Promise<ClassifierResult<QUESTIONS>>;\n async decide(\n options: ConfiguredClassifierDecideOptions | PerCallClassifierDecideOptions<ClassifierQuestions>,\n ): Promise<ClassifierResult<ClassifierQuestions>> {\n const questions = this.questions ?? ('questions' in options ? options.questions : undefined);\n if (questions === undefined) {\n throw new TypeError('Questions are required when the classifier is constructed without questions.');\n }\n\n validateState(options.state);\n validateQuestions(questions, this.model);\n validateMaxRetries(options.maxRetries);\n options.abortSignal?.throwIfAborted();\n\n const providerQuestions = toProviderQuestions(questions);\n const questionTypes = [...new Set(Object.values(questions).map(question => question.type))];\n const span = getOrCreateSpan({\n type: SpanType.CLASSIFIER_EVALUATION,\n name: `classifier evaluate: '${this.id}'`,\n entityType: EntityType.CLASSIFIER,\n entityId: this.id,\n entityName: this.name ?? this.id,\n tracingContext: { currentSpan: resolveCurrentSpan() },\n mastra: this.#mastra,\n input: { state: options.state, questions },\n attributes: {\n classifierId: this.id,\n modelId: this.model.modelId,\n provider: this.model.provider,\n questionCount: Object.keys(questions).length,\n questionTypes,\n maxRetries: options.maxRetries ?? 2,\n },\n });\n\n const startedAt = Date.now();\n let attemptCount = 0;\n\n try {\n const retry = retryWithExponentialBackoff({\n maxRetries: options.maxRetries ?? 2,\n abortSignal: options.abortSignal,\n shouldRetry: error => APICallError.isInstance(error) && error.isRetryable,\n });\n // The last provider error is kept so it can be restored below.\n let lastProviderError: unknown;\n let providerResult: DecisionModelResult;\n try {\n providerResult = await retry(async () => {\n options.abortSignal?.throwIfAborted();\n attemptCount += 1;\n try {\n const callOptions = {\n state: toProviderState(options.state),\n questions: providerQuestions,\n abortSignal: options.abortSignal,\n providerOptions: options.providerOptions,\n };\n // Subclasses written before doDecide existed may override doEvaluate; keep honoring them.\n return this.model.doEvaluate !== MastraDecisionModel.prototype.doEvaluate\n ? await this.model.doEvaluate(callOptions)\n : await this.model.doDecide(callOptions);\n } catch (error) {\n lastProviderError = error;\n throw error;\n }\n });\n } catch (error) {\n if (options.abortSignal?.aborted) {\n throw options.abortSignal.reason;\n }\n\n // When retries are exhausted the helper reports a generic retry error,\n // which drops `APICallError.isInstance` and `isRetryable`. Core reads\n // both for control flow, so the provider's own error is rethrown.\n if (lastProviderError !== undefined && !APICallError.isInstance(error)) throw lastProviderError;\n throw error;\n }\n\n options.abortSignal?.throwIfAborted();\n validateProviderResult(questions, providerResult.answers, providerResult.rounding);\n validateProviderEnvelope(providerResult);\n\n const inputTokens = providerResult.usage?.inputTokens;\n const outputTokens = providerResult.usage?.outputTokens;\n const result: ClassifierResult<ClassifierQuestions> = {\n answers: providerResult.answers,\n usage: {\n inputTokens,\n outputTokens,\n totalTokens: (inputTokens ?? 0) + (outputTokens ?? 0),\n },\n warnings: providerResult.warnings,\n rounding: providerResult.rounding,\n providerMetadata: providerResult.providerMetadata,\n response: {\n ...providerResult.response,\n timestamp: providerResult.response?.timestamp ?? new Date(),\n modelId: providerResult.response?.modelId ?? this.model.modelId,\n },\n };\n\n span?.update({\n attributes: {\n attemptCount,\n retryCount: attemptCount - 1,\n durationMs: Date.now() - startedAt,\n usage: {\n inputTokens: result.usage.inputTokens,\n outputTokens: result.usage.outputTokens,\n },\n },\n });\n span?.end({ output: { answers: result.answers } });\n return result;\n } catch (error) {\n span?.update({\n attributes: {\n attemptCount,\n retryCount: Math.max(0, attemptCount - 1),\n durationMs: Date.now() - startedAt,\n errorType: error instanceof Error ? error.name : typeof error,\n },\n });\n span?.error({\n error: error instanceof Error ? error : new Error(String(error)),\n endSpan: true,\n });\n throw error;\n }\n }\n}\n\n// Mirrors the AI SDK's decide(): providers receive state as an array of parts.\nfunction toProviderState(state: ClassifierState): DecisionModelV4State {\n if (typeof state === 'string') return [{ type: 'text', text: state }];\n if (Array.isArray(state) && state.every(isStatePart)) return state;\n return [{ type: 'json', value: state }];\n}\n\nfunction isStatePart(value: unknown): value is DecisionModelV4State[number] {\n return isPlainObject(value) && (value.type === 'text' || value.type === 'file' || value.type === 'json');\n}\n\nfunction toProviderQuestions(questions: ClassifierQuestions): Readonly<Record<string, DecisionModelV4Question>> {\n return Object.fromEntries(\n Object.entries(questions).map(([questionId, question]) => [\n questionId,\n {\n ...question,\n instructions: question.instructions ?? questionId,\n },\n ]),\n );\n}\n\nfunction validateMaxRetries(maxRetries: number | undefined): void {\n if (maxRetries !== undefined && (!Number.isInteger(maxRetries) || maxRetries < 0)) {\n throw new TypeError('maxRetries must be a non-negative integer.');\n }\n}\n\nfunction validateState(state: unknown): asserts state is ClassifierState {\n validateJsonValue(state, 'state');\n}\n\nfunction validateQuestions(questions: ClassifierQuestions, model: MastraDecisionModelInterface): void {\n if (!isPlainObject(questions) || Object.keys(questions).length === 0) {\n throw new TypeError('Questions must be a non-empty object.');\n }\n\n for (const [questionId, question] of Object.entries(questions)) {\n if (questionId.length === 0) {\n throw new TypeError('Question ids must be non-empty strings.');\n }\n if (!isPlainObject(question) || !['choice', 'score', 'boolean'].includes(question.type as string)) {\n throw new TypeError(`Question '${questionId}' has an invalid type.`);\n }\n if (!model.supportedQuestionTypes.includes(question.type)) {\n throw new DecisionUnsupportedQuestionTypeError({\n questionId,\n questionType: question.type,\n provider: model.provider,\n modelId: model.modelId,\n });\n }\n\n if (question.instructions !== undefined) {\n validateJsonValue(question.instructions, `Question '${questionId}' instructions`);\n }\n\n if (question.type === 'choice') {\n if (!isPlainObject(question.criteria) || Object.keys(question.criteria).length === 0) {\n throw new TypeError(`Choice question '${questionId}' criteria must be a non-empty object.`);\n }\n for (const [choice, description] of Object.entries(question.criteria)) {\n if (choice.length === 0) {\n throw new TypeError(`Choice question '${questionId}' option names must be non-empty.`);\n }\n if (description !== null)\n validateJsonValue(description, `Choice question '${questionId}' criterion '${choice}'`);\n }\n } else if (question.type === 'score') {\n if (!Array.isArray(question.criteria) || question.criteria.length < 2) {\n throw new TypeError(`Score question '${questionId}' criteria must contain at least two levels.`);\n }\n // Indexed rather than `forEach`, which skips holes: `new Array(2)` has the\n // required length but no rubric levels, and would otherwise reach the model.\n for (let index = 0; index < question.criteria.length; index++) {\n const description = question.criteria[index];\n if (!(index in question.criteria) || description === undefined) {\n throw new TypeError(`Score question '${questionId}' criterion ${index} is missing.`);\n }\n if (description !== null) validateJsonValue(description, `Score question '${questionId}' criterion ${index}`);\n }\n } else if (question.criteria !== undefined) {\n if (!isPlainObject(question.criteria)) {\n throw new TypeError(`Boolean question '${questionId}' criteria must be an object.`);\n }\n for (const key of Object.keys(question.criteria)) {\n if (key !== 'true' && key !== 'false') {\n throw new TypeError(`Boolean question '${questionId}' criteria may only contain true and false.`);\n }\n }\n for (const [key, description] of Object.entries(question.criteria)) {\n if (description !== null && description !== undefined) {\n validateJsonValue(description, `Boolean question '${questionId}' criterion '${key}'`);\n }\n }\n }\n }\n}\n\n/**\n * Check the parts of the provider result that surround the answers.\n *\n * These fields are declared by the provider interface but not guaranteed by it.\n * A non-numeric token count would otherwise turn `totalTokens` into a string or\n * `NaN`, and a non-`Date` timestamp would reach callers typed as a `Date`.\n */\nfunction validateProviderEnvelope(result: {\n usage?: { inputTokens?: number; outputTokens?: number };\n warnings?: unknown;\n response?: { timestamp?: unknown };\n}): void {\n for (const field of ['inputTokens', 'outputTokens'] as const) {\n const value = result.usage?.[field];\n if (value !== undefined && (typeof value !== 'number' || !Number.isFinite(value))) {\n throw new TypeError(`The evaluation model returned a non-numeric '${field}' token count.`);\n }\n }\n if (result.warnings !== undefined && !Array.isArray(result.warnings)) {\n throw new TypeError('The evaluation model returned warnings that are not an array.');\n }\n const timestamp = result.response?.timestamp;\n if (timestamp !== undefined && !(timestamp instanceof Date)) {\n throw new TypeError('The evaluation model returned a response timestamp that is not a Date.');\n }\n}\n\nfunction validateProviderResult(\n questions: ClassifierQuestions,\n answers: Record<string, DecisionModelV4Answer>,\n rounding?: { probabilityDecimals?: number; scoreDecimals?: number },\n): asserts answers is ClassifierAnswers<ClassifierQuestions> {\n if (!isPlainObject(answers)) throw new TypeError('The evaluation model returned invalid answers.');\n const questionIds = Object.keys(questions);\n const answerIds = Object.keys(answers);\n if (answerIds.length !== questionIds.length || answerIds.some(id => !(id in questions))) {\n throw new TypeError('The evaluation model must return exactly one answer per question.');\n }\n\n validateRounding(rounding);\n const probabilityTolerance =\n rounding?.probabilityDecimals === undefined ? 1e-6 : 0.5 * 10 ** -rounding.probabilityDecimals;\n const scoreTolerance = rounding?.scoreDecimals === undefined ? 1e-6 : 0.5 * 10 ** -rounding.scoreDecimals;\n\n for (const questionId of questionIds) {\n const question = questions[questionId]!;\n const answer = answers[questionId]!;\n if (!isPlainObject(answer)) {\n throw new TypeError(`Answer '${questionId}' does not match its question type.`);\n }\n if (answer.type === 'refusal') {\n if (['choice', 'score', 'probability', 'probabilities'].some(field => field in answer)) {\n throw new TypeError(`Refusal answer '${questionId}' must not include answer fields.`);\n }\n continue;\n }\n if (answer.type !== question.type) {\n throw new TypeError(`Answer '${questionId}' does not match its question type.`);\n }\n\n if (answer.type === 'boolean') {\n validateProbability(answer.probability, `Boolean answer '${questionId}' probability`);\n continue;\n }\n\n if (answer.type === 'choice') {\n const choices = Object.keys((question as Extract<ClassifierQuestion, { type: 'choice' }>).criteria);\n if (!choices.includes(answer.choice)) {\n throw new TypeError(`Choice answer '${questionId}' selected an unknown option.`);\n }\n if (answer.probabilities !== undefined) {\n validateDistribution(answer.probabilities, choices, probabilityTolerance, questionId);\n const maximum = Math.max(...Object.values(answer.probabilities as Record<string, number>));\n if (answer.probabilities[answer.choice]! < maximum - probabilityTolerance) {\n throw new TypeError(`Choice answer '${questionId}' is not a highest-probability option.`);\n }\n }\n continue;\n }\n\n const levelCount = (question as Extract<ClassifierQuestion, { type: 'score' }>).criteria.length;\n if (!Number.isFinite(answer.score) || answer.score < 0 || answer.score > levelCount - 1) {\n throw new TypeError(`Score answer '${questionId}' is outside the question range.`);\n }\n if (answer.probabilities !== undefined) {\n const levels = Array.from({ length: levelCount }, (_, index) => String(index));\n validateDistribution(answer.probabilities, levels, probabilityTolerance, questionId);\n const mean = levels.reduce((sum, level) => sum + Number(level) * answer.probabilities![level]!, 0);\n if (Math.abs(mean - answer.score) > scoreTolerance + levelCount * probabilityTolerance) {\n throw new TypeError(`Score answer '${questionId}' does not match its probability-weighted mean.`);\n }\n }\n }\n}\n\nfunction validateRounding(rounding: { probabilityDecimals?: number; scoreDecimals?: number } | undefined): void {\n if (rounding === undefined) return;\n if (!isPlainObject(rounding)) throw new TypeError('Evaluation rounding metadata must be an object.');\n for (const [name, value] of Object.entries(rounding)) {\n if ((name !== 'probabilityDecimals' && name !== 'scoreDecimals') || !Number.isInteger(value) || value < 0) {\n throw new TypeError('Evaluation rounding precision must use non-negative integer decimal counts.');\n }\n }\n}\n\nfunction validateDistribution(\n probabilities: Record<string, number>,\n expectedKeys: string[],\n tolerance: number,\n questionId: string,\n): void {\n if (!isPlainObject(probabilities)) {\n throw new TypeError(`Answer '${questionId}' probabilities must be an object.`);\n }\n const keys = Object.keys(probabilities);\n if (keys.length !== expectedKeys.length || keys.some(key => !expectedKeys.includes(key))) {\n throw new TypeError(`Answer '${questionId}' probabilities must contain the complete distribution.`);\n }\n let sum = 0;\n for (const value of Object.values(probabilities)) {\n validateProbability(value, `Answer '${questionId}' probability`);\n sum += value;\n }\n if (Math.abs(sum - 1) > 1e-6 + expectedKeys.length * tolerance) {\n throw new TypeError(`Answer '${questionId}' probabilities must sum to 1.`);\n }\n}\n\nfunction validateProbability(value: unknown, label: string): asserts value is number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value < 0 || value > 1) {\n throw new TypeError(`${label} must be a finite number between 0 and 1.`);\n }\n}\n\nfunction validateJsonValue(value: unknown, label: string, seen = new Set<object>()): void {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return;\n if (typeof value === 'number') {\n if (Number.isFinite(value)) return;\n throw new TypeError(`${label} must contain only JSON-compatible values.`);\n }\n if (typeof value !== 'object') throw new TypeError(`${label} must contain only JSON-compatible values.`);\n if (seen.has(value)) throw new TypeError(`${label} must not contain circular references.`);\n seen.add(value);\n if (Array.isArray(value)) {\n for (const item of value) validateJsonValue(item, label, seen);\n } else if (isPlainObject(value)) {\n for (const item of Object.values(value)) validateJsonValue(item, label, seen);\n } else {\n throw new TypeError(`${label} must contain only JSON-compatible values.`);\n }\n seen.delete(value);\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, any> {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n"],"mappings":";;;;;;;AAgDA,IAAa,sBAAb,cAAyCA,aAAAA,WAAmD;CAC1F,uBAAgC;CAChC;CACA;CACA;CACA;CAEA,YAAY,OAAwB;EAClC,MAAM,EAAE,MAAM,iBAAiB,CAAC;EAChC,KAAK,SAAS;EACd,KAAK,WAAW,MAAM;EACtB,KAAK,UAAU,MA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