{
  "version": 3,
  "sources": ["../src/index.ts", "../src/questions.ts", "../src/utils/math.ts", "../src/answers.ts", "../src/models.ts", "../src/encoding.ts", "../src/utils/errors.ts", "../src/utils/runtime.ts"],
  "sourcesContent": ["import {\n  AutoConfig,\n  AutoTokenizer,\n  ModelRegistry,\n  Tensor,\n} from \"@huggingface/transformers\";\nimport type { PreTrainedTokenizer } from \"@huggingface/transformers\";\nimport { decodeAnswer } from \"./answers\";\nimport type { TokenizedQuestion } from \"./encoding\";\nimport {\n  detectFamily,\n  MODELS,\n  resolveModelId,\n  type FamilyAdapter,\n  type JevModel,\n} from \"./models\";\nimport { questionOptionTexts, validateQuestion } from \"./questions\";\nimport type {\n  Answer,\n  AnswersFor,\n  DecideOptions,\n  ModelProgressCallback,\n  OpenJevInfo,\n  OpenJevOptions,\n  OpenJevRuntime,\n  Question,\n  Questions,\n} from \"./types\";\nimport { normalizeError } from \"./utils/errors\";\nimport { clamp } from \"./utils/math\";\nimport { resolveRuntime } from \"./utils/runtime\";\n\nexport { MODELS } from \"./models\";\nexport { choice, noul, score } from \"./questions\";\nexport type {\n  Answer,\n  AnswerFor,\n  AnswersFor,\n  ChoiceAnswer,\n  ChoiceQuestion,\n  DecideOptions,\n  LoadProgress,\n  ModelAlias,\n  ModelFamily,\n  ModelId,\n  NoulAnswer,\n  NoulQuestion,\n  OpenJevDevice,\n  OpenJevDtype,\n  OpenJevInfo,\n  OpenJevOptions,\n  OpenJevRuntime,\n  Question,\n  Questions,\n  ScoreAnswer,\n  ScoreQuestion,\n} from \"./types\";\n\ntype LoadedParts = {\n  model: JevModel;\n  tokenizer: PreTrainedTokenizer;\n  family: FamilyAdapter;\n  runtime: OpenJevRuntime;\n  defaults: Required<DecideOptions>;\n  maxLength: number;\n};\n\n/**\n * Typed decisions in the browser with Jev-shaped models.\n *\n * One `state` (any text) plus any number of typed questions go in, one\n * forward pass returns a calibrated probability distribution per question.\n * Nothing is generated, so answers are always one of the options you gave.\n *\n * Create an instance with `OpenJev.load()`. Built-in models: `kev-0.6b`\n * (default) and `kev-4b` (Qwen3), `open-jev` (DeBERTa-v3-large).\n */\nexport class OpenJev {\n  /** The model, family, backend and weight variant that were loaded. */\n  readonly runtime: OpenJevRuntime;\n\n  private readonly model: JevModel;\n  private readonly tokenizer: PreTrainedTokenizer;\n  private readonly family: FamilyAdapter;\n  private readonly defaults: Required<DecideOptions>;\n  private readonly maxLength: number;\n\n  private queue: Promise<unknown> = Promise.resolve();\n  private disposed = false;\n\n  private constructor(parts: LoadedParts) {\n    this.model = parts.model;\n    this.tokenizer = parts.tokenizer;\n    this.family = parts.family;\n    this.runtime = parts.runtime;\n    this.defaults = parts.defaults;\n    this.maxLength = parts.maxLength;\n  }\n\n  /**\n   * Download (or read from cache) the tokenizer and model and return a ready\n   * instance.\n   *\n   * Supported options:\n   * - `model`: `kev-0.6b` (default), `kev-4b`, `open-jev` or a Hugging Face repo id.\n   * - `dtype`: `fp32 | fp16 | q4 | q4f16 | auto` (default `auto`).\n   * - `device`: `webgpu | wasm | cpu | auto` (default `auto`).\n   * - `onProgress`: download progress callback.\n   * - `temperature`, `maxStateTokens`, `truncation`: defaults for `decide()`.\n   * - `maxLength`: context limit (model-specific default).\n   */\n  static async load(options: OpenJevOptions = {}): Promise<OpenJev> {\n    const modelId = resolveModelId(options.model);\n    const config = await AutoConfig.from_pretrained(modelId);\n    const family = detectFamily(config);\n    const runtime = await resolveRuntime(options, family.webgpuDtype);\n    const onProgress = options.onProgress;\n\n    let lastProgress = -1;\n    const progressCallback: ModelProgressCallback = (info): void => {\n      if (!onProgress || info.status !== \"progress_total\") {\n        return;\n      }\n\n      const progress = Math.round(clamp(info.progress / 100, 0, 1) * 100) / 100;\n      if (progress === lastProgress) {\n        return;\n      }\n\n      lastProgress = progress;\n      onProgress({ progress, loaded: info.loaded, total: info.total });\n    };\n\n    const tokenizer = await AutoTokenizer.from_pretrained(modelId);\n    family.prepare(tokenizer);\n\n    const model = await family.loadModel(modelId, {\n      config,\n      dtype: runtime.dtype,\n      device: runtime.device,\n      progress_callback: progressCallback as (info: unknown) => void,\n    });\n\n    const defaults: Required<DecideOptions> = {\n      temperature: options.temperature ?? family.defaults.temperature,\n      maxStateTokens: options.maxStateTokens ?? family.defaults.maxStateTokens,\n      truncation: options.truncation ?? \"cut\",\n    };\n\n    return new OpenJev({\n      model,\n      tokenizer,\n      family,\n      runtime: { model: modelId, family: family.name, ...runtime },\n      defaults,\n      maxLength: Math.max(\n        8,\n        Math.floor(options.maxLength ?? family.defaults.maxLength),\n      ),\n    });\n  }\n\n  /**\n   * Get model metadata for a configuration without loading it.\n   *\n   * - `isCached`: whether every required file is present in the browser cache.\n   * - `downloadSize`: total size in bytes of the files that will be fetched.\n   * - `files`: the file list; `model`, `family`, `device`, `dtype`: the resolved runtime.\n   */\n  static async info(\n    options: Pick<OpenJevOptions, \"model\" | \"device\" | \"dtype\"> = {},\n  ): Promise<OpenJevInfo> {\n    const modelId = resolveModelId(options.model);\n    const config = await AutoConfig.from_pretrained(modelId);\n    const family = detectFamily(config);\n    const runtime = await resolveRuntime(options, family.webgpuDtype);\n\n    const files = await ModelRegistry.get_files(modelId, {\n      config,\n      dtype: runtime.dtype,\n      device: runtime.device,\n      include_tokenizer: true,\n      include_processor: false,\n    });\n\n    const [isCached, metadata] = await Promise.all([\n      ModelRegistry.is_cached(modelId, {\n        config,\n        dtype: runtime.dtype,\n        device: runtime.device,\n      }),\n      Promise.all(\n        files.map((file) => ModelRegistry.get_file_metadata(modelId, file)),\n      ),\n    ]);\n\n    const downloadSize = metadata.reduce(\n      (sum, meta) => sum + (meta.size ?? 0),\n      0,\n    );\n\n    return {\n      model: modelId,\n      family: family.name,\n      ...runtime,\n      isCached,\n      downloadSize,\n      files,\n    };\n  }\n\n  /**\n   * Answer typed questions about one state in a single forward pass.\n   *\n   * Pass questions as an array (answers come back as a tuple in the same\n   * order) or as an object (answers come back under the same keys).\n   */\n  async decide<const Qs extends Questions>(\n    state: string,\n    questions: Qs,\n    options: DecideOptions = {},\n  ): Promise<AnswersFor<Qs>> {\n    this.assertNotDisposed();\n\n    if (typeof state !== \"string\") {\n      throw new Error(\"OpenJev.decide() expects the state to be a string.\");\n    }\n\n    const isList = Array.isArray(questions);\n    const keys = isList\n      ? (questions as readonly Question[]).map((_, index) => String(index))\n      : Object.keys(questions);\n    const list = isList\n      ? [...(questions as readonly Question[])]\n      : Object.values(questions as Readonly<Record<string, Question>>);\n\n    if (list.length === 0) {\n      throw new Error(\"OpenJev.decide() needs at least one question.\");\n    }\n\n    list.forEach((question, index) =>\n      validateQuestion(\n        question,\n        isList ? `#${index}` : `\"${keys[index]}\"`,\n        this.family.limits,\n      ),\n    );\n\n    const settings: Required<DecideOptions> = {\n      temperature: Math.max(\n        1e-6,\n        options.temperature ?? this.defaults.temperature,\n      ),\n      maxStateTokens: Math.max(\n        0,\n        Math.floor(options.maxStateTokens ?? this.defaults.maxStateTokens),\n      ),\n      truncation: options.truncation ?? this.defaults.truncation,\n    };\n\n    const answers = await this.enqueue(() => this.run(state, list, settings));\n\n    if (isList) {\n      return answers as unknown as AnswersFor<Qs>;\n    }\n\n    const record: Record<string, Answer> = {};\n    keys.forEach((key, index) => {\n      record[key] = answers[index];\n    });\n    return record as unknown as AnswersFor<Qs>;\n  }\n\n  /**\n   * Number of tokens `text` occupies in the sequence (without markers).\n   * Useful to check a state against `maxStateTokens` before deciding.\n   */\n  countTokens(text: string): number {\n    this.assertNotDisposed();\n    return this.encode(text).length;\n  }\n\n  /**\n   * Release the ONNX session. Pending `decide()` calls finish first; the\n   * instance cannot be used afterwards.\n   */\n  async dispose(): Promise<void> {\n    if (this.disposed) {\n      return;\n    }\n\n    this.disposed = true;\n\n    try {\n      await this.queue;\n    } catch {\n      // A pending decision failed; nothing left to wait for.\n    }\n\n    await this.model.dispose?.();\n  }\n\n  private async run(\n    state: string,\n    questions: Question[],\n    settings: Required<DecideOptions>,\n  ): Promise<Answer[]> {\n    try {\n      const tokenized: TokenizedQuestion[] = questions.map((question) => ({\n        instructions: this.encode(question.instructions),\n        options: questionOptionTexts(question).map((option) =>\n          this.encode(option),\n        ),\n      }));\n\n      const encoded = this.family.encode({\n        state: this.encode(state),\n        questions: tokenized,\n        maxStateTokens: settings.maxStateTokens,\n        maxLength: this.maxLength,\n      });\n\n      if (encoded.stateTruncated && settings.truncation === \"error\") {\n        throw new Error(\n          `State was cut to ${encoded.stateTokens} tokens (limit ${settings.maxStateTokens}, ${this.maxLength} in total). Shorten the state or the questions, or set truncation to \"cut\".`,\n        );\n      }\n\n      const inputs: Record<string, Tensor> = {\n        input_ids: int64(encoded.inputIds),\n        attention_mask: int64(encoded.inputIds.map(() => 1)),\n      };\n      for (const [name, values] of Object.entries(encoded.extraInputs)) {\n        inputs[name] = int64(values);\n      }\n\n      const { logits } = await this.model(inputs);\n      const scores = Array.from(logits.to(\"float32\").data as ArrayLike<number>);\n\n      return questions.map((question, index) =>\n        decodeAnswer(\n          question,\n          encoded.groups[index].map((position) => scores[position]),\n          settings.temperature,\n        ),\n      );\n    } catch (error) {\n      throw normalizeError(error);\n    }\n  }\n\n  /** Tokenize caller text (escaped per family, no special tokens). */\n  private encode(text: string): number[] {\n    const { input_ids } = this.tokenizer(this.family.escape(text), {\n      add_special_tokens: false,\n    }) as { input_ids: Tensor };\n    return Array.from(input_ids.data as ArrayLike<bigint | number>, Number);\n  }\n\n  private enqueue<T>(task: () => Promise<T>): Promise<T> {\n    const result = this.queue.then(task, task);\n    this.queue = result.catch(() => undefined);\n    return result;\n  }\n\n  private assertNotDisposed(): void {\n    if (this.disposed) {\n      throw new Error(\"OpenJev instance has been disposed.\");\n    }\n  }\n}\n\nfunction int64(values: number[]): Tensor {\n  return new Tensor(\"int64\", BigInt64Array.from(values, BigInt), [\n    1,\n    values.length,\n  ]);\n}\n", "import type {\n  ChoiceQuestion,\n  NoulQuestion,\n  Question,\n  ScoreQuestion,\n} from \"./types\";\n\n/** Options the models were trained with for `noul` questions (index 1 = yes). */\nexport const NOUL_OPTIONS = [\"no\", \"yes\"] as const;\n\nexport type QuestionLimits = {\n  minChoiceOptions: number;\n  maxChoiceOptions: number;\n  minScoreLevels: number;\n  maxScoreLevels: number;\n};\n\n/** Build a `choice` question: pick one of the given options. */\nexport function choice<const O extends string>(\n  instructions: string,\n  options: readonly O[],\n  descriptions?: Partial<Record<O, string>>,\n): ChoiceQuestion<O> {\n  return descriptions\n    ? { type: \"choice\", instructions, options, descriptions }\n    : { type: \"choice\", instructions, options };\n}\n\n/** Build a `score` question: rate on an ordered scale (first = lowest). */\nexport function score<const L extends string>(\n  instructions: string,\n  levels: readonly L[],\n): ScoreQuestion<L> {\n  return { type: \"score\", instructions, options: levels };\n}\n\n/** Build a `noul` question: does the statement hold for the state? */\nexport function noul(statement: string): NoulQuestion {\n  return { type: \"noul\", instructions: statement };\n}\n\n/** Option labels of a question (keys of the answer distribution). */\nexport function questionLabels(question: Question): readonly string[] {\n  return question.type === \"noul\" ? NOUL_OPTIONS : question.options;\n}\n\n/** Option texts as they are fed to the model (`name: description` when given). */\nexport function questionOptionTexts(question: Question): string[] {\n  if (question.type === \"noul\") {\n    return [...NOUL_OPTIONS];\n  }\n\n  if (question.type === \"choice\" && question.descriptions) {\n    const descriptions = question.descriptions as Record<string, string>;\n    return question.options.map((option) => {\n      const description = descriptions[option];\n      return description ? `${option}: ${description}` : option;\n    });\n  }\n\n  return [...question.options];\n}\n\nexport function validateQuestion(\n  question: Question,\n  label: string,\n  limits: QuestionLimits,\n): void {\n  if (!question || typeof question !== \"object\") {\n    throw new Error(`Question ${label} must be an object.`);\n  }\n\n  if (\n    typeof question.instructions !== \"string\" ||\n    question.instructions.trim() === \"\"\n  ) {\n    throw new Error(`Question ${label} needs non-empty instructions.`);\n  }\n\n  if (question.type === \"noul\") {\n    return;\n  }\n\n  if (question.type !== \"choice\" && question.type !== \"score\") {\n    throw new Error(\n      `Question ${label} has unknown type \"${String(\n        (question as { type: unknown }).type,\n      )}\". Expected \"choice\", \"score\" or \"noul\".`,\n    );\n  }\n\n  const options = question.options;\n  if (!Array.isArray(options)) {\n    throw new Error(`Question ${label} needs an options array.`);\n  }\n\n  const min =\n    question.type === \"choice\"\n      ? limits.minChoiceOptions\n      : limits.minScoreLevels;\n  const max =\n    question.type === \"choice\"\n      ? limits.maxChoiceOptions\n      : limits.maxScoreLevels;\n  if (options.length < min || options.length > max) {\n    throw new Error(\n      `Question ${label} (${question.type}) needs between ${min} and ${max} options for this model, got ${options.length}.`,\n    );\n  }\n\n  const seen = new Set<string>();\n  for (const option of options) {\n    if (typeof option !== \"string\" || option.trim() === \"\") {\n      throw new Error(`Question ${label} has an empty or non-string option.`);\n    }\n    if (seen.has(option)) {\n      throw new Error(`Question ${label} has a duplicate option \"${option}\".`);\n    }\n    seen.add(option);\n  }\n}\n", "export function clamp(value: number, min: number, max: number): number {\n  return Math.max(min, Math.min(max, value));\n}\n\n/** Numerically stable softmax with temperature scaling. */\nexport function softmax(logits: number[], temperature = 1): number[] {\n  if (logits.length === 0) {\n    return [];\n  }\n\n  const max = Math.max(...logits);\n  const scaled = logits.map((x) => Math.exp((x - max) / temperature));\n  const sum = scaled.reduce((a, b) => a + b, 0);\n  return scaled.map((x) => x / sum);\n}\n", "import { NOUL_OPTIONS } from \"./questions\";\nimport type {\n  Answer,\n  ChoiceAnswer,\n  NoulAnswer,\n  Question,\n  ScoreAnswer,\n} from \"./types\";\nimport { softmax } from \"./utils/math\";\n\n/** Turn the raw logits of one question's option group into a typed answer. */\nexport function decodeAnswer(\n  question: Question,\n  logits: number[],\n  temperature: number,\n): Answer {\n  const probabilities = softmax(logits, temperature);\n\n  switch (question.type) {\n    case \"choice\":\n      return decodeChoice(question.options, probabilities);\n    case \"score\":\n      return decodeScore(question.options, probabilities);\n    case \"noul\":\n      return decodeNoul(probabilities);\n  }\n}\n\nfunction decodeChoice(\n  options: readonly string[],\n  probabilities: number[],\n): ChoiceAnswer {\n  const best = argmax(probabilities);\n  return {\n    type: \"choice\",\n    choice: options[best],\n    confidence: probabilities[best],\n    probabilities: toRecord(options, probabilities),\n  };\n}\n\nfunction decodeScore(\n  levels: readonly string[],\n  probabilities: number[],\n): ScoreAnswer {\n  const expected = probabilities.reduce((sum, p, index) => sum + p * index, 0);\n  const best = argmax(probabilities);\n  const last = levels.length - 1;\n  const nearest = Math.min(last, Math.max(0, Math.round(expected)));\n\n  return {\n    type: \"score\",\n    score: expected,\n    normalized: last > 0 ? expected / last : 0,\n    level: levels[nearest],\n    confidence: probabilities[best],\n    probabilities: toRecord(levels, probabilities),\n  };\n}\n\nfunction decodeNoul(probabilities: number[]): NoulAnswer {\n  const yesIndex = NOUL_OPTIONS.indexOf(\"yes\");\n  const probability = probabilities[yesIndex];\n  return {\n    type: \"noul\",\n    answer: probability >= 0.5,\n    probability,\n    confidence: Math.max(probability, 1 - probability),\n  };\n}\n\nfunction argmax(values: number[]): number {\n  let best = 0;\n  for (let index = 1; index < values.length; index += 1) {\n    if (values[index] > values[best]) {\n      best = index;\n    }\n  }\n  return best;\n}\n\nfunction toRecord(\n  keys: readonly string[],\n  values: number[],\n): Record<string, number> {\n  const record: Record<string, number> = {};\n  keys.forEach((key, index) => {\n    record[key] = values[index];\n  });\n  return record;\n}\n", "import { AutoModel, PreTrainedModel } from \"@huggingface/transformers\";\nimport type {\n  PretrainedConfig,\n  PreTrainedTokenizer,\n  Tensor,\n} from \"@huggingface/transformers\";\nimport {\n  encodeKevSequence,\n  encodeSequence,\n  type EncodedSequence,\n  type TokenizedQuestion,\n} from \"./encoding\";\nimport type { QuestionLimits } from \"./questions\";\nimport type { ModelAlias, ModelFamily, OpenJevDtype } from \"./types\";\n\n/** Hugging Face repos behind the built-in aliases. */\nexport const MODELS: Record<ModelAlias, string> = {\n  \"open-jev\": \"onnx-community/open-jev-deberta-v3-large-ONNX\",\n  \"kev-0.6b\": \"onnx-community/kev-0.6b-ONNX\",\n  \"kev-4b\": \"onnx-community/kev-4b-ONNX\",\n};\n\nexport const DEFAULT_MODEL: ModelAlias = \"kev-0.6b\";\n\nexport function resolveModelId(model: string | undefined): string {\n  const id = model ?? DEFAULT_MODEL;\n  return (MODELS as Record<string, string>)[id] ?? id;\n}\n\nexport type JevModel = {\n  (inputs: Record<string, Tensor>): Promise<{ logits: Tensor }>;\n  dispose?: () => Promise<unknown>;\n};\n\nexport type LoadModelOptions = {\n  config: PretrainedConfig;\n  dtype: OpenJevDtype;\n  device: string;\n  progress_callback: (info: unknown) => void;\n};\n\nexport type FamilyDefaults = {\n  temperature: number;\n  maxStateTokens: number;\n  maxLength: number;\n};\n\n/** Everything that differs between the model families. */\nexport type FamilyAdapter = {\n  name: ModelFamily;\n  /** Best variant on WebGPU with `shader-f16`; `q4` is used elsewhere. */\n  webgpuDtype: OpenJevDtype;\n  limits: QuestionLimits;\n  defaults: FamilyDefaults;\n  loadModel(modelId: string, options: LoadModelOptions): Promise<JevModel>;\n  /** Resolve marker/delimiter token ids once the tokenizer is available. */\n  prepare(tokenizer: PreTrainedTokenizer): void;\n  /** Applied to every caller-provided text before tokenization. */\n  escape(text: string): string;\n  encode(params: {\n    state: number[];\n    questions: TokenizedQuestion[];\n    maxStateTokens: number;\n    maxLength: number;\n  }): EncodedSequence;\n};\n\ntype ConfigJson = Record<string, unknown>;\n\nexport function detectFamily(config: PretrainedConfig): FamilyAdapter {\n  const json = config as unknown as ConfigJson;\n  if (json.kev && typeof json.kev === \"object\") {\n    return kevFamily(json.kev as ConfigJson);\n  }\n  if (json.open_jev && typeof json.open_jev === \"object\") {\n    return openJevFamily(json.open_jev as ConfigJson);\n  }\n  throw new Error(\n    `Unsupported model: config.json has neither an \"open_jev\" nor a \"kev\" section. Use one of ${Object.keys(MODELS).join(\", \")} or a compatible ONNX conversion.`,\n  );\n}\n\nfunction num(value: unknown, fallback: number): number {\n  return typeof value === \"number\" && Number.isFinite(value) ? value : fallback;\n}\n\nfunction encodeSingle(tokenizer: PreTrainedTokenizer, text: string): number {\n  const { input_ids } = tokenizer(text, { add_special_tokens: false }) as {\n    input_ids: Tensor;\n  };\n  const ids = Array.from(input_ids.data as ArrayLike<bigint | number>, Number);\n  if (ids.length !== 1) {\n    throw new Error(`Tokenizer does not know the marker token ${text}.`);\n  }\n  return ids[0];\n}\n\nfunction openJevFamily(section: ConfigJson): FamilyAdapter {\n  let markers: Parameters<typeof encodeSequence>[0][\"markers\"] | null = null;\n\n  return {\n    name: \"open-jev\",\n    webgpuDtype: \"fp16\",\n    limits: {\n      minChoiceOptions: 2,\n      maxChoiceOptions: 255,\n      minScoreLevels: 2,\n      maxScoreLevels: 10,\n    },\n    defaults: {\n      temperature: num(section.temperature, 1.05),\n      maxStateTokens: num(section.max_state_tokens, 256),\n      maxLength: num(section.max_len, 512),\n    },\n    loadModel: async (modelId, options) =>\n      (await AutoModel.from_pretrained(modelId, {\n        config: options.config,\n        dtype: options.dtype,\n        device: options.device as \"webgpu\",\n        progress_callback: options.progress_callback,\n      })) as unknown as JevModel,\n    prepare(tokenizer) {\n      markers = {\n        cls: encodeSingle(tokenizer, \"[CLS]\"),\n        sep: encodeSingle(tokenizer, \"[SEP]\"),\n        state: encodeSingle(tokenizer, \"[STATE]\"),\n        q: encodeSingle(tokenizer, \"[Q]\"),\n        opt: encodeSingle(tokenizer, \"[OPT]\"),\n      };\n    },\n    escape: (text) => text,\n    encode(params) {\n      if (!markers) {\n        throw new Error(\"Model family not prepared.\");\n      }\n      return encodeSequence({ ...params, markers });\n    },\n  };\n}\n\nfunction kevFamily(section: ConfigJson): FamilyAdapter {\n  const ids = (section.delimiter_ids ?? {}) as Record<string, unknown>;\n  const names = (section.delimiters ?? {}) as Record<string, unknown>;\n  let delimiters: Parameters<typeof encodeKevSequence>[0][\"delimiters\"] | null =\n    null;\n\n  const resolve = (\n    tokenizer: PreTrainedTokenizer,\n    key: string,\n    fallback: string,\n  ): number => {\n    const id = ids[key];\n    if (typeof id === \"number\") {\n      return id;\n    }\n    const name =\n      typeof names[key] === \"string\" ? (names[key] as string) : fallback;\n    return encodeSingle(tokenizer, name);\n  };\n\n  return {\n    name: \"kev\",\n    webgpuDtype: \"q4f16\",\n    limits: {\n      minChoiceOptions: 1,\n      maxChoiceOptions: num(section.max_options, 255),\n      minScoreLevels: 2,\n      maxScoreLevels: num(section.max_options, 255),\n    },\n    defaults: {\n      temperature: 1,\n      maxStateTokens: num(section.max_state_tokens, 8192),\n      maxLength: num(section.max_branch_tokens, 8192),\n    },\n    // Transformers.js maps qwen3 to its text-generation class, which expects a\n    // KV-cache graph. The base class takes the single-session path that feeds\n    // every graph input by name. It logs an \"assuming encoder-only\" warning.\n    loadModel: async (modelId, options) =>\n      (await PreTrainedModel.from_pretrained(modelId, {\n        config: options.config,\n        dtype: options.dtype,\n        device: options.device as \"webgpu\",\n        progress_callback: options.progress_callback,\n      })) as unknown as JevModel,\n    prepare(tokenizer) {\n      delimiters = {\n        state: resolve(tokenizer, \"state\", \"<|fim_prefix|>\"),\n        question: resolve(tokenizer, \"question\", \"<|fim_middle|>\"),\n        optionStart: resolve(tokenizer, \"option_start\", \"<|box_start|>\"),\n        optionEnd: resolve(tokenizer, \"option_end\", \"<|box_end|>\"),\n        decide: resolve(tokenizer, \"decide\", \"<|fim_suffix|>\"),\n      };\n    },\n    // Caller text can never produce a delimiter: <|name|> -> <\u00A6name\u00A6>\n    escape: (text) => text.replace(/<\\|([A-Za-z0-9_]+)\\|>/g, \"<\u00A6$1\u00A6>\"),\n    encode(params) {\n      if (!delimiters) {\n        throw new Error(\"Model family not prepared.\");\n      }\n      return encodeKevSequence({ ...params, delimiters });\n    },\n  };\n}\n", "/**\n * Sequence builders for the two model families.\n *\n * open-jev (DeBERTa):\n *   [CLS] [STATE] state [Q] instructions [OPT] option_1 [OPT] option_2 \u2026 [Q] \u2026 [SEP]\n *   plus the span-slot tensor (`seg`) and per-pair slot ids (`pair_q`, `pair_opt`).\n *\n * kev (Qwen3):\n *   <state> state <q> instructions <opt> option_1 </opt> <opt> option_2 </opt> \u2026 <decide> <q> \u2026\n *   only `input_ids` and `attention_mask`; the graph derives the block-causal\n *   mask from the delimiters and returns one logit per token.\n */\n\nexport type MarkerIds = {\n  cls: number;\n  sep: number;\n  state: number;\n  q: number;\n  opt: number;\n};\n\nexport type TokenizedQuestion = {\n  instructions: number[];\n  options: number[][];\n};\n\nexport type EncodedSequence = {\n  inputIds: number[];\n  /** Extra int64 inputs besides `input_ids` and `attention_mask`. */\n  extraInputs: Record<string, number[]>;\n  /** Per question: indices into the flat `logits` output, one per option. */\n  groups: number[][];\n  /** Number of state tokens that made it into the sequence. */\n  stateTokens: number;\n  /** Whether the state had to be cut. */\n  stateTruncated: boolean;\n};\n\nexport type EncodeParams = {\n  state: number[];\n  questions: TokenizedQuestion[];\n  markers: MarkerIds;\n  maxStateTokens: number;\n  maxLength: number;\n};\n\nexport function encodeSequence(params: EncodeParams): EncodedSequence {\n  const { state, questions, markers, maxStateTokens, maxLength } = params;\n\n  // [CLS] [STATE] \u2026 [SEP]\n  let fixedTokens = 3;\n  for (const question of questions) {\n    fixedTokens += 1 + question.instructions.length;\n    for (const option of question.options) {\n      fixedTokens += 1 + option.length;\n    }\n  }\n\n  const budget = maxLength - fixedTokens;\n  if (budget < 0) {\n    throw new Error(\n      `Questions need ${fixedTokens} tokens which exceeds the ${maxLength} token context. Shorten the instructions or options, or ask fewer questions per call.`,\n    );\n  }\n\n  const stateLimit = Math.min(maxStateTokens, budget);\n  const stateTokens = state.slice(0, stateLimit);\n\n  const inputIds: number[] = [markers.cls, markers.state, ...stateTokens];\n  const seg: number[] = inputIds.map(() => -1);\n  const pairQ: number[] = [];\n  const pairOpt: number[] = [];\n  const groups: number[][] = [];\n\n  const totalPairs = questions.reduce((n, q) => n + q.options.length, 0);\n\n  questions.forEach((question, questionIndex) => {\n    const questionSlot = totalPairs + questionIndex;\n\n    inputIds.push(markers.q, ...question.instructions);\n    seg.push(-1, ...question.instructions.map(() => questionSlot));\n\n    const group: number[] = [];\n    for (const option of question.options) {\n      const pairIndex = pairOpt.length;\n      inputIds.push(markers.opt, ...option);\n      seg.push(-1, ...option.map(() => pairIndex));\n      pairQ.push(questionSlot);\n      pairOpt.push(pairIndex);\n      group.push(pairIndex);\n    }\n    groups.push(group);\n  });\n\n  inputIds.push(markers.sep);\n  seg.push(-1);\n\n  return {\n    inputIds,\n    extraInputs: { seg, pair_q: pairQ, pair_opt: pairOpt },\n    groups,\n    stateTokens: stateTokens.length,\n    stateTruncated: stateTokens.length < state.length,\n  };\n}\n\nexport type KevDelimiterIds = {\n  state: number;\n  question: number;\n  optionStart: number;\n  optionEnd: number;\n  decide: number;\n};\n\nexport type KevEncodeParams = {\n  state: number[];\n  questions: TokenizedQuestion[];\n  delimiters: KevDelimiterIds;\n  maxStateTokens: number;\n  /** Limit for the state plus one question branch. */\n  maxLength: number;\n};\n\nexport function encodeKevSequence(params: KevEncodeParams): EncodedSequence {\n  const { state, questions, delimiters, maxStateTokens, maxLength } = params;\n\n  const branches = questions.map((question) => {\n    const branch = [delimiters.question, ...question.instructions];\n    const ends: number[] = [];\n    for (const option of question.options) {\n      branch.push(delimiters.optionStart, ...option, delimiters.optionEnd);\n      ends.push(branch.length - 1);\n    }\n    branch.push(delimiters.decide);\n    return { branch, ends };\n  });\n\n  const longestBranch = Math.max(...branches.map((b) => b.branch.length));\n  // The <state> delimiter counts towards the branch budget.\n  const budget = maxLength - 1 - longestBranch;\n  if (budget < 0) {\n    throw new Error(\n      `A question needs ${longestBranch + 1} tokens which exceeds the ${maxLength} token context. Shorten the instructions or options.`,\n    );\n  }\n\n  const stateLimit = Math.min(maxStateTokens, budget);\n  const stateTokens = state.slice(0, stateLimit);\n\n  const inputIds: number[] = [delimiters.state, ...stateTokens];\n  const groups: number[][] = [];\n\n  for (const { branch, ends } of branches) {\n    const base = inputIds.length;\n    inputIds.push(...branch);\n    groups.push(ends.map((end) => base + end));\n  }\n\n  return {\n    inputIds,\n    extraInputs: {},\n    groups,\n    stateTokens: stateTokens.length,\n    stateTruncated: stateTokens.length < state.length,\n  };\n}\n", "export function normalizeError(error: unknown): Error {\n  if (error instanceof Error) {\n    return error;\n  }\n\n  return new Error(typeof error === \"string\" ? error : \"Unknown error\");\n}\n", "import type { OpenJevDevice, OpenJevDtype, OpenJevRuntime } from \"../types\";\n\ntype GpuAdapterLike = { features: { has(name: string): boolean } };\ntype NavigatorWithGpu = Navigator & {\n  gpu?: { requestAdapter(): Promise<GpuAdapterLike | null> };\n};\n\nlet fp16Support: Promise<boolean> | null = null;\n\nfunction isNode(): boolean {\n  const proc = (globalThis as { process?: { versions?: { node?: string } } })\n    .process;\n  return typeof proc?.versions?.node === \"string\";\n}\n\nexport function isWebGpuAvailable(): boolean {\n  return (\n    typeof navigator !== \"undefined\" &&\n    typeof (navigator as NavigatorWithGpu).gpu !== \"undefined\"\n  );\n}\n\nexport function isWebGpuFp16Supported(): Promise<boolean> {\n  if (!fp16Support) {\n    fp16Support = (async () => {\n      if (!isWebGpuAvailable()) {\n        return false;\n      }\n      try {\n        const adapter = await (\n          navigator as NavigatorWithGpu\n        ).gpu!.requestAdapter();\n        return adapter?.features.has(\"shader-f16\") ?? false;\n      } catch {\n        return false;\n      }\n    })();\n  }\n\n  return fp16Support;\n}\n\n/**\n * Resolve `\"auto\"` device/dtype to concrete values.\n *\n * - device: `webgpu` when the runtime exposes WebGPU, `cpu` in Node.js,\n *   otherwise `wasm`.\n * - dtype: the family's preferred WebGPU variant when `shader-f16` is\n *   available, otherwise `q4`.\n */\nexport async function resolveRuntime(\n  options: {\n    device?: OpenJevDevice | \"auto\";\n    dtype?: OpenJevDtype | \"auto\";\n  },\n  webgpuDtype: OpenJevDtype,\n): Promise<Pick<OpenJevRuntime, \"device\" | \"dtype\">> {\n  const requestedDevice = options.device ?? \"auto\";\n  const requestedDtype = options.dtype ?? \"auto\";\n\n  let device: OpenJevDevice;\n  if (requestedDevice !== \"auto\") {\n    device = requestedDevice;\n  } else if (isWebGpuAvailable()) {\n    device = \"webgpu\";\n  } else if (isNode()) {\n    device = \"cpu\";\n  } else {\n    device = \"wasm\";\n  }\n\n  let dtype: OpenJevDtype;\n  if (requestedDtype !== \"auto\") {\n    dtype = requestedDtype;\n  } else if (device === \"webgpu\" && (await isWebGpuFp16Supported())) {\n    dtype = webgpuDtype;\n  } else {\n    dtype = \"q4\";\n  }\n\n  return { device, dtype };\n}\n"],
  "mappings": "0aAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,YAAAE,EAAA,YAAAC,EAAA,WAAAC,EAAA,SAAAC,EAAA,UAAAC,IAAA,eAAAC,GAAAP,IAAA,IAAAQ,EAKO,qCCGA,IAAMC,EAAe,CAAC,KAAM,KAAK,EAUjC,SAASC,EACdC,EACAC,EACAC,EACmB,CACnB,OAAOA,EACH,CAAE,KAAM,SAAU,aAAAF,EAAc,QAAAC,EAAS,aAAAC,CAAa,EACtD,CAAE,KAAM,SAAU,aAAAF,EAAc,QAAAC,CAAQ,CAC9C,CAGO,SAASE,EACdH,EACAI,EACkB,CAClB,MAAO,CAAE,KAAM,QAAS,aAAAJ,EAAc,QAASI,CAAO,CACxD,CAGO,SAASC,EAAKC,EAAiC,CACpD,MAAO,CAAE,KAAM,OAAQ,aAAcA,CAAU,CACjD,CAQO,SAASC,EAAoBC,EAA8B,CAChE,GAAIA,EAAS,OAAS,OACpB,MAAO,CAAC,GAAGC,CAAY,EAGzB,GAAID,EAAS,OAAS,UAAYA,EAAS,aAAc,CACvD,IAAME,EAAeF,EAAS,aAC9B,OAAOA,EAAS,QAAQ,IAAKG,GAAW,CACtC,IAAMC,EAAcF,EAAaC,CAAM,EACvC,OAAOC,EAAc,GAAGD,CAAM,KAAKC,CAAW,GAAKD,CACrD,CAAC,CACH,CAEA,MAAO,CAAC,GAAGH,EAAS,OAAO,CAC7B,CAEO,SAASK,EACdL,EACAM,EACAC,EACM,CACN,GAAI,CAACP,GAAY,OAAOA,GAAa,SACnC,MAAM,IAAI,MAAM,YAAYM,CAAK,qBAAqB,EAGxD,GACE,OAAON,EAAS,cAAiB,UACjCA,EAAS,aAAa,KAAK,IAAM,GAEjC,MAAM,IA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,EAAMA,CAAI,EACzC,YAAK,MAAQC,EAAO,MAAM,IAAG,EAAY,EAClCA,CACT,CAEQ,mBAA0B,CAChC,GAAI,KAAK,SACP,MAAM,IAAI,MAAM,qCAAqC,CAEzD,CACF,EAEA,SAASX,EAAME,EAA0B,CACvC,OAAO,IAAI,SAAO,QAAS,cAAc,KAAKA,EAAQ,MAAM,EAAG,CAC7D,EACAA,EAAO,MACT,CAAC,CACH",
  "names": ["index_exports", "__export", "MODELS", "OpenJev", "choice", "noul", "score", "__toCommonJS", "import_transformers", "NOUL_OPTIONS", "choice", "instructions", "options", "descriptions", "score", "levels", "noul", "statement", "questionOptionTexts", "question", "NOUL_OPTIONS", "descriptions", "option", "description", "validateQuestion", "label", "limits", "options", "min", "max", "seen", "clamp", "value", "min", "max", "softmax", "logits", "temperature", "scaled", "x", "sum", "a", "b", "decodeAnswer", "question", "logits", "temperature", "probabilities", "softmax", "decodeChoice", "decodeScore", "decodeNoul", "options", "best", "argmax", "toRecord", "levels", "expected", "sum", "p", "index", "last", "nearest", "yesIndex", "NOUL_OPTIONS", "probability", "values", "keys", "record", "key", "import_transformers", "encodeSequence", "params", "state", "questions", "markers", "maxStateTokens", "maxLength", "fixedTokens", "question", "option", "budget", "stateLimit", "stateTokens", "inputIds", "seg", "pairQ", "pairOpt", "groups", "totalPairs", "n", "q", "questionIndex", "questionSlot", "group", "pairIndex", "encodeKevSequence", "delimiters", "branches", "branch", "ends", "longestBranch", "b", "base", "end", "MODELS", "DEFAULT_MODEL", "resolveModelId", "model", "id", "detectFamily", "config", "json", "kevFamily", "openJevFamily", "num", "value", "fallback", "encodeSingle", "tokenizer", "text", "input_ids", "ids", "section", "markers", "modelId", "options", "params", "encodeSequence", "names", "delimiters", "resolve", "key", "name", "encodeKevSequence", "normalizeError", "error", "fp16Support", "isNode", "isWebGpuAvailable", "isWebGpuFp16Supported", "resolveRuntime", "options", "webgpuDtype", "requestedDevice", "requestedDtype", "device", "dtype", "OpenJev", "_OpenJev", "parts", "options", "modelId", "resolveModelId", "config", "family", "detectFamily", "runtime", "resolveRuntime", "onProgress", "lastProgress", "progressCallback", "info", "progress", "clamp", "tokenizer", "model", "defaults", "files", "isCached", "metadata", "file", "downloadSize", "sum", "meta", "state", "questions", "isList", "keys", "_", "index", "list", "question", "validateQuestion", "settings", "answers", "record", "key", "text", "tokenized", "questionOptionTexts", "option", "encoded", "inputs", "int64", "name", "values", "logits", "scores", "decodeAnswer", "position", "error", "normalizeError", "input_ids", "task", "result"]
}
