diff --git a/.env.example b/.env.example index 44452a8..aee62ba 100644 --- a/.env.example +++ b/.env.example @@ -92,6 +92,13 @@ CEREBRAS_API_KEY= # LLM_ANALYSIS_ITEMS=12 # concepts analysis asks for; bounds the reply's length # LLM_RATE_IN= / LLM_RATE_OUT= # USD per million tokens; empty = unattributed +# The TypeScript diagram agent (reader/app/api/diagram). Set BOTH on the API to +# have concept diagrams drawn by a model calling validated tools; unset, codegen +# uses one-shot JSON. The reader project needs ARCVISUAL_INTERNAL_SECRET and +# OPENROUTER_API_KEY (optionally DIAGRAM_MODELS, LLM_REASONING_MAX_TOKENS). +# ARCVISUAL_DIAGRAM_AGENT_URL=https://arcvisual.vercel.app/api/diagram +# ARCVISUAL_INTERNAL_SECRET= # long random string, same value on both projects + # Formula-chain scenes allowed per paper. Past this, transform_chain proposals are # re-cast as drawn concept diagrams of the same claim. # ARCVISUAL_MAX_FORMULA_SCENES=2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4298e45..7aee332 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,7 +108,7 @@ jobs: - run: pytest tests/test_render.py -m slow -v reader: - name: reader typecheck + build + name: reader typecheck + tests + build runs-on: ubuntu-latest defaults: run: @@ -122,4 +122,5 @@ jobs: cache-dependency-path: reader/package.json - run: npm install --no-audit --no-fund - run: npm run typecheck + - run: npm test - run: npm run build diff --git a/README.md b/README.md index 3abc5f8..52d21d2 100644 --- a/README.md +++ b/README.md @@ -333,6 +333,32 @@ Three decisions worth knowing: `ANTHROPIC_BASE_URL` routes the Anthropic provider through any compatible gateway (Dedalus Labs, a proxy). Same SDK, same model ids — a setting, not a fourth provider. +### The diagram agent (TypeScript, tool calling) + +`reader/app/api/diagram` is a small TypeScript agent harness in the reader's +Next.js app; it runs server-side, so the key never reaches a browser. A model draws a +`concept_diagram` by calling one tool, `submit_diagram`, with the whole diagram: +elements, arrows and steps. The diagram is accepted as soon as it has no problems. +Otherwise the tool lists every problem at once: unknown ids, two elements in one +cell, marks on elements without items, or a runtime over 70 s. Runtime is measured +with `planConceptDiagram`, the code that animates the scene in the browser. + +The tool is deliberately coarse. Each turn on the free endpoint costs about 15 s, and +a first version with separate `draw` / `script` / `finish` tools used all five turns +(75 s) because the model called them one at a time. Now the good case is one turn +and each fix one more. `reasoning_details` is passed back between turns. + +Each call has its own timeout (90 s) within the step's deadline. A free model that +is slow, spent for the day or withdrawn hands over to the next model. +`lib/harness/harness.test.ts` covers all of this (`npm test`). + +The Python pipeline calls the agent for a scene's first attempt when +`ARCVISUAL_DIAGRAM_AGENT_URL` and `ARCVISUAL_INTERNAL_SECRET` are set +(`arcvisual/generate/diagram_agent.py`). It passes the remaining step budget, and +validates the result exactly as it validates one-shot output. If the agent isn't +configured, is unreachable, runs out of time or returns nothing, the scene falls +back to one-shot generation. + ### Long-context presets (100K–260K tokens per request) `arcvisual/providers/longcontext_provider.py` is one OpenAI-compatible provider with diff --git a/arcvisual/analyze/single_pass.py b/arcvisual/analyze/single_pass.py index 870713e..8a5e556 100644 --- a/arcvisual/analyze/single_pass.py +++ b/arcvisual/analyze/single_pass.py @@ -317,11 +317,10 @@ def _apply( #: lists can be paired later without guessing. kept_raw_indices: list[int] = [] for i, c in enumerate(raw.concepts): - section = resolve(c.section_id) + section, span = _ground(sb, resolve(c.section_id), c.quote) if section is None: report.concepts_dropped_ungrounded += 1 continue - span = span_for_text(section, c.quote) if span is None: report.concepts_dropped_ungrounded += 1 # Log the quote, not just the name. "dropped ungrounded concept 'X'" says @@ -391,12 +390,8 @@ def _apply( report.opportunities_dropped_unavailable += 1 log.info("dropped %s: no template in this build", o.archetype) continue - section = resolve(o.section_id) - if section is None: - report.opportunities_dropped_ungrounded += 1 - continue - span = span_for_text(section, o.quote) - if span is None: + section, span = _ground(sb, resolve(o.section_id), o.quote) + if section is None or span is None: report.opportunities_dropped_ungrounded += 1 log.info("dropped ungrounded opportunity %r", o.claim[:60]) continue @@ -405,10 +400,26 @@ def _apply( # Fall back to any concept grounded in the same section rather than # discarding a well-grounded proposal over a naming mismatch. same_section = [c.id for c in concepts if c.span.section_id == section.id] - if not same_section: - report.opportunities_dropped_unknown_concept += 1 - continue - concept_id = same_section[0] + if same_section: + concept_id = same_section[0] + else: + # The opportunity is grounded by its own quote; only its concept + # failed to ground. Dropping it here cascaded on a real paper: two + # of its concepts survived, so every opportunity elsewhere was lost + # and the article shipped with no visuals at all. + concept_id = f"c{len(raw.concepts) + i:03d}" + concept = Concept( + id=concept_id, + name=o.concept_name or o.claim[:60], + statement=o.claim, + span=span, + depends_on=[], + centrality=o.centrality, + ) + concepts.append(concept) + by_cid[concept_id] = concept + name_to_id[_norm(concept.name)] = concept_id + report.concepts_kept = len(concepts) candidates.append( VisualOpportunity( id=f"o{i:03d}", @@ -426,6 +437,9 @@ def _apply( report.opportunities_dropped_triage = len(candidates) - len(kept) report.kept_opportunities = len(kept) + # Opportunities may have grounded concepts of their own; sections list them too. + for section in sb.sections: + section.concept_ids = [c.id for c in concepts if c.span.section_id == section.id] sb.concepts = concepts sb.opportunities = kept sb.reading_order = _reading_order(sb, concepts) @@ -437,6 +451,25 @@ def _apply( return sb, report +def _ground(sb: Storyboard, claimed: Section | None, quote: str): + """``(section, span)`` for a quote: the cited section first, then every other. + + Models attribute a correct quote to a neighbouring section often enough that a + single-section search loses real, verbatim text. The span still points at the + exact characters wherever they were found; only the attribution is corrected. + Returns ``(claimed, None)`` when the quote is nowhere, ``(None, None)`` when no + section was resolvable and the quote is nowhere either. + """ + if claimed is not None and (span := span_for_text(claimed, quote)) is not None: + return claimed, span + for section in sb.sections: + if section is claimed: + continue + if (span := span_for_text(section, quote)) is not None: + return section, span + return claimed, None + + def _section_resolver(sb: Storyboard): """Resolve a model's section reference to a real section. diff --git a/arcvisual/config.py b/arcvisual/config.py index b2e1432..4bd3949 100644 --- a/arcvisual/config.py +++ b/arcvisual/config.py @@ -15,7 +15,7 @@ #: Bumped whenever pipeline behaviour changes in a way that should produce a #: different article for the same paper. Part of the L3 cache key and of the #: (paper_id, pipeline_version) idempotency key on `jobs`. -PIPELINE_VERSION = "0.3.0-diagrams" +PIPELINE_VERSION = "0.3.1-grounding" #: Pinned render environment. Any change here invalidates every L2 artifact. MANIM_VERSION = "0.18.1" @@ -620,6 +620,12 @@ class Settings: #: well under the platform's function limit (300s on Vercel Hobby): a scene #: started near the end must still finish inside the same invocation. step_budget_s: int = 200 + #: The TypeScript diagram agent (reader/app/api/diagram). When set, concept + #: diagrams are drawn by a model calling validated tools instead of one-shot JSON; + #: on any failure codegen falls back to the one-shot path. + diagram_agent_url: str = "" + #: Shared with the agent route; it refuses every request without it. + internal_secret: str = "" @property def client_render(self) -> bool: @@ -754,6 +760,8 @@ def settings() -> Settings: strict_ownership=env("STRICT_OWNERSHIP", "1") != "0", render_mode=env("ARCVISUAL_RENDER_MODE", "manim"), step_budget_s=int(env("ARCVISUAL_STEP_BUDGET_S", "200")), + diagram_agent_url=env("ARCVISUAL_DIAGRAM_AGENT_URL", ""), + internal_secret=env("ARCVISUAL_INTERNAL_SECRET", ""), budgets=Budgets( scene_concurrency=int(env("ARCVISUAL_SCENE_CONCURRENCY", "4")), max_formula_scenes=int(env("ARCVISUAL_MAX_FORMULA_SCENES", "2")), diff --git a/arcvisual/generate/codegen.py b/arcvisual/generate/codegen.py index 7772d11..ab90882 100644 --- a/arcvisual/generate/codegen.py +++ b/arcvisual/generate/codegen.py @@ -200,16 +200,20 @@ def generate_scene( usage = Usage(attributed=True) # genuinely free: no call was made notes = ["heuristic parameters — no model provider configured"] else: - raw_params, beats, scrubbable, usage = _call_provider( - sb, - opportunity, - source_text, - provider=provider, - previous=previous, - findings=findings, - attempt=attempt, - ) - notes = [] + drawn = _draw_with_agent(sb, opportunity, provider, findings) + if drawn is not None: + raw_params, beats, scrubbable, usage, notes = drawn + else: + raw_params, beats, scrubbable, usage = _call_provider( + sb, + opportunity, + source_text, + provider=provider, + previous=previous, + findings=findings, + attempt=attempt, + ) + notes = [] cost = usage.cost_usd # Validate before building the spec: an invalid parameter set must not reach @@ -267,6 +271,36 @@ def generate_scene( ) +def _draw_with_agent( + sb: Storyboard, + opportunity: VisualOpportunity, + provider: Provider, + findings: list[str] | None, +) -> tuple[dict[str, Any], list[Beat], bool, Usage, list[str]] | None: + """A first-attempt concept diagram drawn by the TypeScript tool-calling agent. + + Only the first attempt: a repair carries Gate 1's findings, which the one-shot + path already feeds back. None means "use the one-shot path" — the agent is not + configured, ran out of time, or returned no accepted diagram. + """ + from arcvisual.generate import diagram_agent + + if opportunity.archetype is not Archetype.CONCEPT_DIAGRAM or findings: + return None + if not diagram_agent.configured(): + return None + budget_fn = getattr(provider, "call_budget", None) + budget = float(budget_fn()) if callable(budget_fn) else 120.0 + drawn = diagram_agent.draw(sb, opportunity, budget_s=budget) + if drawn is None: + return None + captions = drawn.captions or ["(diagram)"] + beats = fit_beats(captions, MIN_BEAT_S * 2 * len(captions)) + note = f"drawn by the diagram agent in {drawn.turns} turn(s) on {drawn.model}" + # Tokens were spent by the agent's own calls, which report no price. + return drawn.params, beats, False, Usage(attributed=False), [note, *drawn.notes] + + def fit_beats(captions: list[str], total_s: float) -> list[Beat]: """Lay captions end to end across a runtime the template dictates. diff --git a/arcvisual/generate/diagram_agent.py b/arcvisual/generate/diagram_agent.py new file mode 100644 index 0000000..7cdf7dd --- /dev/null +++ b/arcvisual/generate/diagram_agent.py @@ -0,0 +1,103 @@ +"""Client for the TypeScript diagram agent (``reader/app/api/diagram``). + +The agent draws a ``concept_diagram`` by calling tools that validate each step as it +is taken, so a mistake costs one more turn of the same conversation rather than a +whole regeneration. This module only asks it for parameters; everything after that +(the template's validation, beats, Gate 1) is the same path one-shot codegen takes. + +It never fails a scene. Not configured, out of time, unreachable, or no accepted +diagram: it returns None and codegen falls back to the one-shot call. +""" + +from __future__ import annotations + +import logging +from dataclasses import dataclass, field +from typing import Any + +from arcvisual.config import settings +from arcvisual.storyboard import Storyboard, VisualOpportunity + +log = logging.getLogger(__name__) + +#: Below this, the agent cannot finish a turn on the free endpoint (~15s each). +MIN_BUDGET_S = 30.0 +#: Never ask for more: the route caps itself at 250s inside a 300s function. +MAX_BUDGET_S = 240.0 + + +@dataclass +class AgentDiagram: + params: dict[str, Any] + captions: list[str] + turns: int + model: str + notes: list[str] = field(default_factory=list) + + +def configured() -> bool: + cfg = settings() + return bool(cfg.diagram_agent_url and cfg.internal_secret) + + +def draw( + sb: Storyboard, + opportunity: VisualOpportunity, + *, + budget_s: float, + client: Any = None, +) -> AgentDiagram | None: + """Ask the agent for one diagram's parameters, or None to fall back.""" + cfg = settings() + if not configured(): + return None + budget_s = min(budget_s, MAX_BUDGET_S) + if budget_s < MIN_BUDGET_S: + log.info("diagram agent skipped: only %.0fs left", budget_s) + return None + + section = sb.section(opportunity.span.section_id) + concept = sb.concept(opportunity.concept_id) + payload = { + "title": sb.paper.title, + "claim": opportunity.claim, + "concept": f"{concept.name} — {concept.statement}" if concept else "", + "quote": opportunity.span.resolve(section), + "section": section.raw[:12000], + "equations": [e.latex for e in sb.equations if e.span.section_id == section.id][ + :6 + ], + "budget_s": round(budget_s), + } + headers = {"x-arcvisual-key": cfg.internal_secret} + try: + if client is None: + import httpx + + # The agent bounds itself by budget_s; this only catches a hung network. + with httpx.Client(timeout=budget_s + 15) as http: + response = http.post(cfg.diagram_agent_url, json=payload, headers=headers) + else: + response = client.post(cfg.diagram_agent_url, json=payload, headers=headers) + except Exception as exc: # network trouble is a fallback, never a failed scene + log.warning("diagram agent unreachable: %s", exc) + return None + if response.status_code != 200: + log.warning( + "diagram agent answered %s: %s", response.status_code, response.text[:200] + ) + return None + try: + body = response.json() + except ValueError: + return None + if not body.get("ok") or not isinstance(body.get("params"), dict): + log.info("diagram agent gave no diagram: %s", "; ".join(body.get("notes") or [])) + return None + return AgentDiagram( + params=body["params"], + captions=[c for c in body.get("captions") or [] if isinstance(c, str)], + turns=int(body.get("turns") or 0), + model=str(body.get("model") or ""), + notes=[n for n in body.get("notes") or [] if isinstance(n, str)], + ) diff --git a/arcvisual/ingest/latex.py b/arcvisual/ingest/latex.py index 1f84271..2b50e2c 100644 --- a/arcvisual/ingest/latex.py +++ b/arcvisual/ingest/latex.py @@ -541,7 +541,7 @@ def span_for_text(section: Section, needle: str) -> SourceSpan | None: collapsed = re.sub(r"\s+", " ", section.raw) j = collapsed.find(flat) if j == -1: - return None + return _span_for_normalised(section, needle) idx = _map_collapsed_offset(section.raw, j) if idx is None: return None @@ -550,6 +550,121 @@ def span_for_text(section: Section, needle: str) -> SourceSpan | None: return _span(section.id, section.raw, idx, idx + len(needle)) +#: TeX that carries no words a reader would quote: citations, cross-references, +#: labels and footnote markers. Removed whole, argument included. +_NOISE_CMD = re.compile( + r"\\(?:cite[a-z]*|ref|eqref|autoref|cref|Cref|label|footnote|url|href)\*?" + r"(?:\[[^\]]*\])*\{[^{}]*\}" +) +#: Any other command name: dropped, its arguments kept (\emph{x} reads as x). +_ANY_CMD = re.compile(r"\\[A-Za-z]+\*?") +_FOLD = { + "\u2018": "'", + "\u2019": "'", + "\u201c": '"', + "\u201d": '"', + "``": '"', + "''": '"', + "\u2013": "-", + "\u2014": "-", + "--": "-", + "~": " ", + "\u00a0": " ", +} +#: Shortest verbatim run, in words, that grounds a quote the model only partly +#: copied — long enough that it cannot match by accident. +_MIN_RUN_WORDS = 8 + + +def _normalise(text: str) -> tuple[str, list[int]]: + """Lower-case words-and-punctuation view of ``text``, with an offset map. + + ``out[k]`` came from ``text[index[k]]``, so a match found in the normalised view + maps back to an exact span of the original. That is what keeps tolerant matching + honest: the span still points at real characters of the paper. + """ + dropped = [False] * len(text) + for m in _NOISE_CMD.finditer(text): + for i in range(m.start(), m.end()): + dropped[i] = True + for m in _ANY_CMD.finditer(text): + for i in range(m.start(), m.end()): + dropped[i] = True + chars: list[str] = [] + index: list[int] = [] + i = 0 + while i < len(text): + if dropped[i]: + i += 1 + continue + two = text[i : i + 2] + if two in _FOLD: + rep, step = _FOLD[two], 2 + else: + ch = text[i] + rep, step = _FOLD.get(ch, ch), 1 + if ch in "${}\\": + rep = " " + for r in rep: + if r.isspace(): + if chars and chars[-1] != " ": + chars.append(" ") + index.append(i) + else: + chars.append(r.lower()) + index.append(i) + i += step + # No space before closing punctuation: "attention , and" == "attention, and". + out_c: list[str] = [] + out_i: list[int] = [] + for c, k in zip(chars, index, strict=True): + if c in ",.;:)!?" and out_c and out_c[-1] == " ": + out_c.pop() + out_i.pop() + out_c.append(c) + out_i.append(k) + if out_c and out_c[-1] == " ": # never a leading space: see the append above + out_c.pop() + out_i.pop() + return "".join(out_c), out_i + + +def _span_for_normalised(section: Section, needle: str) -> SourceSpan | None: + """Ground a quote the model cleaned up: TeX dropped, quotes and dashes changed. + + Models read ``$\\sqrt{d_k}$~\\cite{x}`` and quote "sqrt d_k", or straighten a + quotation mark, and an exact search drops a correct quote. Both sides are + normalised the same way and the match is mapped back to the raw text, so the + span is still exactly what the paper says. A quote the model only partly copied + grounds to its longest verbatim run, when that run is long enough not to be a + coincidence. + """ + hay, index = _normalise(section.raw) + want, _ = _normalise(needle) + if not want or not hay: + return None + j = hay.find(want) + if j != -1: + return _span_from(section, index, j, len(want)) + words = want.split(" ") + if len(words) < _MIN_RUN_WORDS: + return None + need = max(_MIN_RUN_WORDS, int(len(words) * 0.6 + 0.999)) + for size in range(len(words), need - 1, -1): + for start in range(0, len(words) - size + 1): + run = " ".join(words[start : start + size]) + j = hay.find(run) + if j != -1: + return _span_from(section, index, j, len(run)) + return None + + +def _span_from(section: Section, index: list[int], j: int, n: int) -> SourceSpan: + lo = index[j] + hi = index[j + n - 1] + 1 + return _span(section.id, section.raw, lo, hi) + + def _map_collapsed_offset(raw: str, collapsed_idx: int) -> int | None: """Translate an offset in whitespace-collapsed text back into ``raw``.""" seen = 0 diff --git a/arcvisual/providers/longcontext_provider.py b/arcvisual/providers/longcontext_provider.py index 90df1af..31e3136 100644 --- a/arcvisual/providers/longcontext_provider.py +++ b/arcvisual/providers/longcontext_provider.py @@ -154,6 +154,12 @@ def set_deadline(self, deadline: float | None) -> None: """ self._deadline = deadline + def call_budget(self) -> float: + """Seconds the next model call may take: the per-call cap or what is left of + the step, whichever is smaller. Callers outside the provider (the diagram + agent) are held to the same deadline.""" + return self._call_budget() + def _call_budget(self) -> float: budget = self._cfg.call_timeout_s if self._deadline is not None: diff --git a/reader/app/api/diagram/route.ts b/reader/app/api/diagram/route.ts new file mode 100644 index 0000000..023f711 --- /dev/null +++ b/reader/app/api/diagram/route.ts @@ -0,0 +1,67 @@ +/** + * POST /api/diagram — the TypeScript diagram agent, called by the Python pipeline. + * + * Server-side only: the OpenRouter key lives in this function's environment and never + * reaches a browser. Callers authenticate with `ARCVISUAL_INTERNAL_SECRET`; without + * that secret configured the route refuses everything, so a deployment that has not + * opted in exposes no model on the public internet. + */ + +import { timingSafeEqual } from "node:crypto"; +import { drawDiagram, type DiagramRequest } from "../../../lib/harness/diagramAgent"; + +export const runtime = "nodejs"; +export const dynamic = "force-dynamic"; +export const maxDuration = 300; + +const DEFAULT_MODELS = + "nvidia/nemotron-3.5-lightning:free,qwen/qwen3-235b-a22b-2507,openai/gpt-oss-120b,deepseek/deepseek-v3.2"; +/** Never let the agent run into the platform's 300s limit. */ +const MAX_BUDGET_S = 250; + +function authorised(req: Request): boolean { + const secret = process.env.ARCVISUAL_INTERNAL_SECRET ?? ""; + const given = req.headers.get("x-arcvisual-key") ?? ""; + if (!secret || given.length !== secret.length) return false; + return timingSafeEqual(Buffer.from(given), Buffer.from(secret)); +} + +function str(v: unknown, max: number): string { + return typeof v === "string" ? v.slice(0, max) : ""; +} + +export async function POST(req: Request): Promise { + if (!authorised(req)) return Response.json({ error: "unauthorised" }, { status: 401 }); + const apiKey = process.env.OPENROUTER_API_KEY ?? ""; + if (!apiKey) return Response.json({ error: "OPENROUTER_API_KEY is not set" }, { status: 503 }); + + let body: Record; + try { + body = (await req.json()) as Record; + } catch { + return Response.json({ error: "body must be JSON" }, { status: 400 }); + } + const request: DiagramRequest = { + title: str(body.title, 300), + claim: str(body.claim, 600), + concept: str(body.concept, 600), + quote: str(body.quote, 3000), + section: str(body.section, 12000), + equations: Array.isArray(body.equations) ? body.equations.filter((e): e is string => typeof e === "string").slice(0, 6) : [], + }; + if (!request.claim) return Response.json({ error: "claim is required" }, { status: 400 }); + + const budgetS = Math.min(MAX_BUDGET_S, Math.max(10, Number(body.budget_s) || 120)); + const result = await drawDiagram(request, { + apiKey, + baseUrl: process.env.OPENROUTER_BASE_URL || undefined, + models: (process.env.DIAGRAM_MODELS || process.env.LLM_MODEL_CODEGEN || DEFAULT_MODELS) + .split(",") + .map((m) => m.trim()) + .filter(Boolean), + // `||`, not `??`: an empty variable must not become 0, which means "no cap". + reasoningMaxTokens: Number(process.env.LLM_REASONING_MAX_TOKENS || 800), + deadline: Date.now() + budgetS * 1000, + }); + return Response.json(result); +} diff --git a/reader/lib/harness/diagramAgent.ts b/reader/lib/harness/diagramAgent.ts new file mode 100644 index 0000000..2a6381a --- /dev/null +++ b/reader/lib/harness/diagramAgent.ts @@ -0,0 +1,138 @@ +/** + * The diagram agent: a model draws one `concept_diagram` by calling tools. + * + * Built for a slow free model, so turns are the unit of cost: one tool takes the + * whole diagram and accepts it the moment it is sound, so the good case is one turn. + * Problems come back in the same conversation, so a fix costs one more turn instead + * of a whole regeneration. The loop stops at a turn limit and at the + * caller's deadline, whichever comes first. + */ + +import { Chat, OutOfTime, NoModelLeft, addUsage, type ClientOptions, type Message, type Usage } from "./openrouter"; +import { TOOLS, emptyState, runTool, toParams } from "./diagramTools"; + +export interface DiagramRequest { + title: string; + claim: string; + concept: string; + quote: string; + /** The section the idea comes from; names, structure and numbers to draw from. */ + section: string; + equations: string[]; +} + +export interface DiagramResult { + ok: boolean; + params: Record | null; + captions: string[]; + turns: number; + model: string | null; + usage: Usage; + notes: string[]; +} + +export const SYSTEM = `You draw one diagram that explains one idea from a research paper, and script how it animates. + +You have one tool, submit_diagram. Call it with the WHOLE diagram — elements, arrows and steps — in your first reply. It is accepted at once if nothing is wrong; otherwise it lists every problem. Fix them all and call it again with the whole corrected diagram. Write no prose outside the tool call. + +DRAW THE OBJECTS THE IDEA IS ABOUT +- Use the paper's own things and names: "Queries Q", "Keys K", "Expert 3". Never "Input A". +- Pick the kind that matches what the thing IS: a sequence of words or patches is tokens; a set of vectors is a stack; a pairwise matrix (attention, similarity) is a grid; a probability or weighting is bars; a transformation is an op (×, +, ⊕, softmax, concat); a learned component is a block; a repeated or grouped region is a container spanning its members. +- Labels in Unicode: QKᵀ, √dₖ, x₁…xₙ. No LaTeX, no dollar signs. At most one text element, as an annotation. +- Use numbers the paper gives in values; otherwise leave values empty. + +LAYOUT: data flows left to right over columns 0-7; parallel streams use rows 0-5. One element per cell; tall things get row_span, wide things col_span. 5-12 elements. + +SCRIPT 3-7 STEPS, ONE IDEA EACH: inputs first, then each operation, then the result. show brings parts in; flow sends a pulse along a path of ids; marks light up cells or items; relabel changes a label when a thing changes meaning; focus points at the contribution. Each caption is one plain sentence about what is on screen now.`; + +export function userMessage(req: DiagramRequest): string { + const eqs = req.equations.length ? `\nEQUATIONS IN THIS SECTION (verbatim)\n${req.equations.slice(0, 6).join("\n")}\n` : ""; + return `PAPER: ${req.title} + +THE IDEA TO DRAW +${req.claim} + +THE CONCEPT +${req.concept} + +VERBATIM FROM THE PAPER (ground truth) +""" +${req.quote.slice(0, 1500)} +""" +${eqs} +THE SECTION IT COMES FROM +""" +${req.section.slice(0, 12000)} +"""`; +} + +export interface AgentOptions extends ClientOptions { + /** Absolute deadline, in the clock `now` reports (ms). */ + deadline: number; + maxTurns?: number; +} + +export async function drawDiagram(req: DiagramRequest, opts: AgentOptions): Promise { + const chat = new Chat(opts); + const state = emptyState(); + const messages: Message[] = [ + { role: "system", content: SYSTEM }, + { role: "user", content: userMessage(req) }, + ]; + let usage: Usage = { prompt: 0, completion: 0, reasoning: 0 }; + let model: string | null = null; + const notes: string[] = []; + const maxTurns = opts.maxTurns ?? 4; + let nudged = false; + + for (let turn = 1; turn <= maxTurns; turn++) { + let reply; + try { + reply = await chat.send(messages, TOOLS, opts.deadline); + } catch (err) { + if (err instanceof OutOfTime || err instanceof NoModelLeft) { + notes.push(err.message); + return { ok: false, params: null, captions: [], turns: turn - 1, model, usage, notes }; + } + throw err; + } + usage = addUsage(usage, reply.usage); + model = reply.model; + const msg = reply.message; + // Passed back unmodified: the model continues its reasoning on the next turn. + messages.push({ + role: "assistant", + content: msg.content ?? "", + tool_calls: msg.tool_calls, + ...(msg.reasoning_details !== undefined ? { reasoning_details: msg.reasoning_details } : {}), + }); + + const calls = msg.tool_calls ?? []; + if (!calls.length) { + if (nudged) { + notes.push("the model answered without calling a tool, twice"); + break; + } + nudged = true; + messages.push({ role: "user", content: "Call submit_diagram now with the whole diagram." }); + continue; + } + for (const call of calls) { + const { reply: out, done } = runTool(state, call.function.name, call.function.arguments); + messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(out) }); + if (done) { + return { + ok: true, + params: toParams(state), + captions: state.steps.map((s) => s.caption), + turns: turn, + model, + usage, + notes, + }; + } + } + } + notes.push(`no accepted diagram within ${maxTurns} turns`); + return { ok: false, params: null, captions: [], turns: maxTurns, model, usage, notes }; +} diff --git a/reader/lib/harness/diagramTools.ts b/reader/lib/harness/diagramTools.ts new file mode 100644 index 0000000..b241931 --- /dev/null +++ b/reader/lib/harness/diagramTools.ts @@ -0,0 +1,276 @@ +/** + * The tools a model draws a `concept_diagram` with, and the checks behind them. + * + * One-shot generation returns a whole diagram as JSON and learns it was wrong only + * from Gate 1, a full round trip later. Here every tool call is checked as it is made + * and answers with concrete problems ("q and k share cell (0, 0)"), so the model + * fixes them in the same conversation. + * + * There is one tool, deliberately: `submit_diagram` takes the whole diagram — + * elements, arrows and steps — and is accepted the moment it has no problems. Each + * turn on the free endpoint costs ~15s, and a live run with separate draw / script / + * finish tools took all five allowed turns (75s) because the model called them one + * at a time. One coarse tool makes the good case one turn and each fix one more. + * + * Runtime is measured with `planConceptDiagram`, the very function the browser uses + * to animate the scene, so "fits the runtime cap" means exactly what the reader + * will play. The Python template validates the result again before it is stored. + */ + +import { planConceptDiagram } from "../scenes/plans"; +import type { ToolDef } from "./openrouter"; + +export const KINDS = ["block", "op", "tokens", "stack", "grid", "bars", "text", "container"] as const; +export const TONES = ["neutral", "accent", "input", "output", "muted"] as const; +const ITEM_KINDS = new Set(["tokens", "stack", "grid", "bars"]); +const ID = /^[A-Za-z0-9_]+$/; +const MAX_COLUMNS = 8; +const MAX_ROWS = 6; +/** Same ceiling as concept_diagram.MAX_RUNTIME_S. */ +export const MAX_RUNTIME_S = 70; + +export interface DiagramElement { + id: string; + kind: string; + label: string; + column: number; + row: number; + col_span?: number; + row_span?: number; + cells?: string[]; + size?: number; + values?: number[]; + tone?: string; + note?: string; +} + +export interface DiagramConnection { + src: string; + dst: string; + label?: string | null; + dashed?: boolean; +} + +export interface DiagramStep { + caption: string; + show?: string[]; + focus?: string[]; + flow?: string[]; + marks?: { target: string; item: number; col?: number }[]; + relabel?: { id: string; label: string }[]; +} + +export interface DiagramState { + title: string | null; + elements: DiagramElement[]; + connections: DiagramConnection[]; + steps: DiagramStep[]; +} + +export interface ToolReply { + ok: boolean; + problems: string[]; + /** Advisory only; nothing here blocks `finish`. */ + notes: string[]; +} + +export function emptyState(): DiagramState { + return { title: null, elements: [], connections: [], steps: [] }; +} + +const elementSchema = { + type: "object", + properties: { + id: { type: "string", description: "Letters, digits and _ only." }, + kind: { type: "string", enum: [...KINDS] }, + label: { type: "string", description: "Short; Unicode maths (QKᵀ, √dₖ), never LaTeX." }, + column: { type: "integer", minimum: 0, maximum: MAX_COLUMNS - 1 }, + row: { type: "integer", minimum: 0, maximum: MAX_ROWS - 1 }, + col_span: { type: "integer", minimum: 1, maximum: MAX_COLUMNS }, + row_span: { type: "integer", minimum: 1, maximum: MAX_ROWS }, + cells: { type: "array", items: { type: "string" }, description: "Item labels (tokens/stack/bars) or grid row/column labels." }, + size: { type: "integer", minimum: 0, maximum: 8, description: "Item count, or N for an N×N grid." }, + values: { type: "array", items: { type: "number" }, description: "bars: one height each. grid: N×N, row-major. Only numbers the paper gives." }, + tone: { type: "string", enum: [...TONES] }, + note: { type: "string", description: "A short second line, e.g. a shape like n × d." }, + }, + required: ["id", "kind", "label", "column", "row"], +}; + +const stepSchema = { + type: "object", + properties: { + caption: { type: "string", description: "One plain sentence, under 90 characters." }, + show: { type: "array", items: { type: "string" } }, + focus: { type: "array", items: { type: "string" } }, + flow: { type: "array", items: { type: "string" }, description: "A path of element ids, in order." }, + marks: { + type: "array", + items: { + type: "object", + properties: { target: { type: "string" }, item: { type: "integer" }, col: { type: "integer" } }, + required: ["target", "item"], + }, + }, + relabel: { + type: "array", + items: { + type: "object", + properties: { id: { type: "string" }, label: { type: "string" } }, + required: ["id", "label"], + }, + }, + }, + required: ["caption"], +}; + +export const TOOL_NAME = "submit_diagram"; + +export const TOOLS: ToolDef[] = [ + { + type: "function", + function: { + name: TOOL_NAME, + description: + "Submit the whole diagram: elements, arrows and animation steps. It is accepted at once if it has no " + + "problems; otherwise you get every problem in one list (unknown ids, two elements in one cell, marks on " + + "elements without items, runtime over 70s). Fix them all and submit the whole diagram again.", + parameters: { + type: "object", + properties: { + title: { type: "string", description: "Optional heading, under 60 characters." }, + elements: { type: "array", items: elementSchema, minItems: 2, maxItems: 16 }, + connections: { + type: "array", + maxItems: 20, + items: { + type: "object", + properties: { + src: { type: "string" }, + dst: { type: "string" }, + label: { type: "string" }, + dashed: { type: "boolean" }, + }, + required: ["src", "dst"], + }, + }, + steps: { type: "array", items: stepSchema, minItems: 1, maxItems: 8 }, + }, + required: ["elements", "connections", "steps"], + }, + }, + }, +]; + +function asArray(v: unknown): T[] { + return Array.isArray(v) ? (v as T[]) : []; +} + +export function checkDrawing(state: DiagramState): string[] { + const problems: string[] = []; + const { elements, connections } = state; + if (elements.length < 2) problems.push("draw at least 2 elements"); + if (elements.length > 16) problems.push(`${elements.length} elements; at most 16`); + const ids = new Set(); + const cells = new Map(); + for (const e of elements) { + if (!e.id || !ID.test(e.id)) problems.push(`id ${JSON.stringify(e.id)}: use letters, digits and _ only`); + if (ids.has(e.id)) problems.push(`duplicate id ${e.id}`); + ids.add(e.id); + if (!(KINDS as readonly string[]).includes(e.kind)) problems.push(`${e.id}: unknown kind ${JSON.stringify(e.kind)}`); + if (!Number.isInteger(e.column) || e.column < 0 || e.column >= MAX_COLUMNS) problems.push(`${e.id}: column must be 0-7`); + if (!Number.isInteger(e.row) || e.row < 0 || e.row >= MAX_ROWS) problems.push(`${e.id}: row must be 0-5`); + if (e.kind === "container") continue; + const cs = Math.max(1, e.col_span ?? 1); + const rs = Math.max(1, e.row_span ?? 1); + for (let c = e.column; c < Math.min(e.column + cs, MAX_COLUMNS); c++) { + for (let r = e.row; r < Math.min(e.row + rs, MAX_ROWS); r++) { + const key = `${c},${r}`; + const other = cells.get(key); + if (other && other !== e.id) problems.push(`${e.id} and ${other} share grid cell (${c}, ${r}); move one`); + cells.set(key, e.id); + } + } + } + const seen = new Set(); + for (const c of connections) { + for (const end of [c.src, c.dst]) if (!ids.has(end)) problems.push(`arrow ${c.src}->${c.dst}: no element ${JSON.stringify(end)}`); + if (c.src === c.dst) problems.push(`arrow ${c.src}->${c.dst} points at itself`); + const key = `${c.src}>${c.dst}`; + if (seen.has(key)) problems.push(`arrow ${key} drawn twice`); + seen.add(key); + } + return [...new Set(problems)]; +} + +export function checkScript(state: DiagramState): { problems: string[]; notes: string[] } { + const problems: string[] = []; + const notes: string[] = []; + const byId = new Map(state.elements.map((e) => [e.id, e])); + if (!state.steps.length) problems.push("script at least 1 step"); + if (state.steps.length > 8) problems.push(`${state.steps.length} steps; at most 8`); + state.steps.forEach((s, i) => { + const n = i + 1; + if (!s.caption?.trim()) problems.push(`step ${n}: needs a caption`); + else if (s.caption.length > 90) notes.push(`step ${n}: caption is ${s.caption.length} characters and will be shortened to 90`); + const named = [...asArray(s.show), ...asArray(s.focus), ...asArray(s.flow)]; + for (const r of asArray<{ id: string }>(s.relabel)) named.push(r.id); + for (const id of named) if (!byId.has(id)) problems.push(`step ${n}: no element ${JSON.stringify(id)}`); + for (const m of asArray<{ target: string; item: number; col?: number }>(s.marks)) { + const t = byId.get(m.target); + if (!t) problems.push(`step ${n}: mark on unknown element ${JSON.stringify(m.target)}`); + else if (!ITEM_KINDS.has(t.kind)) problems.push(`step ${n}: ${m.target} is a ${t.kind}; marks go on tokens, stack, grid or bars`); + } + }); + const shown = new Set(state.steps.flatMap((s) => asArray(s.show))); + const never = state.elements.filter((e) => !shown.has(e.id)).map((e) => e.id); + if (never.length) notes.push(`never shown, so they appear in the first step that uses them (or the first step): ${never.join(", ")}`); + if (!problems.length && state.elements.length) { + const plan = planConceptDiagram(toParams(state)); + if (plan && plan.duration > MAX_RUNTIME_S) { + problems.push( + `the script runs ${plan.duration.toFixed(0)}s; keep it under ${MAX_RUNTIME_S}s (shorter flow paths, fewer steps)`, + ); + } else if (plan) { + notes.push(`runs ${plan.duration.toFixed(1)}s`); + } + } + return { problems: [...new Set(problems)], notes }; +} + +/** The `concept_diagram` params the Python template validates. */ +export function toParams(state: DiagramState): Record { + return { + ...(state.title ? { title: state.title } : {}), + elements: state.elements, + connections: state.connections, + steps: state.steps, + }; +} + +/** Apply one tool call to the state and answer it. `done` means accepted. */ +export function runTool( + state: DiagramState, + name: string, + rawArgs: string, +): { reply: ToolReply; done: boolean } { + if (name !== TOOL_NAME) { + return { reply: { ok: false, problems: [`no tool named ${JSON.stringify(name)}; call ${TOOL_NAME}`], notes: [] }, done: false }; + } + let args: Record; + try { + args = rawArgs.trim() ? (JSON.parse(rawArgs) as Record) : {}; + } catch { + return { reply: { ok: false, problems: [`arguments to ${name} were not valid JSON`], notes: [] }, done: false }; + } + state.elements = asArray(args.elements); + state.connections = asArray(args.connections); + state.steps = asArray(args.steps); + state.title = typeof args.title === "string" ? args.title.slice(0, 60) || null : null; + const drawing = checkDrawing(state); + // Script problems are only meaningful once the drawing is sound; report both + // when the drawing is fine, so one turn can fix everything. + const script = drawing.length ? { problems: [], notes: [] } : checkScript(state); + const problems = [...drawing, ...script.problems]; + return { reply: { ok: !problems.length, problems, notes: script.notes }, done: !problems.length }; +} diff --git a/reader/lib/harness/harness.test.ts b/reader/lib/harness/harness.test.ts new file mode 100644 index 0000000..b5eaa50 --- /dev/null +++ b/reader/lib/harness/harness.test.ts @@ -0,0 +1,289 @@ +import { describe, expect, it } from "vitest"; +import { drawDiagram, type DiagramRequest } from "./diagramAgent"; +import { checkDrawing, checkScript, emptyState, runTool, type DiagramState } from "./diagramTools"; +import { Chat, NoModelLeft, OutOfTime, type Message } from "./openrouter"; + +// -- fixtures ----------------------------------------------------------------- // + +const ATTENTION = { + title: "Scaled dot-product attention", + elements: [ + { id: "q", kind: "stack", label: "Queries Q", column: 0, row: 0, cells: ["q₁", "q₂", "q₃"] }, + { id: "k", kind: "stack", label: "Keys K", column: 0, row: 1, cells: ["k₁", "k₂", "k₃"] }, + { id: "dot", kind: "op", label: "QKᵀ", column: 1, row: 0, row_span: 2 }, + { id: "scores", kind: "grid", label: "scores", column: 2, row: 0, row_span: 2, size: 3 }, + { id: "sm", kind: "op", label: "softmax", column: 3, row: 0, row_span: 2 }, + { id: "out", kind: "block", label: "Output", column: 4, row: 0, row_span: 2 }, + ], + connections: [ + { src: "q", dst: "dot" }, + { src: "k", dst: "dot" }, + { src: "dot", dst: "scores" }, + { src: "scores", dst: "sm" }, + { src: "sm", dst: "out" }, + ], +}; +const STEPS = { + steps: [ + { caption: "Every token brings a query and a key.", show: ["q", "k"] }, + { caption: "Each query meets every key.", show: ["dot", "scores"], flow: ["q", "dot", "scores"] }, + { caption: "Row 1 is how well q₁ matches each key.", marks: [{ target: "scores", item: 0, col: 0 }] }, + { caption: "Softmax turns scores into weights.", show: ["sm", "out"], focus: ["out"] }, + ], +}; + +const REQUEST: DiagramRequest = { + title: "Attention Is All You Need", + claim: "Each query is scored against every key; softmax turns the scores into weights.", + concept: "Scaled dot-product attention", + quote: "We compute the dot products of the query with all keys", + section: "We compute the dot products of the query with all keys, divide each by sqrt(d_k).", + equations: [], +}; + +function state(over: Partial = {}): DiagramState { + return { ...emptyState(), ...JSON.parse(JSON.stringify(ATTENTION)), ...STEPS, ...over }; +} + +let callId = 0; +function toolCall(name: string, args: unknown) { + return { id: `call_${++callId}`, type: "function" as const, function: { name, arguments: JSON.stringify(args) } }; +} + +function reply(toolCalls: ReturnType[], extra: Record = {}) { + return new Response( + JSON.stringify({ + choices: [{ message: { role: "assistant", content: "", tool_calls: toolCalls, ...extra } }], + usage: { prompt_tokens: 100, completion_tokens: 50, completion_tokens_details: { reasoning_tokens: 20 } }, + }), + { status: 200, headers: { "Content-Type": "application/json" } }, + ); +} + +/** A fetch that answers from a script and records every request body. */ +function scriptedFetch(answers: (Response | ((init: RequestInit) => Promise))[]) { + const sent: { model: string; messages: Message[]; reasoning: unknown }[] = []; + const fn = (async (_url: string, init: RequestInit) => { + const body = JSON.parse(String(init.body)); + sent.push(body); + const next = answers.shift(); + if (!next) throw new Error("no scripted answer left"); + return typeof next === "function" ? next(init) : next; + }) as unknown as typeof fetch; + return { fn, sent }; +} + +const NO_SLEEP = async () => {}; + +// -- tools ---------------------------------------------------------------------- // + +describe("diagram tools", () => { + it("accept a sound diagram and script", () => { + expect(checkDrawing(state())).toEqual([]); + const { problems, notes } = checkScript(state()); + expect(problems).toEqual([]); + expect(notes.some((n) => n.startsWith("runs "))).toBe(true); + }); + + it("name the cells two elements share", () => { + const s = state(); + s.elements[1].row = 0; // keys onto the queries' cell + expect(checkDrawing(s)).toContain("k and q share grid cell (0, 0); move one"); + }); + + it("let a container span what it groups", () => { + const s = state(); + s.elements.push({ id: "head", kind: "container", label: "One head", column: 1, row: 0, col_span: 3, row_span: 2 }); + expect(checkDrawing(s)).toEqual([]); + }); + + it("refuse arrows and steps that name nothing", () => { + const s = state({ connections: [{ src: "q", dst: "ghost" }] }); + expect(checkDrawing(s)).toContain('arrow q->ghost: no element "ghost"'); + const t = state({ steps: [{ caption: "Look.", focus: ["ghost"] }] }); + expect(checkScript(t).problems).toContain('step 1: no element "ghost"'); + }); + + it("refuse marks on things without items", () => { + const s = state({ steps: [{ caption: "Light it.", marks: [{ target: "dot", item: 0 }] }] }); + expect(checkScript(s).problems[0]).toMatch(/dot is a op; marks go on/); + }); + + it("measure runtime with the renderer's own timeline", () => { + const long = Array.from({ length: 8 }, (_, i) => ({ + caption: `Step ${i}.`, + focus: ["out"], + flow: ["q", "dot", "scores", "sm", "out", "sm", "scores", "dot"], + relabel: [{ id: "out", label: `v${i}` }], + })); + const { problems } = checkScript(state({ steps: long })); + expect(problems.some((p) => p.includes("keep it under 70s"))).toBe(true); + }); + + it("accept a whole sound diagram in one call", () => { + const s = emptyState(); + const { reply, done } = runTool(s, "submit_diagram", JSON.stringify({ ...ATTENTION, ...STEPS })); + expect(reply.problems).toEqual([]); + expect(done).toBe(true); + expect(s.steps).toHaveLength(4); + }); + + it("refuse a diagram with every problem listed at once", () => { + const broken = JSON.parse(JSON.stringify({ ...ATTENTION, ...STEPS })); + broken.elements[1].row = 0; + broken.connections.push({ src: "q", dst: "ghost" }); + const { reply, done } = runTool(emptyState(), "submit_diagram", JSON.stringify(broken)); + expect(done).toBe(false); + expect(reply.problems).toEqual( + expect.arrayContaining(["k and q share grid cell (0, 0); move one", 'arrow q->ghost: no element "ghost"']), + ); + }); + + it("answer an unknown tool or broken JSON with a problem, not an exception", () => { + expect(runTool(emptyState(), "paint", "{}").reply.problems[0]).toMatch(/no tool named "paint"/); + expect(runTool(emptyState(), "submit_diagram", "{not json").reply.problems[0]).toMatch(/not valid JSON/); + }); +}); + +// -- agent loop ----------------------------------------------------------------- // + +describe("diagram agent", () => { + it("accepts a sound first submission in one turn", async () => { + const { fn } = scriptedFetch([reply([toolCall("submit_diagram", { ...ATTENTION, ...STEPS })])]); + const result = await drawDiagram(REQUEST, { + apiKey: "k", + models: ["m"], + reasoningMaxTokens: 800, + deadline: Date.now() + 60_000, + fetch: fn, + }); + expect(result.ok).toBe(true); + expect(result.turns).toBe(1); + }); + + it("fixes a reported problem in a second turn, carrying reasoning forward", async () => { + const broken = JSON.parse(JSON.stringify(ATTENTION)); + broken.elements[1].row = 0; + const { fn, sent } = scriptedFetch([ + reply([toolCall("submit_diagram", { ...broken, ...STEPS })], { reasoning_details: [{ type: "reasoning.text", text: "plan" }] }), + reply([toolCall("submit_diagram", { ...ATTENTION, ...STEPS })]), + ]); + const result = await drawDiagram(REQUEST, { + apiKey: "k", + models: ["nvidia/nemotron-3.5-lightning:free"], + reasoningMaxTokens: 800, + deadline: Date.now() + 60_000, + fetch: fn, + }); + expect(result.ok).toBe(true); + expect(result.turns).toBe(2); + expect(result.captions).toEqual(STEPS.steps.map((s) => s.caption)); + expect((result.params?.elements as unknown[]).length).toBe(6); + expect(result.usage).toEqual({ prompt: 200, completion: 100, reasoning: 40 }); + // The tool told the model exactly what was wrong ... + const toolReplies = sent[1].messages.filter((m) => m.role === "tool").map((m) => JSON.parse(String(m.content))); + expect(toolReplies[0].problems).toContain("k and q share grid cell (0, 0); move one"); + // ... and the model's reasoning went back to it unmodified. + const assistant = sent[1].messages.find((m) => m.role === "assistant"); + expect(assistant?.reasoning_details).toEqual([{ type: "reasoning.text", text: "plan" }]); + // Reasoning is capped on every call. + expect(sent[0].reasoning).toEqual({ max_tokens: 800 }); + }); + + it("nudges once when the model answers in prose, then gives up", async () => { + const prose = () => + new Response(JSON.stringify({ choices: [{ message: { role: "assistant", content: "Here is a diagram..." } }] }), { status: 200 }); + const { fn } = scriptedFetch([prose(), prose()]); + const result = await drawDiagram(REQUEST, { + apiKey: "k", + models: ["m"], + reasoningMaxTokens: 800, + deadline: Date.now() + 60_000, + fetch: fn, + }); + expect(result.ok).toBe(false); + expect(result.notes).toContain("the model answered without calling a tool, twice"); + }); +}); + +// -- client --------------------------------------------------------------------- // + +describe("openrouter client", () => { + const ok = () => reply([toolCall("submit_diagram", {})]); + + it("hands a spent free model over to the next in the chain", async () => { + const { fn, sent } = scriptedFetch([ + new Response(JSON.stringify({ error: { code: 429, message: "Rate limit exceeded: free-models-per-day" } }), { status: 429 }), + ok(), + ]); + const chat = new Chat({ apiKey: "k", models: ["a:free", "b"], reasoningMaxTokens: 800, fetch: fn, sleep: NO_SLEEP }); + const result = await chat.send([], [], Date.now() + 60_000); + expect(result.model).toBe("b"); + expect(sent.map((s) => s.model)).toEqual(["a:free", "b"]); + expect(chat.models()).toEqual(["b"]); + }); + + it("waits once on a per-minute limit and retries the same model", async () => { + const { fn, sent } = scriptedFetch([new Response("slow down", { status: 429 }), ok()]); + const chat = new Chat({ apiKey: "k", models: ["a:free"], reasoningMaxTokens: 0, fetch: fn, sleep: NO_SLEEP }); + const result = await chat.send([], [], Date.now() + 60_000); + expect(result.model).toBe("a:free"); + expect(sent).toHaveLength(2); + expect(sent[0].reasoning).toEqual({ enabled: true }); + }); + + it("treats an error inside a 200 as that error", async () => { + const { fn } = scriptedFetch([ + new Response(JSON.stringify({ error: { code: 404, message: "No endpoints found for a:free" } }), { status: 200 }), + ok(), + ]); + const chat = new Chat({ apiKey: "k", models: ["a:free", "b"], reasoningMaxTokens: 800, fetch: fn, sleep: NO_SLEEP }); + expect((await chat.send([], [], Date.now() + 60_000)).model).toBe("b"); + }); + + it("cuts a slow free model off and leaves the fallback time to answer", async () => { + const hang = (init: RequestInit) => + new Promise((_, reject) => { + init.signal?.addEventListener("abort", () => reject(Object.assign(new Error("timed out"), { name: "TimeoutError" }))); + }); + const { fn, sent } = scriptedFetch([hang, ok()]); + const chat = new Chat({ + apiKey: "k", + models: ["slow:free", "fast"], + reasoningMaxTokens: 800, + fetch: fn, + sleep: NO_SLEEP, + callTimeoutMs: 200, + minCallMs: 10, + }); + const started = Date.now(); + const result = await chat.send([], [], Date.now() + 5_000); + expect(result.model).toBe("fast"); + expect(sent.map((s) => s.model)).toEqual(["slow:free", "fast"]); + expect(Date.now() - started).toBeLessThan(2_000); + }); + + it("gives up with OutOfTime when a paid model is too slow", async () => { + const hang = (init: RequestInit) => + new Promise((_, reject) => { + init.signal?.addEventListener("abort", () => reject(Object.assign(new Error("timed out"), { name: "TimeoutError" }))); + }); + const { fn } = scriptedFetch([hang]); + const chat = new Chat({ apiKey: "k", models: ["paid"], reasoningMaxTokens: 800, fetch: fn, callTimeoutMs: 100, minCallMs: 10 }); + await expect(chat.send([], [], Date.now() + 5_000)).rejects.toBeInstanceOf(OutOfTime); + }); + + it("starts no call when the deadline is too close", async () => { + const { fn, sent } = scriptedFetch([ok()]); + const chat = new Chat({ apiKey: "k", models: ["a"], reasoningMaxTokens: 800, fetch: fn }); + await expect(chat.send([], [], Date.now() + 1_000)).rejects.toBeInstanceOf(OutOfTime); + expect(sent).toHaveLength(0); + }); + + it("reports when every model has failed", async () => { + const gone = () => new Response(JSON.stringify({ error: { code: 404, message: "No endpoints found" } }), { status: 404 }); + const { fn } = scriptedFetch([gone(), gone()]); + const chat = new Chat({ apiKey: "k", models: ["a:free", "b"], reasoningMaxTokens: 800, fetch: fn }); + await expect(chat.send([], [], Date.now() + 60_000)).rejects.toBeInstanceOf(NoModelLeft); + }); +}); diff --git a/reader/lib/harness/openrouter.ts b/reader/lib/harness/openrouter.ts new file mode 100644 index 0000000..7fd4579 --- /dev/null +++ b/reader/lib/harness/openrouter.ts @@ -0,0 +1,228 @@ +/** + * A small OpenRouter chat client for tool-calling agents. + * + * Three properties carried over from the Python provider, each learned in production: + * + * - **Every call has a wall-clock limit.** `AbortSignal.timeout` covers the whole + * request, body included. A slow call ends with an error the agent can act on, + * instead of the platform killing the function mid-call. + * - **A model chain, not a model.** A `:free` endpoint that is spent for the day + * (429 "free-models-per-day"), withdrawn (404 "No endpoints found") or too slow + * hands over to the next model. + * - **Reasoning is capped.** On the free Nemotron endpoint, measured side by side, a + * diagram took 66s with unbounded reasoning and 15s with an 800-token cap. + * + * `reasoning_details` from each reply is kept on the assistant message, so the next + * turn continues the same line of reasoning instead of starting over. + */ + +export interface ToolDef { + type: "function"; + function: { name: string; description: string; parameters: Record }; +} + +export interface ToolCall { + id: string; + type?: "function"; + function: { name: string; arguments: string }; +} + +export interface Message { + role: "system" | "user" | "assistant" | "tool"; + content: string | null; + tool_calls?: ToolCall[]; + tool_call_id?: string; + /** Opaque; passed back unmodified so the model continues its reasoning. */ + reasoning_details?: unknown; +} + +export interface Usage { + prompt: number; + completion: number; + reasoning: number; +} + +export interface ChatResult { + message: Message; + model: string; + usage: Usage; +} + +export interface ClientOptions { + apiKey: string; + baseUrl?: string; + /** Preference order. Spent or withdrawn models are skipped for the rest of the run. */ + models: string[]; + /** Reasoning tokens per call; 0 lets the model reason without a cap. */ + reasoningMaxTokens: number; + maxTokens?: number; + /** + * Ceiling on ONE call, within the overall deadline. Without it a slow free model + * waits out the entire budget and leaves the paid fallback no time to answer. + */ + callTimeoutMs?: number; + /** No call starts with less than this left. */ + minCallMs?: number; + /** Injected in tests. */ + fetch?: typeof fetch; + now?: () => number; + sleep?: (ms: number) => Promise; +} + +/** Below this many milliseconds left, no call starts: it could not finish. */ +export const MIN_CALL_MS = 8_000; +export const CALL_TIMEOUT_MS = 90_000; + +export class OutOfTime extends Error { + constructor(message: string) { + super(message); + this.name = "OutOfTime"; + } +} + +export class NoModelLeft extends Error { + constructor(message: string) { + super(message); + this.name = "NoModelLeft"; + } +} + +/** Errors that mean the MODEL is unusable now, as opposed to this request. */ +function modelGone(status: number, body: string, model: string): boolean { + if (status === 404) return /no endpoints found|model_not_found|not a valid model/i.test(body); + if (status === 400) return /model_decommissioned|not a valid model/i.test(body); + if (status === 429) return model.endsWith(":free") && /per[- ]day/i.test(body); + return false; +} + +export class Chat { + private readonly unavailable = new Set(); + private readonly fetch: typeof fetch; + private readonly now: () => number; + private readonly sleep: (ms: number) => Promise; + private readonly minCallMs: number; + + constructor(private readonly opts: ClientOptions) { + this.fetch = opts.fetch ?? fetch; + this.now = opts.now ?? Date.now; + this.sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))); + this.minCallMs = opts.minCallMs ?? MIN_CALL_MS; + } + + /** The models still worth trying, in order. */ + models(): string[] { + const live = this.opts.models.filter((m) => !this.unavailable.has(m)); + return live.length ? live : []; + } + + async send(messages: Message[], tools: ToolDef[], deadline: number): Promise { + let lastError = "no model configured"; + for (const model of this.models()) { + const budget = deadline - this.now(); + if (budget < this.minCallMs) { + throw new OutOfTime(`only ${Math.max(0, Math.round(budget / 1000))}s left; no call started`); + } + let retriedRateLimit = false; + for (;;) { + const result = await this.once(model, messages, tools, deadline); + if (result.kind === "ok") return result.value; + if (result.kind === "rate-limited" && !retriedRateLimit && deadline - this.now() > this.minCallMs + 3_000) { + // A per-minute limit clears in seconds; one short wait is worth it. + retriedRateLimit = true; + await this.sleep(3_000); + continue; + } + lastError = result.error; + if (result.kind === "fatal") throw new Error(result.error); + // "gone", "too-slow" or a second rate limit: this model is done for this run. + this.unavailable.add(model); + break; + } + } + throw new NoModelLeft(`every model in the chain failed; last: ${lastError}`); + } + + private async once( + model: string, + messages: Message[], + tools: ToolDef[], + deadline: number, + ): Promise< + | { kind: "ok"; value: ChatResult } + | { kind: "gone" | "too-slow" | "rate-limited" | "fatal"; error: string } + > { + const cap = this.opts.reasoningMaxTokens; + const body = { + model, + messages, + tools, + tool_choice: "auto", + max_tokens: this.opts.maxTokens ?? 8192, + reasoning: cap > 0 ? { max_tokens: cap } : { enabled: true }, + }; + const budget = Math.min(deadline - this.now(), this.opts.callTimeoutMs ?? CALL_TIMEOUT_MS); + let res: Response; + try { + res = await this.fetch(`${this.opts.baseUrl ?? "https://openrouter.ai/api/v1"}/chat/completions`, { + method: "POST", + headers: { Authorization: `Bearer ${this.opts.apiKey}`, "Content-Type": "application/json" }, + body: JSON.stringify(body), + signal: AbortSignal.timeout(Math.max(1, budget)), + }); + } catch (err) { + const name = (err as Error)?.name ?? ""; + if (name === "TimeoutError" || name === "AbortError") { + if (model.endsWith(":free")) return { kind: "too-slow", error: `${model}: no answer within ${Math.round(budget / 1000)}s` }; + throw new OutOfTime(`${model}: no answer within ${Math.round(budget / 1000)}s`); + } + return { kind: "fatal", error: `${model}: ${String(err)}` }; + } + let text: string; + try { + text = await res.text(); + } catch (err) { + const name = (err as Error)?.name ?? ""; + if (name === "TimeoutError" || name === "AbortError") { + if (model.endsWith(":free")) return { kind: "too-slow", error: `${model}: reply cut off at the deadline` }; + throw new OutOfTime(`${model}: reply cut off at the deadline`); + } + return { kind: "fatal", error: `${model}: ${String(err)}` }; + } + let parsed: Record = {}; + try { + parsed = JSON.parse(text) as Record; + } catch { + /* non-JSON error page; handled by status below */ + } + // OpenRouter can report an upstream error inside a 200. + const inner = parsed.error as { code?: unknown; message?: unknown } | undefined; + const status = res.ok && inner ? (typeof inner.code === "number" ? inner.code : 502) : res.status; + if (status === 200) { + const choice = (parsed.choices as { message?: Message }[] | undefined)?.[0]; + if (!choice?.message) return { kind: "fatal", error: `${model}: reply had no message` }; + const u = (parsed.usage ?? {}) as Record; + const details = (u.completion_tokens_details ?? {}) as Record; + return { + kind: "ok", + value: { + message: { ...choice.message, role: "assistant" }, + model, + usage: { + prompt: Number(u.prompt_tokens ?? 0), + completion: Number(u.completion_tokens ?? 0), + reasoning: Number(details.reasoning_tokens ?? 0), + }, + }, + }; + } + const detail = `${model}: ${status} ${text.slice(0, 200)}`; + if (modelGone(status, text, model)) return { kind: "gone", error: detail }; + if (status === 429) return { kind: "rate-limited", error: detail }; + if (status >= 500) return { kind: "gone", error: detail }; + return { kind: "fatal", error: detail }; + } +} + +export function addUsage(a: Usage, b: Usage): Usage { + return { prompt: a.prompt + b.prompt, completion: a.completion + b.completion, reasoning: a.reasoning + b.reasoning }; +} diff --git a/reader/package-lock.json b/reader/package-lock.json index ccb49fd..5cc847f 100644 --- a/reader/package-lock.json +++ b/reader/package-lock.json @@ -21,7 +21,8 @@ "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", "tailwindcss": "^4.0.0", - "typescript": "^5.7.0" + "typescript": "^5.7.0", + "vitest": "^3.2.4" } }, "node_modules/@alloc/quick-lru": { @@ -47,363 +48,469 @@ "tslib": "^2.4.0" } }, - "node_modules/@img/colour": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", - "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, "license": "MIT", "optional": true, + "os": [ + "aix" + ], "engines": { "node": ">=18" } }, - "node_modules/@img/sharp-darwin-arm64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", - "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", "cpu": [ "arm64" ], - "license": "Apache-2.0", + "dev": true, + "license": "MIT", "optional": true, "os": [ - "darwin" + "android" ], "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-darwin-arm64": "1.2.4" + "node": ">=18" } }, - "node_modules/@img/sharp-darwin-x64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", - "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", "cpu": [ "x64" ], - "license": "Apache-2.0", + "dev": true, + "license": "MIT", "optional": true, "os": [ - "darwin" + "android" ], "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-darwin-x64": "1.2.4" + "node": ">=18" } }, - "node_modules/@img/sharp-libvips-darwin-arm64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", - "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", "cpu": [ "arm64" ], - "license": "LGPL-3.0-or-later", + "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" ], - "funding": { - "url": "https://opencollective.com/libvips" + "engines": { + "node": ">=18" } }, - "node_modules/@img/sharp-libvips-darwin-x64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", - "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", "cpu": [ "x64" ], - "license": "LGPL-3.0-or-later", + "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" ], - "funding": { - "url": "https://opencollective.com/libvips" + "engines": { + "node": ">=18" } }, - "node_modules/@img/sharp-libvips-linux-arm": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", - "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", "cpu": [ - "arm" + "arm64" ], - "license": "LGPL-3.0-or-later", + "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "freebsd" ], - "funding": { - "url": "https://opencollective.com/libvips" + "engines": { + "node": ">=18" } }, - "node_modules/@img/sharp-libvips-linux-arm64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", - "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", "cpu": [ - "arm64" + "x64" ], - "license": "LGPL-3.0-or-later", + "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "freebsd" ], - "funding": { - "url": "https://opencollective.com/libvips" + "engines": { + "node": ">=18" } }, - "node_modules/@img/sharp-libvips-linux-ppc64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", - "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", "cpu": [ - "ppc64" + "arm" ], - "license": "LGPL-3.0-or-later", + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ], - "funding": { - "url": "https://opencollective.com/libvips" + "engines": { + "node": ">=18" } }, - "node_modules/@img/sharp-libvips-linux-riscv64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", - "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", "cpu": [ - "riscv64" + "arm64" ], - "license": "LGPL-3.0-or-later", + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ], - "funding": { - "url": "https://opencollective.com/libvips" + "engines": { + "node": ">=18" } }, - "node_modules/@img/sharp-libvips-linux-s390x": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", - "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", "cpu": [ - "s390x" + "ia32" ], - "license": "LGPL-3.0-or-later", + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ], - "funding": { - "url": "https://opencollective.com/libvips" + "engines": { + "node": ">=18" } }, - "node_modules/@img/sharp-libvips-linux-x64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz", - "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==", + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", "cpu": [ - "x64" + "loong64" ], - "license": "LGPL-3.0-or-later", + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ], - "funding": { - "url": "https://opencollective.com/libvips" + "engines": { + "node": ">=18" } }, - "node_modules/@img/sharp-libvips-linuxmusl-arm64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", - "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", "cpu": [ - "arm64" + "mips64el" ], - "license": "LGPL-3.0-or-later", + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ], - "funding": { - "url": "https://opencollective.com/libvips" + "engines": { + "node": ">=18" } }, - "node_modules/@img/sharp-libvips-linuxmusl-x64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", - "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", "cpu": [ - "x64" + "ppc64" ], - "license": "LGPL-3.0-or-later", + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ], - "funding": { - "url": "https://opencollective.com/libvips" + "engines": { + "node": ">=18" } }, - "node_modules/@img/sharp-linux-arm": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", - "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", "cpu": [ - "arm" + "riscv64" ], - "license": "Apache-2.0", + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-arm": "1.2.4" + "node": ">=18" } }, - "node_modules/@img/sharp-linux-arm64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", - "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", "cpu": [ - "arm64" + "s390x" ], - "license": "Apache-2.0", + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-arm64": "1.2.4" + "node": ">=18" } }, - "node_modules/@img/sharp-linux-ppc64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", - "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", "cpu": [ - "ppc64" + "x64" ], - "license": "Apache-2.0", + "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-ppc64": "1.2.4" + "node": ">=18" } }, - "node_modules/@img/sharp-linux-riscv64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", - "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", "cpu": [ - "riscv64" + "arm64" ], - "license": "Apache-2.0", + "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "netbsd" ], "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-riscv64": "1.2.4" + "node": ">=18" } }, - "node_modules/@img/sharp-linux-s390x": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", - "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", "cpu": [ - "s390x" + "x64" ], - "license": "Apache-2.0", + "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "netbsd" ], "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-s390x": "1.2.4" + "node": ">=18" } }, - "node_modules/@img/sharp-linux-x64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz", - "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==", + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", "cpu": [ "x64" ], - "license": "Apache-2.0", + "dev": true, + "license": "MIT", "optional": true, "os": [ - "linux" + "openbsd" ], "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-x64": "1.2.4" + "node": ">=18" } }, - "node_modules/@img/sharp-linuxmusl-arm64": { + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", - "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", + "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", "cpu": [ "arm64" ], "license": "Apache-2.0", "optional": true, "os": [ - "linux" + "darwin" ], "engines": { "node": "^18.17.0 || ^20.3.0 || >=21.0.0" @@ -412,20 +519,20 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" + "@img/sharp-libvips-darwin-arm64": "1.2.4" } }, - "node_modules/@img/sharp-linuxmusl-x64": { + "node_modules/@img/sharp-darwin-x64": { "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", - "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", + "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", "cpu": [ "x64" ], "license": "Apache-2.0", "optional": true, "os": [ - "linux" + "darwin" ], "engines": { "node": "^18.17.0 || ^20.3.0 || >=21.0.0" @@ -434,268 +541,985 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-x64": "1.2.4" + "@img/sharp-libvips-darwin-x64": "1.2.4" } }, - "node_modules/@img/sharp-wasm32": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", - "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", + "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", "cpu": [ - "wasm32" + "arm64" ], - "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "license": "LGPL-3.0-or-later", "optional": true, - "dependencies": { - "@emnapi/runtime": "^1.7.0" - }, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, + "os": [ + "darwin" + ], "funding": { "url": "https://opencollective.com/libvips" } }, - "node_modules/@img/sharp-win32-arm64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", - "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", + "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", "cpu": [ - "arm64" + "x64" ], - "license": "Apache-2.0 AND LGPL-3.0-or-later", + "license": "LGPL-3.0-or-later", "optional": true, "os": [ - "win32" + "darwin" ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, "funding": { "url": "https://opencollective.com/libvips" } }, - "node_modules/@img/sharp-win32-ia32": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", - "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", + "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", "cpu": [ - "ia32" + "arm" ], - "license": "Apache-2.0 AND LGPL-3.0-or-later", + "license": "LGPL-3.0-or-later", "optional": true, "os": [ - "win32" + "linux" ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, "funding": { "url": "https://opencollective.com/libvips" } }, - "node_modules/@img/sharp-win32-x64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", - "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", + "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", "cpu": [ - "x64" + "arm64" ], - "license": "Apache-2.0 AND LGPL-3.0-or-later", + "license": "LGPL-3.0-or-later", "optional": true, "os": [ - "win32" + "linux" ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, "funding": { "url": "https://opencollective.com/libvips" } }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.13", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", - "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.0", - "@jridgewell/trace-mapping": "^0.3.24" + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", + "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", + "cpu": [ + "ppc64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" } }, - "node_modules/@jridgewell/remapping": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", - "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", + "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", + "cpu": [ + "riscv64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", + "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", + "cpu": [ + "s390x" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz", + "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", + "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", + "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", + "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", + "cpu": [ + "arm" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", + "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", + "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", + "cpu": [ + "ppc64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", + "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", + "cpu": [ + "riscv64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", + "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", + "cpu": [ + "s390x" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz", + "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", + "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", + "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", + "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.7.0" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", + "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", + "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", + "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, + "node_modules/@next/env": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.23.tgz", + "integrity": "sha512-Mv3Z9hVbFcPnoLevsZ6rnX1TBtyHb5E17yN7HTPDXSXxeNsGBjUFrdbjRXKKXIOhfth7/cg6Ay7PZ2UFawaWsQ==", + "license": "MIT" + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.23.tgz", + "integrity": "sha512-SrEwOROH/rhA03F59hHtdhgtfZMWGzr5duDBWgRQt2rS3mJhqMKOcnNx6txOd0/i3E3D3uFKYFvyHsEiwQxzag==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.23.tgz", + "integrity": "sha512-f0FpFbG2EhDCuptBGcfrLcYMDuQAhe6m1QA4VVfXFrIBoFXvXt/olGbBkYkloKlXQtmhuzvtdYyuu/6zf07GIg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.23.tgz", + "integrity": "sha512-WlNtfepUXKX2u2ZsJZ8c3c8+tJSRZqsYzoMwLOY72A8ucKCCgxgNhiePA3qzFYahVWrwcQd8jOeJmBinc+VFVQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.23.tgz", + "integrity": "sha512-W/6qKk7UG93mg14PmQC+2urt69MIdwTBLNQ6MJyeC4wOCIHCjz+VfgssvS1pK7mgYBtLC1g6VKNoHD9xB0WWGg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.23.tgz", + "integrity": "sha512-vzefI32mi6VMk96RaTAyxApgfGbiFzQBXVsekEjsDv1fr48mlABTWx0sUYhaYCBHWqCalxmz3DxbxFcbFvzNtw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.23.tgz", + "integrity": "sha512-qppK/3dTGOTI+aoWWBZc3DshFIhrzgL8guATlaN9V6M1QJxbkP/rhEZ22tdICsQ/2WWXopMZ2Jokzj2u3uKY3Q==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.23.tgz", + "integrity": "sha512-Wc29KFOdT7XBcII3Vtmw7aoU8Uk3Mes/FNJfhFeSHdYBFJWMcR/DsI8U9BCPUhq/uycsUVuqSKGthW15tLsigA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "15.5.23", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.23.tgz", + "integrity": "sha512-/C7wRW4fa9s/PKA18zGPPpVmx8ycgVpP8yOxro4gzGTzjPJdscbAP3ODeFvgiIovxD176Z2J/SXO9t8PJKHLeQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.67.4.tgz", + "integrity": "sha512-/v/pUAPOcwp+r1Hjjdg0cBV1TE89CzGKrKh2FgkIQw2QBcIMmVPOCSfuOZStCn4Xh/98HXfo/ht6ztcssctPNg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.67.4.tgz", + "integrity": "sha512-6tmmB/P52Vt167FXXEw5auiEUgTtZz7aqUgWHqYXToIUE0HFDY6fTdAyeekjjsNk6O/8dtpSKtClxSj1mMneKQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-x64": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-x64/-/rollup-android-x64-4.67.4.tgz", + "integrity": "sha512-8Z9Q4RmotVmuL4llOvqX814JNiOK1oqoBv+glG5KbpRfUiypqzz2/fxIzK4Pq129l4dT5a8Gszmpc0/XPYoFuQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.67.4.tgz", + "integrity": "sha512-pnq6hssxTtwuRAl6Kdi/+IDY+b1IhkUetjhUkdLAAJCssjfqtL2Oqy/FXJVJFtAWOu1oRlArIvf0Yk1O92x2HQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.67.4.tgz", + "integrity": "sha512-BeIrGZvHMVdJg/N+ohZfFywG/gF41684YhDj2wBvouj7m9ziP1tZDUNwzXRiDY+3WIKngaC4hiUBqVtBPGP5og==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.67.4.tgz", + "integrity": "sha512-fRFX/oqNg/g780DKoS8RIfYcZD59Ru5O/bSeK1N7gQljBFrTxJY/q5EX4eMs5SrJf32VgVBVVYCdfPpzAwPPnQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.67.4.tgz", + "integrity": "sha512-bSrBRopG1q+0RuOsW0NtYTtIODlvNA3T3ebx5WnQVdSxWIoXFmj+rZdHUHdSLgFdZ5M6VGmekYE7r4RMGQXjfg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.67.4.tgz", + "integrity": "sha512-L8IvdrJVtl65g1ozwDSyjGPG+FmibhCdFUwmqTItJLw0S3+Oj4QzFs7rfgTUiK7rsPjkCLdG1/GApFxoynXFJQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.67.4.tgz", + "integrity": "sha512-h7PcoQOzC31jshNpQ48J0akB9tsghjkSjSl5AZ6XsVGTxVsln7t7C4SQyw62tNVSaz2SeHgk4VT2ELbL17BSHQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.67.4.tgz", + "integrity": "sha512-KSPuOBNHoOl7AsVjeY1KZci8+0up0U4TFAHU5IzBYN8P+Z6cB9DZq28+JQycZW7f6WLLa/tSzhV7Rdy95bVi+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.67.4.tgz", + "integrity": "sha512-0E/mKmVk1PlQeQYygIwQm0jlwjANTzGSiNBMPrFx+rdFGFj/2Axh4p6XwcrystQIqXZVudTaGsdbDpzYgJ4wSA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.67.4.tgz", + "integrity": "sha512-Fvw7dOSc2Sa9UOipRZVI0zOgdLCzsjVyD/6JuHXzUHTXFu7mMgmeX/0/bCVBIut1dz+nWz3pV4WpS/Qg0XVnxw==", + "cpu": [ + "loong64" + ], "dev": true, "license": "MIT", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - } + "optional": true, + "os": [ + "linux" + ] }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.67.4.tgz", + "integrity": "sha512-jzxbVHaE7V3F+P0wEK7UydQtvv7Twfdtx58jI5/3VRx1jJxyrn+qFwfXmqjVFxPhBl+zjaRs+ZJMFJw7vdHaQA==", + "cpu": [ + "loong64" + ], "dev": true, "license": "MIT", - "engines": { - "node": ">=6.0.0" - } + "optional": true, + "os": [ + "linux" + ] }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", - "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.67.4.tgz", + "integrity": "sha512-fhtrzp9p4GjEJVaigaap9g6X9nP6xgJtKiLLXSDgpE18HXufA5aqfltGn+KAqMtVZReJZfOrXm//y5YSA9BWbA==", + "cpu": [ + "ppc64" + ], "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.31", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", - "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.67.4.tgz", + "integrity": "sha512-uynaF7IUHwAckV0S+yC1f5esy9gB+aqCBsPH5BOck32TYdCuAn2lVG5tvUcFnEsrviGEmRZxE1NHSOieUPYJEg==", + "cpu": [ + "ppc64" + ], "dev": true, "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, - "node_modules/@next/env": { - "version": "15.5.23", - "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.23.tgz", - "integrity": "sha512-Mv3Z9hVbFcPnoLevsZ6rnX1TBtyHb5E17yN7HTPDXSXxeNsGBjUFrdbjRXKKXIOhfth7/cg6Ay7PZ2UFawaWsQ==", - "license": "MIT" + "optional": true, + "os": [ + "linux" + ] }, - "node_modules/@next/swc-darwin-arm64": { - "version": "15.5.23", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.23.tgz", - "integrity": "sha512-SrEwOROH/rhA03F59hHtdhgtfZMWGzr5duDBWgRQt2rS3mJhqMKOcnNx6txOd0/i3E3D3uFKYFvyHsEiwQxzag==", + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.67.4.tgz", + "integrity": "sha512-uaqRFdfb8eIa2bVHN/FE3ndCvR0zV2xv0AwjCfxrqSu6l6fp/54VhjfhslKlf2RIik9L1jwlt4E56PeVX6tQtQ==", "cpu": [ - "arm64" + "riscv64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } + "linux" + ] }, - "node_modules/@next/swc-darwin-x64": { - "version": "15.5.23", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.23.tgz", - "integrity": "sha512-f0FpFbG2EhDCuptBGcfrLcYMDuQAhe6m1QA4VVfXFrIBoFXvXt/olGbBkYkloKlXQtmhuzvtdYyuu/6zf07GIg==", + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.67.4.tgz", + "integrity": "sha512-JZRow7kmxUDEASnxHuVG5itTm+nTXi9BQUABcVUnUEngC+OPwMrpx1uJ9hIA/v+IcAEBL52ktCSPXk5OJn9Jqg==", "cpu": [ - "x64" + "riscv64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } + "linux" + ] }, - "node_modules/@next/swc-linux-arm64-gnu": { - "version": "15.5.23", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.23.tgz", - "integrity": "sha512-WlNtfepUXKX2u2ZsJZ8c3c8+tJSRZqsYzoMwLOY72A8ucKCCgxgNhiePA3qzFYahVWrwcQd8jOeJmBinc+VFVQ==", + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.67.4.tgz", + "integrity": "sha512-rdrh4e+Lq9fCNKoDPaCqeHXbQCe7yl77Ukl45tlSClwYdZ1gpFGZz1XLJdYtY++FRlfL5aHvb6/0n3GDW/Nxsw==", "cpu": [ - "arm64" + "s390x" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ], - "engines": { - "node": ">= 10" - } + ] }, - "node_modules/@next/swc-linux-arm64-musl": { - "version": "15.5.23", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.23.tgz", - "integrity": "sha512-W/6qKk7UG93mg14PmQC+2urt69MIdwTBLNQ6MJyeC4wOCIHCjz+VfgssvS1pK7mgYBtLC1g6VKNoHD9xB0WWGg==", + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.67.4.tgz", + "integrity": "sha512-wL7MS4r0fYcxluF3ne2plofHZiB/LsqNCnyaUlyiKpAJLb6agPSFz7DEFCfkonWAZXMrLwCmC08b2ZEnEdJkog==", "cpu": [ - "arm64" + "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ], - "engines": { - "node": ">= 10" - } + ] }, - "node_modules/@next/swc-linux-x64-gnu": { - "version": "15.5.23", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.23.tgz", - "integrity": "sha512-vzefI32mi6VMk96RaTAyxApgfGbiFzQBXVsekEjsDv1fr48mlABTWx0sUYhaYCBHWqCalxmz3DxbxFcbFvzNtw==", + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.67.4.tgz", + "integrity": "sha512-4H0XHfd2VufGjX7NjUyeue78sD0bRIoKSGjGqO+F5nSvL6jN48NAU7esdmtFEYxZXwObLtt3MJ/kHS0jASMW3g==", "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "linux" - ], - "engines": { - "node": ">= 10" - } + ] }, - "node_modules/@next/swc-linux-x64-musl": { - "version": "15.5.23", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.23.tgz", - "integrity": "sha512-qppK/3dTGOTI+aoWWBZc3DshFIhrzgL8guATlaN9V6M1QJxbkP/rhEZ22tdICsQ/2WWXopMZ2Jokzj2u3uKY3Q==", + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.67.4.tgz", + "integrity": "sha512-osRHQbE55pZpCLetpMsFmhkapyZnAUH73qRKMh+npi3boUom6u6hdaTTPSxlInXxwJHsn9r2uDhdz0V7Yoxx2A==", "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ - "linux" + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.67.4.tgz", + "integrity": "sha512-95+exYEyOwrZePsE0czi4q7X5lxKPa21+lmyAZlwbYENITQ0Unk4HAQAFp/p+KhXBHBx9mUABXRYjOC5A1wY3Q==", + "cpu": [ + "arm64" ], - "engines": { - "node": ">= 10" - } + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] }, - "node_modules/@next/swc-win32-arm64-msvc": { - "version": "15.5.23", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.23.tgz", - "integrity": "sha512-Wc29KFOdT7XBcII3Vtmw7aoU8Uk3Mes/FNJfhFeSHdYBFJWMcR/DsI8U9BCPUhq/uycsUVuqSKGthW15tLsigA==", + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.67.4.tgz", + "integrity": "sha512-FOXOcKhNQpO4Po+Ynan6IbtM67SrXZbgpRJWVYwz53CT5veI7sVzDwVBmWS65N5Imv+wK3SVhIPAl+C5DXXNCg==", "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.67.4.tgz", + "integrity": "sha512-cklKh0gJOkAZQcWziQa3hrjxZKN+PCHZ7SPTyGJDAiBVr05ZXlEjGFCG7zFJMaVibxsmzAe1FimN4u/HBns9+Q==", + "cpu": [ + "ia32" ], - "engines": { - "node": ">= 10" - } + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] }, - "node_modules/@next/swc-win32-x64-msvc": { - "version": "15.5.23", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.23.tgz", - "integrity": "sha512-/C7wRW4fa9s/PKA18zGPPpVmx8ycgVpP8yOxro4gzGTzjPJdscbAP3ODeFvgiIovxD176Z2J/SXO9t8PJKHLeQ==", + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.67.4.tgz", + "integrity": "sha512-AegwxJPc9bvUp8fQtlsUHkFMOMkGylWU7glyL+YD4vwG+QaYoGXYLSsQoeTD7kvoLZrVlMWNVhTg1dedY5C1VQ==", "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.67.4.tgz", + "integrity": "sha512-RJZnrwTWj7Iq2ooBwoGbDdC65tDwYawneGcAfFMJqVUrRZMcskka6nTkBpXR/47G7kzn3EW2qupExnaBy11vwg==", + "cpu": [ + "x64" ], - "engines": { - "node": ">= 10" - } + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] }, "node_modules/@swc/helpers": { "version": "0.5.15", @@ -977,6 +1801,31 @@ "tailwindcss": "4.3.3" } }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", + "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/katex": { "version": "0.16.8", "resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.8.tgz", @@ -1004,14 +1853,175 @@ "csstype": "^3.2.2" } }, - "node_modules/@types/react-dom": { - "version": "19.2.4", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.4.tgz", - "integrity": "sha512-Bsc+QHgp+P/F02XDzNCY9jnZNCUuLki36KT7VKrTXXLdHf+vHMNZnW1rVu5DNW/rCK+fya3DATySbLM4yhtKUw==", + "node_modules/@types/react-dom": { + "version": "19.2.4", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.4.tgz", + "integrity": "sha512-Bsc+QHgp+P/F02XDzNCY9jnZNCUuLki36KT7VKrTXXLdHf+vHMNZnW1rVu5DNW/rCK+fya3DATySbLM4yhtKUw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.2.0" + } + }, + "node_modules/@vitest/expect": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.4.tgz", + "integrity": "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/spy": "3.2.4", + "@vitest/utils": "3.2.4", + "chai": "^5.2.0", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.4.tgz", + "integrity": "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "3.2.4", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.17" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.7.tgz", + "integrity": "sha512-KUHlwqVu0sRlhCdyPdQ/wBoTfRahjUky1MubOmYw9fWfIZy1gNoHpuaaQBPAaMaVYdQYHJLurzj8ECCj5OwTqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.4.tgz", + "integrity": "sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "3.2.4", + "pathe": "^2.0.3", + "strip-literal": "^3.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.4.tgz", + "integrity": "sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.2.4", + "magic-string": "^0.30.17", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot/node_modules/@vitest/pretty-format": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.4.tgz", + "integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.4.tgz", + "integrity": "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^4.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.4.tgz", + "integrity": "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.2.4", + "loupe": "^3.1.4", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils/node_modules/@vitest/pretty-format": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.4.tgz", + "integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", "dev": true, "license": "MIT", - "peerDependencies": { - "@types/react": "^19.2.0" + "engines": { + "node": ">=8" } }, "node_modules/caniuse-lite": { @@ -1034,6 +2044,33 @@ ], "license": "CC-BY-4.0" }, + "node_modules/chai": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", + "integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/check-error": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.3.tgz", + "integrity": "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, "node_modules/client-only": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", @@ -1056,6 +2093,34 @@ "dev": true, "license": "MIT" }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", @@ -1080,6 +2145,108 @@ "node": ">=10.13.0" } }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -1097,6 +2264,13 @@ "jiti": "lib/jiti-cli.mjs" } }, + "node_modules/js-tokens": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", + "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", + "dev": true, + "license": "MIT" + }, "node_modules/katex": { "version": "0.16.47", "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.47.tgz", @@ -1374,6 +2548,13 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/loupe": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", + "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", + "dev": true, + "license": "MIT" + }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -1384,6 +2565,13 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, "node_modules/nanoid": { "version": "3.3.18", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz", @@ -1482,12 +2670,42 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz", + "integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "license": "ISC" }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/postcss": { "version": "8.5.26", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz", @@ -1538,6 +2756,53 @@ "react": "^19.2.8" } }, + "node_modules/rollup": { + "version": "4.67.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.67.4.tgz", + "integrity": "sha512-Lsv3oKcz5jgOQJej/p7nfwbVEdAbDT+z6OPf/SCdI+nF+q2ENp0pTKT35ZwXAmH8g45mfrIiJeEyAqKYSYoL9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.10" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.67.4", + "@rollup/rollup-android-arm64": "4.67.4", + "@rollup/rollup-android-x64": "4.67.4", + "@rollup/rollup-darwin-arm64": "4.67.4", + "@rollup/rollup-darwin-x64": "4.67.4", + "@rollup/rollup-freebsd-arm64": "4.67.4", + "@rollup/rollup-freebsd-x64": "4.67.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.67.4", + "@rollup/rollup-linux-arm-musleabihf": "4.67.4", + "@rollup/rollup-linux-arm64-gnu": "4.67.4", + "@rollup/rollup-linux-arm64-musl": "4.67.4", + "@rollup/rollup-linux-loong64-gnu": "4.67.4", + "@rollup/rollup-linux-loong64-musl": "4.67.4", + "@rollup/rollup-linux-ppc64-gnu": "4.67.4", + "@rollup/rollup-linux-ppc64-musl": "4.67.4", + "@rollup/rollup-linux-riscv64-gnu": "4.67.4", + "@rollup/rollup-linux-riscv64-musl": "4.67.4", + "@rollup/rollup-linux-s390x-gnu": "4.67.4", + "@rollup/rollup-linux-x64-gnu": "4.67.4", + "@rollup/rollup-linux-x64-musl": "4.67.4", + "@rollup/rollup-openbsd-x64": "4.67.4", + "@rollup/rollup-openharmony-arm64": "4.67.4", + "@rollup/rollup-win32-arm64-msvc": "4.67.4", + "@rollup/rollup-win32-ia32-msvc": "4.67.4", + "@rollup/rollup-win32-x64-gnu": "4.67.4", + "@rollup/rollup-win32-x64-msvc": "4.67.4", + "fsevents": "~2.3.2" + } + }, "node_modules/scheduler": { "version": "0.27.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", @@ -1608,6 +2873,13 @@ "@img/sharp-win32-x64": "0.34.5" } }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -1617,6 +2889,33 @@ "node": ">=0.10.0" } }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", + "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", + "dev": true, + "license": "MIT" + }, + "node_modules/strip-literal": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz", + "integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^9.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, "node_modules/styled-jsx": { "version": "5.1.6", "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.6.tgz", @@ -1661,6 +2960,67 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinypool": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", + "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", + "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.6.tgz", + "integrity": "sha512-u8KszXvGfU68hVcZpRHKG28T0krMuv2G5nDhiHaMLen/gIuFEgIJhaJuO69qjnXg5paSrbPMFfx3brNuN8eVSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", @@ -1687,6 +3047,194 @@ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "dev": true, "license": "MIT" + }, + "node_modules/vite": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.7.tgz", + "integrity": "sha512-AHEzTORMbi7/7aXp7w7KZ5+DCUdSeLsJz0grY8xHpc9DHdYb0vQu6DqJfm2tOw3gDExNgPgnJTXxM6syYFHaCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.27.0 || ^0.28.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", + "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.4.1", + "es-module-lexer": "^1.7.0", + "pathe": "^2.0.3", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.4.tgz", + "integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/expect": "3.2.4", + "@vitest/mocker": "3.2.4", + "@vitest/pretty-format": "^3.2.4", + "@vitest/runner": "3.2.4", + "@vitest/snapshot": "3.2.4", + "@vitest/spy": "3.2.4", + "@vitest/utils": "3.2.4", + "chai": "^5.2.0", + "debug": "^4.4.1", + "expect-type": "^1.2.1", + "magic-string": "^0.30.17", + "pathe": "^2.0.3", + "picomatch": "^4.0.2", + "std-env": "^3.9.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.2", + "tinyglobby": "^0.2.14", + "tinypool": "^1.1.1", + "tinyrainbow": "^2.0.0", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", + "vite-node": "3.2.4", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/debug": "^4.1.12", + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "@vitest/browser": "3.2.4", + "@vitest/ui": "3.2.4", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/debug": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } } } } diff --git a/reader/package.json b/reader/package.json index 5851a49..5a1732a 100644 --- a/reader/package.json +++ b/reader/package.json @@ -8,7 +8,8 @@ "build": "next build", "start": "next start", "lint": "next lint", - "typecheck": "tsc --noEmit" + "typecheck": "tsc --noEmit", + "test": "vitest run" }, "dependencies": { "katex": "^0.16.11", @@ -24,6 +25,7 @@ "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", "tailwindcss": "^4.0.0", - "typescript": "^5.7.0" + "typescript": "^5.7.0", + "vitest": "^3.2.4" } } diff --git a/tests/conftest.py b/tests/conftest.py index 1e81f58..f2ba058 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -45,6 +45,8 @@ "LLM_API_KEY", "LLM_BASE_URL", "LLM_PRESET", + "ARCVISUAL_DIAGRAM_AGENT_URL", + "ARCVISUAL_INTERNAL_SECRET", "DATABASE_URL", "R2_ACCOUNT_ID", "R2_ACCESS_KEY_ID", diff --git a/tests/test_diagram_agent.py b/tests/test_diagram_agent.py new file mode 100644 index 0000000..287d89d --- /dev/null +++ b/tests/test_diagram_agent.py @@ -0,0 +1,164 @@ +"""The Python side of the TypeScript diagram agent. + +What matters here is the seam: the agent is used when it is configured and has time, +its parameters go through exactly the validation one-shot codegen's do, and any +failure falls back to the one-shot call. It must never cost a scene. +""" + +from __future__ import annotations + +import copy + +import pytest + +from arcvisual.storyboard import Archetype +from tests.test_concept_diagram import ATTENTION, _DiagramProvider + + +class _Resp: + def __init__(self, status: int, body: dict): + self.status_code = status + self._body = body + self.text = str(body) + + def json(self): + return self._body + + +class _Http: + def __init__(self, resp: _Resp | Exception): + self.resp = resp + self.sent: list[dict] = [] + + def post(self, url, json, headers): + self.sent.append({"url": url, "json": json, "headers": headers}) + if isinstance(self.resp, Exception): + raise self.resp + return self.resp + + +@pytest.fixture(scope="module") +def storyboard(): + from arcvisual.analyze.single_pass import analyze + from arcvisual.ingest.arxiv import build_storyboard + from tests.fixtures import metadata, paper_tarball + + sb, _ = analyze(build_storyboard(metadata(), paper_tarball())) + return sb + + +def _opp(sb): + return sb.opportunities[0].model_copy(update={"archetype": Archetype.CONCEPT_DIAGRAM}) + + +AGENT_OK = { + "ok": True, + "params": copy.deepcopy(ATTENTION), + "captions": [s["caption"] for s in ATTENTION["steps"]], + "turns": 2, + "model": "nvidia/nemotron-3.5-lightning:free", + "notes": [], +} + + +@pytest.fixture +def agent_on(reset_settings): + reset_settings( + ARCVISUAL_DIAGRAM_AGENT_URL="https://reader.example/api/diagram", + ARCVISUAL_INTERNAL_SECRET="s3cret", + ) + + +def test_the_agent_is_asked_with_the_secret_and_the_section(agent_on, storyboard) -> None: + from arcvisual.generate import diagram_agent + + http = _Http(_Resp(200, AGENT_OK)) + drawn = diagram_agent.draw(storyboard, _opp(storyboard), budget_s=150, client=http) + assert drawn is not None and drawn.turns == 2 + sent = http.sent[0] + assert sent["headers"] == {"x-arcvisual-key": "s3cret"} + assert sent["json"]["budget_s"] == 150 + assert sent["json"]["claim"] and sent["json"]["section"] + + +@pytest.mark.parametrize( + "resp", + [ + _Resp(200, {"ok": False, "params": None, "notes": ["no accepted diagram"]}), + _Resp(401, {"error": "unauthorised"}), + ConnectionError("down"), + ], +) +def test_any_agent_failure_is_a_fallback_not_an_error(agent_on, storyboard, resp) -> None: + from arcvisual.generate import diagram_agent + + assert ( + diagram_agent.draw(storyboard, _opp(storyboard), budget_s=150, client=_Http(resp)) + is None + ) + + +def test_no_call_without_time_or_configuration(reset_settings, storyboard) -> None: + from arcvisual.generate import diagram_agent + + http = _Http(_Resp(200, AGENT_OK)) + reset_settings(ARCVISUAL_DIAGRAM_AGENT_URL=None, ARCVISUAL_INTERNAL_SECRET=None) + assert ( + diagram_agent.draw(storyboard, _opp(storyboard), budget_s=150, client=http) + is None + ) + reset_settings( + ARCVISUAL_DIAGRAM_AGENT_URL="https://reader.example/api/diagram", + ARCVISUAL_INTERNAL_SECRET="s3cret", + ) + assert ( + diagram_agent.draw(storyboard, _opp(storyboard), budget_s=5, client=http) is None + ) + assert http.sent == [] + + +def test_codegen_uses_the_agent_and_validates_its_diagram( + agent_on, storyboard, monkeypatch +) -> None: + from arcvisual.generate import codegen, diagram_agent + + real = diagram_agent.draw + http = _Http(_Resp(200, AGENT_OK)) + monkeypatch.setattr( + diagram_agent, + "draw", + lambda sb, opp, budget_s: real(sb, opp, budget_s=budget_s, client=http), + ) + provider = _DiagramProvider(budget=300_000) + result = codegen.generate_scene(storyboard, _opp(storyboard), provider=provider) + assert result.params_obj is not None, result.notes + assert any("diagram agent" in n for n in result.notes) + assert provider.user == "", "the one-shot call should not have been made" + assert [b.caption for b in result.scene.spec.beats] == AGENT_OK["captions"] + + +def test_codegen_falls_back_to_one_shot_when_the_agent_fails( + agent_on, storyboard, monkeypatch +) -> None: + from arcvisual.generate import codegen, diagram_agent + + monkeypatch.setattr(diagram_agent, "draw", lambda sb, opp, budget_s: None) + provider = _DiagramProvider(budget=300_000) + result = codegen.generate_scene(storyboard, _opp(storyboard), provider=provider) + assert result.params_obj is not None + assert provider.user, "the one-shot call should have been made" + + +def test_repairs_do_not_go_to_the_agent(agent_on, storyboard, monkeypatch) -> None: + from arcvisual.generate import codegen, diagram_agent + + called = [] + monkeypatch.setattr(diagram_agent, "draw", lambda *a, **k: called.append(1)) + codegen.generate_scene( + storyboard, + _opp(storyboard), + provider=_DiagramProvider(budget=300_000), + findings=["x"], + attempt=2, + ) + assert called == [] diff --git a/tests/test_grounding.py b/tests/test_grounding.py new file mode 100644 index 0000000..92cfbc2 --- /dev/null +++ b/tests/test_grounding.py @@ -0,0 +1,189 @@ +"""Grounding: a correct quote must ground, an invented one must not. + +The failure this covers came from production. "Attention Is All You Need" shipped +with two concepts and no visuals. The free model quoted the paper with its LaTeX +cleaned up ("dimension d_k" for ``dimension $d_k$``), so exact matching dropped +most quotes. Every opportunity whose concept had been dropped went with it. + +Tolerance must not become approximation. Each span still points at exact +characters of the paper, and a sentence the paper never wrote still fails. +""" + +from __future__ import annotations + +import pytest + +from arcvisual.ingest.arxiv import build_storyboard +from arcvisual.ingest.latex import span_for_text +from arcvisual.storyboard import Section +from tests.fixtures import metadata, paper_tarball + + +def _section(raw: str, sid: str = "s001") -> Section: + return Section( + id=sid, + heading_path=["Method"], + raw=raw, + prose_md=raw, + equation_ids=[], + figure_ids=[], + ) + + +RAW = ( + "We call our particular attention mechanism ``scaled dot-product attention''.\n" + "The input consists of queries and keys of dimension $d_k$, and values of\n" + "dimension $d_v$~\\cite{vaswani2017}. We compute the dot products of the query\n" + "with all keys, divide each by $\\sqrt{d_k}$, and apply a softmax function." +) + + +@pytest.mark.parametrize( + "quote", + [ + # TeX math delimiters dropped + "The input consists of queries and keys of dimension d_k, and values of dimension d_v", + # citation dropped, curly quotes, different case + "We call our particular attention mechanism “scaled dot-product attention”", + # \sqrt dropped + "divide each by d_k, and apply a softmax function", + ], +) +def test_a_quote_with_its_latex_cleaned_up_still_grounds(quote: str) -> None: + span = span_for_text(_section(RAW), quote) + assert span is not None, quote + grounded = RAW[span.start : span.end] + # The span is real text of the paper, not the model's rewrite of it. + assert grounded in RAW + assert grounded.split()[0].lower().strip("`") == quote.split()[0].lower().strip("“") + + +def test_a_partly_copied_quote_grounds_to_its_verbatim_run() -> None: + quote = ( + "We compute the dot products of the query with all keys, divide each by " + "the magic constant" + ) + span = span_for_text(_section(RAW), quote) + assert span is not None + assert RAW[span.start : span.end].startswith("We compute the dot products") + + +def test_a_mostly_invented_quote_does_not_ground_on_its_real_part() -> None: + """14 verbatim words out of 24 is under the 60% floor: the claim would rest + mostly on words the paper never wrote.""" + quote = ( + "We compute the dot products of the query with all keys, divide each by " + "the magic constant, and then do something the paper never said at all" + ) + assert span_for_text(_section(RAW), quote) is None + + +@pytest.mark.parametrize( + "invented", + [ + "Attention lets every token look at every other token in a single step", + "The softmax function", # a few real words, too short to be evidence + "queries keys values attention softmax dimension function input query keys", + ], +) +def test_text_the_paper_never_wrote_does_not_ground(invented: str) -> None: + assert span_for_text(_section(RAW), invented) is None + + +def test_the_exact_path_is_unchanged() -> None: + quote = "We compute the dot products of the query" + span = span_for_text(_section(RAW), quote) + assert span is not None and RAW[span.start : span.end] == quote + + +# --------------------------------------------------------------------------- # +# Analyze: attribution and the concept cascade +# --------------------------------------------------------------------------- # + + +class _Stub: + """Returns a fixed AnalysisOut.""" + + name = "stub" + + def __init__(self, out) -> None: + self.out = out + + def capabilities(self): + from arcvisual.providers.base import Capabilities + + return Capabilities( + name="stub", + native_structured_output=True, + prompt_cache=False, + vision=False, + cost_attributed=True, + ) + + def model_for(self, task): + return "stub" + + def structured(self, **_): + from arcvisual.providers.base import StructuredResult, Usage + + return StructuredResult(value=self.out, usage=Usage(), provider="stub", model="m") + + +def _analyse(concepts, opportunities): + from arcvisual.analyze.prompts import AnalysisOut + from arcvisual.analyze.single_pass import analyze + + sb = build_storyboard(metadata(), paper_tarball()) + out = AnalysisOut.model_validate( + {"concepts": concepts, "opportunities": opportunities, "section_difficulty": []} + ) + return analyze(sb, provider=_Stub(out)) + + +QUOTE_S003 = ( + "We compute the dot products of the query with all keys, divide each by the " + "square root of the key dimension" +) + + +def test_a_quote_attributed_to_the_wrong_section_is_found_in_the_right_one() -> None: + sb, _ = _analyse( + [ + { + "name": "Scaled attention", + "statement": "Dot products scaled by the key dimension.", + "section_id": "s000", # wrong: the text is in s003 + "quote": QUOTE_S003, + "depends_on": [], + "centrality": 0.9, + } + ], + [], + ) + assert [c.span.section_id for c in sb.concepts] == ["s003"] + + +def test_a_grounded_opportunity_survives_without_its_concept() -> None: + """The cascade that emptied a real article: the opportunity's own quote + grounds, its named concept did not, and no other concept shared its section.""" + sb, _ = _analyse( + [], + [ + { + "archetype": "concept_diagram", + "claim": "Each query is scored against every key, then scaled.", + "concept_name": "Scaled dot-product attention", + "section_id": "s003", + "quote": QUOTE_S003, + "justification": "The mechanism is a process the formula hides.", + "difficulty": 4, + "centrality": 0.9, + } + ], + ) + assert len(sb.opportunities) == 1 + concept = sb.concept(sb.opportunities[0].concept_id) + assert concept is not None and concept.name == "Scaled dot-product attention" + assert concept.span.section_id == "s003" + section = next(s for s in sb.sections if s.id == "s003") + assert concept.id in section.concept_ids