A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
improvement: AI context registry + codemirror decorated resources (#5962)
Myles Scolnick58c81cefabb3
diff --git a/frontend/package.json b/frontend/package.jsonindex 32d0e35de1..e1399782ee 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -47,6 +47,7 @@"@lezer/python": "^1.1.18","@marimo-team/codemirror-ai": "^0.1.11","@marimo-team/codemirror-languageserver": "^1.15.24",+ "@marimo-team/codemirror-mcp": "^0.1.5","@marimo-team/marimo-api": "workspace:*","@marimo-team/react-slotz": "^0.2.0","@mui/material": "^6.4.12",diff --git a/frontend/src/components/editor/ai/__tests__/completion-utils.test.ts b/frontend/src/components/editor/ai/__tests__/completion-utils.test.tsindex 7ef076d47c..60d7a2093f 100644--- a/frontend/src/components/editor/ai/__tests__/completion-utils.test.ts+++ b/frontend/src/components/editor/ai/__tests__/completion-utils.test.ts@@ -49,7 +49,7 @@ describe("getAICompletionBody", () => {];store.set(datasetsAtom, { tables: testDatasets } as DatasetsState);- const input = "Use @dataset1 and @dataset2 for analysis";+ const input = "Use @data://dataset1 and @data://dataset2 for analysis";const result = getAICompletionBody({ input });expect(result).toEqual({@@ -77,7 +77,7 @@ describe("getAICompletionBody", () => {});it("should handle input with no mentioned datasets", () => {- const input = "Perform some analysis without mentioning datasets";+ const input = "Perform some analysis without mentioning @data://datasets";const result = getAICompletionBody({ input });expect(result).toEqual({@@ -102,7 +102,8 @@ describe("getAICompletionBody", () => {];store.set(datasetsAtom, { tables: testDatasets } as DatasetsState);- const input = "Use @existingDataset and @nonExistentDataset for analysis";+ const input =+ "Use @data://existingDataset and @data://nonExistentDataset for analysis";const result = getAICompletionBody({ input });expect(result).toEqual({@@ -139,7 +140,8 @@ describe("getAICompletionBody", () => {];store.set(datasetsAtom, { tables: testDatasets } as DatasetsState);- const input = "Use @dataset.with.dots and @regular_dataset for analysis";+ const input =+ "Use @data://dataset.with.dots and @data://regular_dataset for analysis";const result = getAICompletionBody({ input });expect(result).toEqual({@@ -195,7 +197,7 @@ describe("getAICompletionBody", () => {connectionsMap: new Map().set(DUCKDB_ENGINE, testConnection),});- const input = "Use @table1 for analysis";+ const input = "Use @data://table1 for analysis";const result = getAICompletionBody({ input });expect(result).toEqual({@@ -232,7 +234,7 @@ describe("getAICompletionBody", () => {};store.set(variablesAtom, testVariables);- const input = "Use @var1 and @var2 for analysis";+ const input = "Use @variable://var1 and @variable://var2 for analysis";const result = getAICompletionBody({ input });expect(result).toEqual({@@ -279,7 +281,7 @@ describe("getAICompletionBody", () => {};store.set(variablesAtom, testVariables);- const input = "Use @dataset1 and @var1 for analysis";+ const input = "Use @data://dataset1 and @variable://var1 for analysis";const result = getAICompletionBody({ input });expect(result).toEqual({@@ -318,7 +320,8 @@ describe("getAICompletionBody", () => {};store.set(variablesAtom, testVariables);- const input = "Use @existingVar and @nonExistentVar for analysis";+ const input =+ "Use @variable://existingVar and @variable://nonExistentVar for analysis";const result = getAICompletionBody({ input });expect(result).toEqual({@@ -357,7 +360,7 @@ describe("getAICompletionBody", () => {};store.set(variablesAtom, testVariables);- const input = "Use @conflict for analysis";+ const input = "Use @data://conflict for analysis";const result = getAICompletionBody({ input });expect(result).toEqual({diff --git a/frontend/src/components/editor/ai/add-cell-with-ai.tsx b/frontend/src/components/editor/ai/add-cell-with-ai.tsxindex 45847e02f5..8a81f761f0 100644--- a/frontend/src/components/editor/ai/add-cell-with-ai.tsx+++ b/frontend/src/components/editor/ai/add-cell-with-ai.tsx@@ -6,6 +6,7 @@ import {type CompletionContext,type CompletionSource,} from "@codemirror/autocomplete";+import { markdown } from "@codemirror/lang-markdown";import { sql } from "@codemirror/lang-sql";import { Prec } from "@codemirror/state";import ReactCodeMirror, {@@ -15,7 +16,7 @@ import ReactCodeMirror, {type ReactCodeMirrorRef,} from "@uiw/react-codemirror";import { useCompletion } from "ai/react";-import { useAtom, useAtomValue } from "jotai";+import { useAtom, useStore } from "jotai";import { atomWithStorage } from "jotai/utils";import { ChevronsUpDown, Loader2Icon, SparklesIcon, XIcon } from "lucide-react";import { useMemo, useState } from "react";@@ -28,11 +29,10 @@ import {DropdownMenuTrigger,} from "@/components/ui/dropdown-menu";import { toast } from "@/components/ui/use-toast";+import { resourceExtension } from "@/core/codemirror/ai/resources";import { customPythonLanguageSupport } from "@/core/codemirror/language/languages/python";import { SQLLanguageAdapter } from "@/core/codemirror/language/languages/sql";-import { allTablesAtom } from "@/core/datasets/data-source-connections";import { useRuntimeManager } from "@/core/runtime/config";-import { variablesAtom } from "@/core/variables/state";import { type ResolvedTheme, useTheme } from "@/theme/useTheme";import { cn } from "@/utils/cn";import { prettyError } from "@/utils/errors";@@ -41,10 +41,6 @@ import {getAICompletionBody,mentionsCompletionSource,} from "./completion-utils";-import {- getTableMentionCompletions,- getVariableMentionCompletions,-} from "./completions";const pythonExtensions = [customPythonLanguageSupport(),@@ -247,35 +243,31 @@ export const PromptInput = ({}: PromptInputProps) => {const handleSubmit = onSubmit;const handleEscape = onClose;- const tablesMap = useAtomValue(allTablesAtom);- const variables = useAtomValue(variablesAtom);+ const store = useStore();- // TablesMap and variable change a lot,- // so we use useEvent to memoize the completion source- const completionSource: CompletionSource = useEvent(+ const additionalCompletionsSource: CompletionSource = useEvent((context: CompletionContext) => {- const completions = [- ...getTableMentionCompletions(tablesMap),- ...getVariableMentionCompletions(variables, tablesMap),- ];-- // Trigger autocompletion for text that begins with @, can contain dots- const matchBeforeRegexes = [/@([\w.]+)?/];- if (additionalCompletions) {- matchBeforeRegexes.push(additionalCompletions.triggerCompletionRegex);- completions.push(...additionalCompletions.completions);+ if (!additionalCompletions) {+ return null;}- return mentionsCompletionSource(matchBeforeRegexes, completions)(context);+ return mentionsCompletionSource(+ [additionalCompletions.triggerCompletionRegex],+ additionalCompletions.completions,+ )(context);},);// Changing extensions can be expensive, so// it is worth making sure this is memoized well.const extensions = useMemo(() => {+ const markdownLanguage = markdown();return [- autocompletion({- override: [completionSource],+ autocompletion({}),+ markdownLanguage,+ resourceExtension(markdownLanguage.language, store),+ markdownLanguage.language.data.of({+ autocomplete: additionalCompletionsSource,}),EditorView.lineWrapping,minimalSetup(),@@ -347,7 +339,7 @@ export const PromptInput = ({},]),];- }, [completionSource, handleSubmit, handleEscape]);+ }, [store, additionalCompletionsSource, handleSubmit, handleEscape]);return (<ReactCodeMirrordiff --git a/frontend/src/components/editor/ai/completion-utils.ts b/frontend/src/components/editor/ai/completion-utils.tsindex 3f70f75b8f..a1b106c97d 100644--- a/frontend/src/components/editor/ai/completion-utils.ts+++ b/frontend/src/components/editor/ai/completion-utils.ts@@ -5,13 +5,14 @@ import type {CompletionContext,CompletionSource,} from "@codemirror/autocomplete";+import { getAIContextRegistry } from "@/core/ai/context/context";+import type { TableContextItem } from "@/core/ai/context/providers/tables";+import type { VariableContextItem } from "@/core/ai/context/providers/variable";import { getCodes } from "@/core/codemirror/copilot/getCodes";-import { allTablesAtom } from "@/core/datasets/data-source-connections";import type { DataTable } from "@/core/kernel/messages";import type { AiCompletionRequest } from "@/core/network/types";import { store } from "@/core/state/jotai";-import { variablesAtom } from "@/core/variables/state";-import type { Variable, VariableName } from "@/core/variables/types";+import type { Variable } from "@/core/variables/types";import { Logger } from "@/utils/Logger";/**@@ -55,30 +56,15 @@ function extractDatasetsAndVariables(input: string): {datasets: DataTable[];variables: Variable[];} {- const allTables = store.get(allTablesAtom);- const allVariables = store.get(variablesAtom);-- // Extract mentions from the input- const mentions = input.match(/@([\w.]+)/g) || [];- const mentionedNames = mentions.map((mention) => mention.slice(1));-- const datasets: DataTable[] = [];- const variables: Variable[] = [];-- for (const name of mentionedNames) {- // First process datasets (higher priority)- const dataset = allTables.get(name);- if (dataset) {- datasets.push(dataset);- continue;- }-- // Then process variables if not already processed as datasets- const variable = allVariables[name as VariableName];- if (variable) {- variables.push(variable);- }- }+ const registry = getAIContextRegistry(store);+ const contextIds = registry.parseAllContextIds(input);+ const contextInfo = registry.getContextInfo(contextIds);+ const datasets: DataTable[] = contextInfo+ .filter((info): info is TableContextItem => info.type === "data")+ .map((info) => info.data);+ const variables: Variable[] = contextInfo+ .filter((info): info is VariableContextItem => info.type === "variable")+ .map((info) => info.data.variable);return { datasets, variables };}diff --git a/frontend/src/components/editor/ai/completions.ts b/frontend/src/components/editor/ai/completions.tsdeleted file mode 100644index 6a21b45094..0000000000--- a/frontend/src/components/editor/ai/completions.ts+++ /dev/null@@ -1,183 +0,0 @@-/* Copyright 2024 Marimo. All rights reserved. */--import type { Completion } from "@codemirror/autocomplete";-import { getVariableCompletions } from "@/core/codemirror/completion/variable-completions";-import type { DatasetTablesMap } from "@/core/datasets/data-source-connections";-import type { DataTable } from "@/core/kernel/messages";-import type { Variables } from "@/core/variables/types";--const Boosts = {- LOCAL_TABLE: 5,- REMOTE_TABLE: 4,- VARIABLE: 3,-} as const;--export function getVariableMentionCompletions(- variables: Variables,- tablesMap: DatasetTablesMap,-) {- return getVariableCompletions(- variables,- new Set(tablesMap.keys()),- Boosts.VARIABLE,- "@",- );-}--export function getTableMentionCompletions(tablesMap: DatasetTablesMap) {- return [...tablesMap.entries()].map(- ([tableName, table]): Completion => ({- label: `@${tableName}`,- displayLabel: tableName,- detail: table.source === "memory" ? "in-memory" : table.source,- boost:- table.source_type === "local"- ? Boosts.LOCAL_TABLE- : Boosts.REMOTE_TABLE,- type: table.variable_name ? "dataframe" : "table",- apply: `@${tableName}`,- // This may break in future, but if if it has a variable name,- // then it is a dataframe, otherwise it is a table.- section: table.variable_name ? "Dataframe" : "Table",- info: () => {- const infoContainer = document.createElement("div");- infoContainer.classList.add(- "mo-cm-tooltip",- "docs-documentation",- "min-w-[200px]",- );- infoContainer.style.display = "flex";- infoContainer.style.flexDirection = "column";- infoContainer.style.gap = ".8rem";- infoContainer.style.padding = "0.5rem";-- // Table header with name and source- const headerDiv = document.createElement("div");- headerDiv.classList.add("flex", "flex-col", "gap-1");-- const nameDiv = document.createElement("div");- nameDiv.classList.add("font-bold", "text-base");- nameDiv.textContent = tableName;- headerDiv.append(nameDiv);-- if (table.source) {- const sourceDiv = document.createElement("div");- sourceDiv.classList.add("text-xs", "text-muted-foreground");- sourceDiv.textContent = `Source: ${table.source}`;- headerDiv.append(sourceDiv);- }-- infoContainer.append(headerDiv);-- // Table shape info- const shape = [- table.num_rows == null ? undefined : `${table.num_rows} rows`,- table.num_columns == null- ? undefined- : `${table.num_columns} columns`,- ]- .filter(Boolean)- .join(", ");-- if (shape) {- const shapeDiv = document.createElement("div");- shapeDiv.classList.add(- "text-xs",- "bg-muted",- "px-2",- "py-1",- "rounded",- );- shapeDiv.textContent = shape;- infoContainer.append(shapeDiv);- }-- // Columns table- if (table.columns && table.columns.length > 0) {- const columnsDiv = document.createElement("div");- columnsDiv.classList.add("overflow-auto", "max-h-60");-- const columnsTable = document.createElement("table");- columnsTable.classList.add("w-full", "text-xs", "border-collapse");-- // Table header- const headerRow = columnsTable.insertRow();- headerRow.classList.add("bg-muted");-- const nameHeader = headerRow.insertCell();- nameHeader.classList.add("p-2", "font-medium", "text-left");- nameHeader.textContent = "Column";-- const typeHeader = headerRow.insertCell();- typeHeader.classList.add("p-2", "font-medium", "text-left");- typeHeader.textContent = "Type";- // Check if any column has metadata before adding the header- const hasAnyMetadata = table.columns.some(- (column) => getItemMetadata(table, column) !== undefined,- );-- let metadataHeader: HTMLTableCellElement | undefined;- if (hasAnyMetadata) {- metadataHeader = headerRow.insertCell();- metadataHeader.classList.add("p-2", "font-medium", "text-left");- metadataHeader.textContent = "Metadata";- }-- // Table rows- table.columns.forEach((column, index) => {- const row = columnsTable.insertRow();- row.classList.add(- index % 2 === 0 ? "bg-background" : "bg-muted/30",- );-- const nameCell = row.insertCell();- nameCell.classList.add("p-2", "font-mono");- nameCell.textContent = column.name;-- const typeCell = row.insertCell();- typeCell.classList.add("p-2", "text-muted-foreground");- typeCell.textContent = column.type;-- if (hasAnyMetadata) {- const metadataCell = row.insertCell();- metadataCell.classList.add("p-2");-- const itemMetadata = getItemMetadata(table, column);- if (itemMetadata) {- metadataCell.append(itemMetadata);- }- }- });-- columnsDiv.append(columnsTable);- infoContainer.append(columnsDiv);- }-- return infoContainer;- },- }),- );-}--function getItemMetadata(- table: DataTable,- column: DataTable["columns"][0],-): HTMLSpanElement | undefined {- const isPrimaryKey = table.primary_keys?.includes(column.name);- const isIndexed = table.indexes?.includes(column.name);- if (isPrimaryKey || isIndexed) {- const badge = document.createElement("span");- badge.textContent = isPrimaryKey ? "PK" : "IDX";- badge.classList.add(- "text-xs",- "px-1.5",- "py-0.5",- "rounded-full",- "font-medium",- isPrimaryKey- ? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"- : "bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200",- );- return badge;- }-}diff --git a/frontend/src/core/ai/context/__tests__/registry.test.ts b/frontend/src/core/ai/context/__tests__/registry.test.tsnew file mode 100644index 0000000000..c681dac706--- /dev/null+++ b/frontend/src/core/ai/context/__tests__/registry.test.ts@@ -0,0 +1,559 @@+/* Copyright 2024 Marimo. All rights reserved. */++import type { Completion } from "@codemirror/autocomplete";+import { beforeEach, describe, expect, it } from "vitest";+import {+ type AIContextItem,+ AIContextProvider,+ AIContextRegistry,+ type ContextLocatorId,+} from "../registry";++// Mock context item for testing+interface MockContextItem extends AIContextItem {+ type: "mock";+ data: { value: string };+}++// Concrete implementation of AIContextProvider for testing+class MockContextProvider extends AIContextProvider<MockContextItem> {+ readonly title = "Mock Items";+ readonly mentionPrefix = "@";+ readonly contextType = "mock";++ private items: MockContextItem[] = [+ {+ type: "mock",+ uri: this.asURI("item1"),+ name: "Item 1",+ description: "First mock item",+ data: { value: "value1" },+ },+ {+ type: "mock",+ uri: this.asURI("item2"),+ name: "Item 2",+ description: "Second mock item",+ data: { value: "value2" },+ },+ {+ type: "mock",+ uri: this.asURI("item_with_special-chars"),+ name: "Special Item",+ description: "Item with special characters",+ data: { value: "special" },+ },+ ];++ getItems(): MockContextItem[] {+ return this.items;+ }++ formatContext(item: MockContextItem): string {+ return `Mock: ${item.name} (${item.data.value})`;+ }++ formatCompletion(item: MockContextItem): Completion {+ return this.createBasicCompletion(item);+ }++ getCompletions(): Completion[] {+ return [];+ }++ // Method to add items for testing+ addItem(item: MockContextItem): void {+ this.items.push(item);+ }++ // Method to clear items for testing+ clearItems(): void {+ this.items = [];+ }+}++interface FileContextItem extends AIContextItem {+ type: "file";+ data: { value: string };+}++// Another mock provider with different prefix and type+class FileContextProvider extends AIContextProvider<FileContextItem> {+ readonly title = "Files";+ readonly mentionPrefix = "@";+ readonly contextType = "file";++ private items: FileContextItem[] = [+ {+ type: "file",+ uri: this.asURI("config.py"),+ name: "config.py",+ description: "Configuration file",+ data: { value: "config" },+ },+ {+ type: "file",+ uri: this.asURI("utils/helpers.py"),+ name: "utils/helpers.py",+ description: "Helper functions",+ data: { value: "helpers" },+ },+ ];++ getItems(): FileContextItem[] {+ return this.items;+ }++ formatCompletion(item: FileContextItem): Completion {+ return this.createBasicCompletion(item);+ }++ formatContext(item: FileContextItem): string {+ return `File: ${item.uri}\nDescription: ${item.description}`;+ }++ getCompletions(): Completion[] {+ return [];+ }+}++describe("AIContextProvider", () => {+ let provider: MockContextProvider;++ beforeEach(() => {+ provider = new MockContextProvider();+ });++ describe("formatContextId", () => {+ it("should format context ID correctly", () => {+ const item = provider.getItems()[0];+ const contextId = item.uri;+ expect(contextId).toBe("mock://item1");+ });++ it("should handle items with special characters", () => {+ const item = provider.getItems()[2];+ const contextId = item.uri;+ expect(contextId).toBe("mock://item_with_special-chars");+ });+ });++ describe("parseContextIds", () => {+ it("should parse valid mentions from input text", () => {+ const input = "Hello @mock://item1 and @mock://item2 world";+ const contextIds = provider.parseContextIds(input);+ expect(contextIds).toEqual(["mock://item1", "mock://item2"]);+ });++ it("should ignore invalid mentions", () => {+ const input = "Hello @mock://item1 and @nonexistent world";+ const contextIds = provider.parseContextIds(input);+ expect(contextIds).toEqual(["mock://item1"]);+ });++ it("should handle mentions with special characters", () => {+ const input = "Use @mock://item_with_special-chars here";+ const contextIds = provider.parseContextIds(input);+ expect(contextIds).toEqual(["mock://item_with_special-chars"]);+ });++ it("should handle input with no mentions", () => {+ const input = "This has no mentions";+ const contextIds = provider.parseContextIds(input);+ expect(contextIds).toEqual([]);+ });++ it("should handle empty input", () => {+ const input = "";+ const contextIds = provider.parseContextIds(input);+ expect(contextIds).toEqual([]);+ });++ it("should handle multiple occurrences of same mention", () => {+ const input = "@mock://item1 and @mock://item1 again";+ const contextIds = provider.parseContextIds(input);+ expect(contextIds).toEqual(["mock://item1"]);+ });+ });++ describe("createBasicCompletion", () => {+ it("should create completion with default options", () => {+ const item = provider.getItems()[0];+ // @ts-expect-error - createBasicCompletion is protected+ const completion = provider.createBasicCompletion(item);++ expect(completion).toEqual({+ label: "@item1",+ displayLabel: "Item 1",+ detail: "First mock item",+ boost: 1,+ type: "mock",+ apply: "@mock://item1",+ section: "Mock Items",+ });+ });++ it("should create completion with custom options", () => {+ const item = provider.getItems()[0];+ // @ts-expect-error - createBasicCompletion is protected+ const completion = provider.createBasicCompletion(item, {+ boost: 5,+ type: "custom",+ section: "Custom Section",+ detail: "Custom detail",+ });++ expect(completion).toEqual({+ label: "@item1",+ displayLabel: "Item 1",+ detail: "Custom detail",+ boost: 5,+ type: "custom",+ apply: "@mock://item1",+ section: "Custom Section",+ });+ });++ it("should handle item without description", () => {+ const itemWithoutDesc: MockContextItem = {+ type: "mock",+ uri: "no-desc",+ name: "No Description",+ data: { value: "test" },+ };++ // @ts-expect-error - createBasicCompletion is protected+ const completion = provider.createBasicCompletion(itemWithoutDesc);+ expect(completion.detail).toBeUndefined();+ });+ });++ describe("getCompletions", () => {+ it("should return empty array (refactored to use formatCompletion)", () => {+ const completions = provider.getCompletions();+ expect(completions).toEqual([]);+ });++ it("should return empty array when no items", () => {+ provider.clearItems();+ const completions = provider.getCompletions();+ expect(completions).toEqual([]);+ });+ });++ describe("formatCompletion", () => {+ it("should format completions correctly", () => {+ const items = provider.getItems();+ const completion = provider.formatCompletion(items[0]);+ expect(completion.label).toBe("@item1");+ expect(completion.displayLabel).toBe("Item 1");+ expect(completion.detail).toBe("First mock item");+ });+ });+});++describe("AIContextRegistry", () => {+ let registry: AIContextRegistry<MockContextItem | FileContextItem>;+ let mockProvider: MockContextProvider;+ let fileProvider: FileContextProvider;++ beforeEach(() => {+ registry = new AIContextRegistry();+ mockProvider = new MockContextProvider();+ fileProvider = new FileContextProvider();+ });++ describe("register", () => {+ it("should register a provider", () => {+ const result = registry.register(mockProvider);+ expect(result).toBe(registry); // Should return itself for chaining+ expect(registry.getProviders().has(mockProvider)).toBe(true);+ });++ it("should allow chaining multiple registrations", () => {+ const result = registry.register(mockProvider).register(fileProvider);++ expect(result).toBe(registry);+ expect(registry.getProviders().has(mockProvider)).toBe(true);+ expect(registry.getProviders().has(fileProvider)).toBe(true);+ });++ it("should not register the same provider twice", () => {+ registry.register(mockProvider);+ registry.register(mockProvider);++ const providers = [...registry.getProviders()];+ const mockProviderCount = providers.filter(+ (p) => p === mockProvider,+ ).length;+ expect(mockProviderCount).toBe(1);+ });+ });++ describe("getProviders", () => {+ it("should return empty set initially", () => {+ expect(registry.getProviders().size).toBe(0);+ });++ it("should return all registered providers", () => {+ registry.register(mockProvider);+ registry.register(fileProvider);++ const providers = registry.getProviders();+ expect(providers.size).toBe(2);+ expect(providers.has(mockProvider)).toBe(true);+ expect(providers.has(fileProvider)).toBe(true);+ });+ });++ describe("getProvider", () => {+ beforeEach(() => {+ registry.register(mockProvider);+ registry.register(fileProvider);+ });++ it("should return provider by type", () => {+ const provider = registry.getProvider("mock");+ expect(provider).toBe(mockProvider);+ });++ it("should return undefined for unknown type", () => {+ const provider = registry.getProvider("unknown");+ expect(provider).toBeUndefined();+ });++ it("should handle multiple providers correctly", () => {+ const mockProviderResult = registry.getProvider("mock");+ const fileProviderResult = registry.getProvider("file");++ expect(mockProviderResult).toBe(mockProvider);+ expect(fileProviderResult).toBe(fileProvider);+ });+ });++ describe("getAllCompletions", () => {+ it("should return empty array when no providers", () => {+ const completions = registry.getAllCompletions();+ expect(completions).toEqual([]);+ });++ it("should return empty array from providers (refactored to use formatCompletion)", () => {+ registry.register(mockProvider);+ const completions = registry.getAllCompletions();+ expect(completions).toEqual([]);+ });++ it("should return empty arrays from multiple providers", () => {+ registry.register(mockProvider);+ registry.register(fileProvider);++ const completions = registry.getAllCompletions();+ expect(completions).toEqual([]);+ });+ });++ describe("parseAllContextIds", () => {+ beforeEach(() => {+ registry.register(mockProvider);+ registry.register(fileProvider);+ });++ it("should parse context IDs from all providers", () => {+ const input = "Use @mock://item1 and @file://config.py here";+ const contextIds = registry.parseAllContextIds(input);++ expect(contextIds).toContain("mock://item1");+ expect(contextIds).toContain("file://config.py");+ expect(contextIds).toHaveLength(2);+ });++ it("should handle input with no mentions", () => {+ const input = "This has no mentions";+ const contextIds = registry.parseAllContextIds(input);+ expect(contextIds).toEqual([]);+ });++ it("should handle mixed valid and invalid mentions", () => {+ const input = "Use @mock://item1 and #nonexistent.py and @invalid";+ const contextIds = registry.parseAllContextIds(input);+ expect(contextIds).toEqual(["mock://item1"]);+ });++ it("should handle empty input", () => {+ const input = "";+ const contextIds = registry.parseAllContextIds(input);+ expect(contextIds).toEqual([]);+ });+ });++ describe("getContextInfo", () => {+ beforeEach(() => {+ registry.register(mockProvider);+ registry.register(fileProvider);+ });++ it("should return context info for valid IDs", () => {+ const contextIds: ContextLocatorId[] = [+ "mock://item1",+ "file://config.py",+ ] as ContextLocatorId[];+ const contextInfo = registry.getContextInfo(contextIds);++ expect(contextInfo).toHaveLength(2);+ expect(contextInfo[0].uri).toBe("mock://item1");+ expect(contextInfo[1].uri).toBe("file://config.py");+ });++ it("should ignore invalid context IDs", () => {+ const contextIds: ContextLocatorId[] = [+ "mock://item1",+ "mock://nonexistent",+ "unknown://item",+ ] as ContextLocatorId[];+ const contextInfo = registry.getContextInfo(contextIds);++ expect(contextInfo).toHaveLength(1);+ expect(contextInfo[0].uri).toBe("mock://item1");+ });++ it("should return empty array for empty input", () => {+ const contextInfo = registry.getContextInfo([]);+ expect(contextInfo).toEqual([]);+ });++ it("should handle malformed context IDs", () => {+ const contextIds: ContextLocatorId[] = [+ "malformed" as ContextLocatorId,+ "mock://item1",+ ] as ContextLocatorId[];+ const contextInfo = registry.getContextInfo(contextIds);++ expect(contextInfo).toHaveLength(1);+ expect(contextInfo[0].uri).toBe("mock://item1");+ });+ });++ describe("formatContextForAI", () => {+ beforeEach(() => {+ registry.register(mockProvider);+ registry.register(fileProvider);+ });++ it("should format context for AI with valid IDs", () => {+ const contextIds: ContextLocatorId[] = [+ "mock://item1",+ "file://config.py",+ ] as ContextLocatorId[];+ const formatted = registry.formatContextForAI(contextIds);++ expect(formatted).toMatchInlineSnapshot(`+ "Mock: Item 1 (value1)++ File: file://config.py+ Description: Configuration file"+ `);+ });++ it("should handle multiple items from same provider", () => {+ const contextIds: ContextLocatorId[] = [+ "mock://item1",+ "mock://item2",+ ] as ContextLocatorId[];+ const formatted = registry.formatContextForAI(contextIds);++ expect(formatted).toMatchInlineSnapshot(`+ "Mock: Item 1 (value1)++ Mock: Item 2 (value2)"+ `);+ });++ it("should return empty string for empty input", () => {+ const formatted = registry.formatContextForAI([]);+ expect(formatted).toBe("");+ });++ it("should ignore invalid context IDs", () => {+ const contextIds: ContextLocatorId[] = [+ "mock://item1",+ "unknown://item",+ "mock://nonexistent",+ ] as ContextLocatorId[];+ const formatted = registry.formatContextForAI(contextIds);++ expect(formatted).toContain("Mock: Item 1 (value1)");+ expect(formatted.split("\n\n")).toHaveLength(1);+ });++ it("should handle complex file paths", () => {+ const contextIds: ContextLocatorId[] = [+ "file://utils/helpers.py",+ ] as ContextLocatorId[];+ const formatted = registry.formatContextForAI(contextIds);++ expect(formatted).toMatchInlineSnapshot(`+ "File: file://utils/helpers.py+ Description: Helper functions"+ `);+ });++ it("should handle malformed context IDs gracefully", () => {+ const contextIds: ContextLocatorId[] = [+ "mock://item1",+ ] as ContextLocatorId[];+ const formatted = registry.formatContextForAI(contextIds);++ expect(formatted).toContain("Mock: Item 1 (value1)");+ expect(formatted.split("\n\n")).toHaveLength(1);+ });+ });++ describe("edge cases and error handling", () => {+ it("should handle provider with no items", () => {+ const emptyProvider = new MockContextProvider();+ emptyProvider.clearItems();+ registry.register(emptyProvider);++ expect(registry.getAllCompletions()).toEqual([]);+ expect(registry.parseAllContextIds("@anything")).toEqual([]);+ expect(+ registry.getContextInfo(["mock://anything"] as ContextLocatorId[]),+ ).toEqual([]);+ expect(+ registry.formatContextForAI(["mock://anything"] as ContextLocatorId[]),+ ).toBe("");+ });++ it("should handle context ID with multiple colons", () => {+ // Add an item with colon in the ID+ const specialItem: MockContextItem = {+ type: "mock",+ uri: "mock://namespace:item:with:colons", // Note: current implementation has a bug with split(":", 2)+ name: "Special Item",+ data: { value: "special" },+ };+ mockProvider.addItem(specialItem);+ registry.register(mockProvider);++ const contextIds: ContextLocatorId[] = [+ "mock://namespace:item:with:colons",+ ] as ContextLocatorId[];+ const contextInfo = registry.getContextInfo(contextIds);++ // Current implementation only gets "namespace" as id due to split(":", 2)+ // This is likely a bug - it should split only on first colon+ expect(contextInfo).toHaveLength(1);+ expect(contextInfo[0].uri).toBe("mock://namespace:item:with:colons");+ });++ it("should handle providers with same context type", () => {+ const anotherMockProvider = new MockContextProvider();+ registry.register(mockProvider);+ registry.register(anotherMockProvider);++ // Should return the first registered provider+ const provider = registry.getProvider("mock");+ expect(provider).toBe(mockProvider);+ });+ });+});diff --git a/frontend/src/core/ai/context/context.ts b/frontend/src/core/ai/context/context.tsnew file mode 100644index 0000000000..573cf17751--- /dev/null+++ b/frontend/src/core/ai/context/context.ts@@ -0,0 +1,16 @@+/* Copyright 2024 Marimo. All rights reserved. */++import { allTablesAtom } from "@/core/datasets/data-source-connections";+import type { JotaiStore } from "@/core/state/jotai";+import { variablesAtom } from "@/core/variables/state";+import { TableContextProvider } from "./providers/tables";+import { VariableContextProvider } from "./providers/variable";+import { AIContextRegistry } from "./registry";++export function getAIContextRegistry(store: JotaiStore) {+ const tablesMap = store.get(allTablesAtom);+ const variables = store.get(variablesAtom);+ return new AIContextRegistry()+ .register(new TableContextProvider(tablesMap))+ .register(new VariableContextProvider(variables, tablesMap));+}diff --git a/frontend/src/core/ai/context/providers/__tests__/__snapshots__/tables.test.ts.snap b/frontend/src/core/ai/context/providers/__tests__/__snapshots__/tables.test.ts.snapnew file mode 100644index 0000000000..07ee3240b8--- /dev/null+++ b/frontend/src/core/ai/context/providers/__tests__/__snapshots__/tables.test.ts.snap@@ -0,0 +1,301 @@+// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html++exports[`TableContextProvider > formatContext > should format context for basic table > basic-table-context 1`] = `+"Table: products+Source: memory+Shape: 100 rows, 3 columns+Columns:+ - id: integer+ - name: string+ - active: boolean"+`;++exports[`TableContextProvider > formatContext > should format context for remote database table > remote-table-context 1`] = `+"Table: remote_table+Source: postgresql://localhost:5432/mydb+Shape: 100 rows, 3 columns+Columns:+ - uuid: string+ - created_at: string+ - metadata: string"+`;++exports[`TableContextProvider > formatContext > should format context for table without columns > no-columns-table-context 1`] = `+"Table: no_columns+Source: memory+Shape: 100 rows, 3 columns"+`;++exports[`TableContextProvider > formatContext > should format context for table without shape info > no-shape-table-context 1`] = `+"Table: no_shape+Source: memory+Columns:+ - id: integer+ - name: string+ - active: boolean"+`;++exports[`TableContextProvider > getCompletions > should handle tables with special characters in names > special-chars-table-completions 1`] = `[]`;++exports[`TableContextProvider > getCompletions > should return completions for dataframes vs tables > mixed-table-dataframe-completions 1`] = `[]`;++exports[`TableContextProvider > getCompletions > should return completions for memory tables > memory-table-completions 1`] = `[]`;++exports[`TableContextProvider > getCompletions > should return completions for remote tables > remote-table-completions 1`] = `[]`;++exports[`TableContextProvider > getCompletions > should return empty completions when no tables > empty-completions 1`] = `[]`;++exports[`TableContextProvider > getItems > should handle dataframe tables with variable names > dataframe-table 1`] = `+[+ {+ "data": {+ "columns": [+ {+ "external_type": "datetime64[ns]",+ "name": "timestamp",+ "sample_values": [+ "sample_timestamp_1",+ "sample_timestamp_2",+ ],+ "type": "string",+ },+ {+ "external_type": "float64",+ "name": "value",+ "sample_values": [+ "sample_value_1",+ "sample_value_2",+ ],+ "type": "number",+ },+ {+ "external_type": "object",+ "name": "category",+ "sample_values": [+ "sample_category_1",+ "sample_category_2",+ ],+ "type": "string",+ },+ ],+ "engine": null,+ "indexes": null,+ "name": "df_analysis",+ "num_columns": 3,+ "num_rows": 100,+ "primary_keys": [+ "id",+ ],+ "source": "pandas",+ "source_type": "local",+ "type": "table",+ "variable_name": "df_analysis",+ },+ "description": "pandas",+ "name": "df_analysis",+ "type": "data",+ "uri": "data://df_analysis",+ },+]+`;++exports[`TableContextProvider > getItems > should handle tables with minimal information > minimal-table 1`] = `+[+ {+ "data": {+ "columns": [],+ "engine": null,+ "indexes": null,+ "name": "minimal",+ "num_columns": null,+ "num_rows": null,+ "primary_keys": null,+ "source": "",+ "source_type": "local",+ "type": "table",+ "variable_name": null,+ },+ "description": "",+ "name": "minimal",+ "type": "data",+ "uri": "data://minimal",+ },+]+`;++exports[`TableContextProvider > getItems > should return empty array when no tables > empty-tables 1`] = `[]`;++exports[`TableContextProvider > getItems > should return table items for multiple tables > multiple-tables 1`] = `+[+ {+ "data": {+ "columns": [+ {+ "external_type": "int64",+ "name": "id",+ "sample_values": [+ "sample_id_1",+ "sample_id_2",+ ],+ "type": "integer",+ },+ {+ "external_type": "varchar",+ "name": "name",+ "sample_values": [+ "sample_name_1",+ "sample_name_2",+ ],+ "type": "string",+ },+ {+ "external_type": "bool",+ "name": "active",+ "sample_values": [+ "sample_active_1",+ "sample_active_2",+ ],+ "type": "boolean",+ },+ ],+ "engine": null,+ "indexes": null,+ "name": "users",+ "num_columns": 3,+ "num_rows": 100,+ "primary_keys": [+ "id",+ ],+ "source": "memory",+ "source_type": "local",+ "type": "table",+ "variable_name": null,+ },+ "description": "in-memory",+ "name": "users",+ "type": "data",+ "uri": "data://users",+ },+ {+ "data": {+ "columns": [+ {+ "external_type": "integer",+ "name": "order_id",+ "sample_values": [+ "sample_order_id_1",+ "sample_order_id_2",+ ],+ "type": "integer",+ },+ {+ "external_type": "integer",+ "name": "user_id",+ "sample_values": [+ "sample_user_id_1",+ "sample_user_id_2",+ ],+ "type": "integer",+ },+ {+ "external_type": "decimal",+ "name": "amount",+ "sample_values": [+ "sample_amount_1",+ "sample_amount_2",+ ],+ "type": "number",+ },+ {+ "external_type": "timestamp",+ "name": "created_at",+ "sample_values": [+ "sample_created_at_1",+ "sample_created_at_2",+ ],+ "type": "string",+ },+ {+ "external_type": "enum",+ "name": "status",+ "sample_values": [+ "sample_status_1",+ "sample_status_2",+ ],+ "type": "string",+ },+ ],+ "engine": null,+ "indexes": null,+ "name": "orders",+ "num_columns": 5,+ "num_rows": 250,+ "primary_keys": [+ "id",+ ],+ "source": "database.db",+ "source_type": "duckdb",+ "type": "view",+ "variable_name": null,+ },+ "description": "database.db",+ "name": "orders",+ "type": "data",+ "uri": "data://orders",+ },+]+`;++exports[`TableContextProvider > getItems > should return table items for single table > single-table 1`] = `+[+ {+ "data": {+ "columns": [+ {+ "external_type": "int64",+ "name": "id",+ "sample_values": [+ "sample_id_1",+ "sample_id_2",+ ],+ "type": "integer",+ },+ {+ "external_type": "varchar",+ "name": "name",+ "sample_values": [+ "sample_name_1",+ "sample_name_2",+ ],+ "type": "string",+ },+ {+ "external_type": "bool",+ "name": "active",+ "sample_values": [+ "sample_active_1",+ "sample_active_2",+ ],+ "type": "boolean",+ },+ ],+ "engine": null,+ "indexes": null,+ "name": "users",+ "num_columns": 3,+ "num_rows": 100,+ "primary_keys": [+ "id",+ ],+ "source": "memory",+ "source_type": "local",+ "type": "table",+ "variable_name": null,+ },+ "description": "in-memory",+ "name": "users",+ "type": "data",+ "uri": "data://users",+ },+]+`;diff --git a/frontend/src/core/ai/context/providers/__tests__/__snapshots__/variable.test.ts.snap b/frontend/src/core/ai/context/providers/__tests__/__snapshots__/variable.test.ts.snapnew file mode 100644index 0000000000..8f23b4713c--- /dev/null+++ b/frontend/src/core/ai/context/providers/__tests__/__snapshots__/variable.test.ts.snap@@ -0,0 +1,386 @@+// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html++exports[`VariableContextProvider > formatContext > should format context for basic variable > basic-variable-context 1`] = `+"Variable: username+Type: str+Preview: "\\"alice\\"""+`;++exports[`VariableContextProvider > formatContext > should format context for dataframe variable > dataframe-variable-context 1`] = `+"Variable: sales_df+Type: pandas.DataFrame+Preview: "<DataFrame shape: (1000, 8)>\\n date product quantity price\\n0 2023-01-01 Widget A 10 29.99\\n1 2023-01-02 Widget B 5 49.99\\n...""+`;++exports[`VariableContextProvider > formatContext > should format context for variable with complex value > complex-value-variable-context 1`] = `+"Variable: complex_data+Type: dict+Preview: "{\\"users\\": [{\\"id\\": 1, \\"name\\": \\"Alice\\"}, {\\"id\\": 2, \\"name\\": \\"Bob\\"}], \\"total\\": 2}""+`;++exports[`VariableContextProvider > formatContext > should format context for variable without dataType > no-datatype-variable-context 1`] = `+"Variable: mystery_var+Type: unknown+Preview: "some_value""+`;++exports[`VariableContextProvider > getCompletions > should pass table names to completion function > variable-completions-with-tables 1`] = `[]`;++exports[`VariableContextProvider > getCompletions > should return completions for variables > variable-completions 1`] = `[]`;++exports[`VariableContextProvider > getCompletions > should return empty completions when no variables > empty-variable-completions 1`] = `[]`;++exports[`VariableContextProvider > getItems > should handle complex data types > complex-data-types 1`] = `+[+ {+ "data": {+ "variable": {+ "dataType": "pandas.DataFrame",+ "declaredBy": [+ "cell1",+ ],+ "name": "df",+ "usedBy": [+ "cell2",+ "cell3",+ ],+ "value": "<DataFrame shape: (100, 5)>",+ },+ },+ "dataType": "pandas.DataFrame",+ "description": "pandas.DataFrame",+ "name": "df",+ "type": "variable",+ "uri": "variable://df",+ },+ {+ "data": {+ "variable": {+ "dataType": "sklearn.linear_model._base.LinearRegression",+ "declaredBy": [+ "cell4",+ ],+ "name": "model",+ "usedBy": [+ "cell5",+ ],+ "value": "<sklearn.linear_model.LinearRegression>",+ },+ },+ "dataType": "sklearn.linear_model._base.LinearRegression",+ "description": "sklearn.linear_model._base.LinearRegression",+ "name": "model",+ "type": "variable",+ "uri": "variable://model",+ },+ {+ "data": {+ "variable": {+ "dataType": "numpy.ndarray",+ "declaredBy": [+ "cell2",+ ],+ "name": "array",+ "usedBy": [+ "cell3",+ ],+ "value": "array([1, 2, 3, 4, 5])",+ },+ },+ "dataType": "numpy.ndarray",+ "description": "numpy.ndarray",+ "name": "array",+ "type": "variable",+ "uri": "variable://array",+ },+]+`;++exports[`VariableContextProvider > getItems > should handle variables with null/undefined values > null-undefined-variables 1`] = `+[+ {+ "data": {+ "variable": {+ "dataType": "NoneType",+ "declaredBy": [+ "cell1",+ ],+ "name": "null_var",+ "usedBy": [+ "cell2",+ ],+ "value": null,+ },+ },+ "dataType": "NoneType",+ "description": "NoneType",+ "name": "null_var",+ "type": "variable",+ "uri": "variable://null_var",+ },+ {+ "data": {+ "variable": {+ "dataType": null,+ "declaredBy": [+ "cell1",+ ],+ "name": "undefined_var",+ "usedBy": [+ "cell2",+ ],+ "value": undefined,+ },+ },+ "dataType": null,+ "description": "",+ "name": "undefined_var",+ "type": "variable",+ "uri": "variable://undefined_var",+ },+ {+ "data": {+ "variable": {+ "dataType": "str",+ "declaredBy": [+ "cell1",+ ],+ "name": "empty_string",+ "usedBy": [+ "cell2",+ ],+ "value": """",+ },+ },+ "dataType": "str",+ "description": "str",+ "name": "empty_string",+ "type": "variable",+ "uri": "variable://empty_string",+ },+]+`;++exports[`VariableContextProvider > getItems > should handle variables with special characters in names > special-chars-variables 1`] = `+[+ {+ "data": {+ "variable": {+ "dataType": "int",+ "declaredBy": [+ "cell1",+ ],+ "name": "_private_var",+ "usedBy": [+ "cell2",+ ],+ "value": "42",+ },+ },+ "dataType": "int",+ "description": "int",+ "name": "_private_var",+ "type": "variable",+ "uri": "variable://_private_var",+ },+ {+ "data": {+ "variable": {+ "dataType": "str",+ "declaredBy": [+ "cell1",+ ],+ "name": "var_with_numbers123",+ "usedBy": [+ "cell2",+ ],+ "value": ""test"",+ },+ },+ "dataType": "str",+ "description": "str",+ "name": "var_with_numbers123",+ "type": "variable",+ "uri": "variable://var_with_numbers123",+ },+ {+ "data": {+ "variable": {+ "dataType": "float",+ "declaredBy": [+ "cell1",+ ],+ "name": "CONSTANT_VAR",+ "usedBy": [+ "cell2",+ ],+ "value": "3.14159",+ },+ },+ "dataType": "float",+ "description": "float",+ "name": "CONSTANT_VAR",+ "type": "variable",+ "uri": "variable://CONSTANT_VAR",+ },+]+`;++exports[`VariableContextProvider > getItems > should return empty array when no variables > empty-variables 1`] = `[]`;++exports[`VariableContextProvider > getItems > should return variable items for multiple variables with different types > multiple-variables 1`] = `+[+ {+ "data": {+ "variable": {+ "dataType": "int",+ "declaredBy": [+ "cell1",+ ],+ "name": "user_id",+ "usedBy": [+ "cell2",+ "cell3",+ ],+ "value": "123",+ },+ },+ "dataType": "int",+ "description": "int",+ "name": "user_id",+ "type": "variable",+ "uri": "variable://user_id",+ },+ {+ "data": {+ "variable": {+ "dataType": "bool",+ "declaredBy": [+ "cell2",+ ],+ "name": "is_active",+ "usedBy": [],+ "value": "True",+ },+ },+ "dataType": "bool",+ "description": "bool",+ "name": "is_active",+ "type": "variable",+ "uri": "variable://is_active",+ },+ {+ "data": {+ "variable": {+ "dataType": "list",+ "declaredBy": [+ "cell3",+ ],+ "name": "scores",+ "usedBy": [+ "cell4",+ ],+ "value": "[1, 2, 3, 4, 5]",+ },+ },+ "dataType": "list",+ "description": "list",+ "name": "scores",+ "type": "variable",+ "uri": "variable://scores",+ },+ {+ "data": {+ "variable": {+ "dataType": "dict",+ "declaredBy": [+ "cell1",+ ],+ "name": "config",+ "usedBy": [+ "cell2",+ "cell4",+ ],+ "value": "{"debug": true, "timeout": 30}",+ },+ },+ "dataType": "dict",+ "description": "dict",+ "name": "config",+ "type": "variable",+ "uri": "variable://config",+ },+]+`;++exports[`VariableContextProvider > getItems > should return variable items for single variable > single-variable 1`] = `+[+ {+ "data": {+ "variable": {+ "dataType": "str",+ "declaredBy": [+ "cell1",+ ],+ "name": "user_name",+ "usedBy": [+ "cell2",+ ],+ "value": ""John Doe"",+ },+ },+ "dataType": "str",+ "description": "str",+ "name": "user_name",+ "type": "variable",+ "uri": "variable://user_name",+ },+]+`;++exports[`VariableContextProvider > integration with tables > should work with both variables and tables > variables-with-tables-completions 1`] = `[]`;++exports[`VariableContextProvider > integration with tables > should work with both variables and tables > variables-with-tables-items 1`] = `+[+ {+ "data": {+ "variable": {+ "dataType": "pandas.DataFrame",+ "declaredBy": [+ "cell1",+ ],+ "name": "df",+ "usedBy": [+ "cell2",+ ],+ "value": "<DataFrame shape: (50, 3)>",+ },+ },+ "dataType": "pandas.DataFrame",+ "description": "pandas.DataFrame",+ "name": "df",+ "type": "variable",+ "uri": "variable://df",+ },+ {+ "data": {+ "variable": {+ "dataType": "str",+ "declaredBy": [+ "cell1",+ ],+ "name": "connection_string",+ "usedBy": [+ "cell2",+ ],+ "value": ""postgresql://localhost:5432/mydb"",+ },+ },+ "dataType": "str",+ "description": "str",+ "name": "connection_string",+ "type": "variable",+ "uri": "variable://connection_string",+ },+]+`;diff --git a/frontend/src/core/ai/context/providers/__tests__/tables.test.ts b/frontend/src/core/ai/context/providers/__tests__/tables.test.tsnew file mode 100644index 0000000000..a2e4399da3--- /dev/null+++ b/frontend/src/core/ai/context/providers/__tests__/tables.test.ts@@ -0,0 +1,330 @@+/* Copyright 2024 Marimo. All rights reserved. */++import { describe, expect, it } from "vitest";+import type { DatasetTablesMap } from "@/core/datasets/data-source-connections";+import type { DataTable, DataTableColumn } from "@/core/kernel/messages";+import { type TableContextItem, TableContextProvider } from "../tables";++// Mock data for testing+const createMockColumn = (+ name: string,+ type: string,+ externalType?: string,+): DataTableColumn => ({+ name,+ type: type as DataTableColumn["type"],+ external_type: externalType || type,+ sample_values: [`sample_${name}_1`, `sample_${name}_2`],+});++const createMockTable = (+ name: string,+ options: Partial<DataTable> = {},+): DataTable => ({+ name,+ source: "memory",+ source_type: "local",+ type: "table",+ columns: [+ createMockColumn("id", "integer", "int64"),+ createMockColumn("name", "string", "varchar"),+ createMockColumn("active", "boolean", "bool"),+ ],+ num_rows: 100,+ num_columns: 3,+ engine: null,+ indexes: null,+ primary_keys: ["id"],+ variable_name: null,+ ...options,+});++describe("TableContextProvider", () => {+ describe("getItems", () => {+ it("should return empty array when no tables", () => {+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new TableContextProvider(tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("empty-tables");+ });++ it("should return table items for single table", () => {+ const table = createMockTable("users");+ const tablesMap: DatasetTablesMap = new Map([["users", table]]);+ const provider = new TableContextProvider(tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("single-table");+ });++ it("should return table items for multiple tables", () => {+ const usersTable = createMockTable("users");+ const ordersTable = createMockTable("orders", {+ source: "database.db",+ source_type: "duckdb",+ type: "view",+ num_rows: 250,+ num_columns: 5,+ columns: [+ createMockColumn("order_id", "integer"),+ createMockColumn("user_id", "integer"),+ createMockColumn("amount", "number", "decimal"),+ createMockColumn("created_at", "string", "timestamp"),+ createMockColumn("status", "string", "enum"),+ ],+ });+ const tablesMap: DatasetTablesMap = new Map([+ ["users", usersTable],+ ["orders", ordersTable],+ ]);+ const provider = new TableContextProvider(tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("multiple-tables");+ });++ it("should handle dataframe tables with variable names", () => {+ const dfTable = createMockTable("df_analysis", {+ variable_name: "df_analysis",+ source: "pandas",+ source_type: "local",+ columns: [+ createMockColumn("timestamp", "string", "datetime64[ns]"),+ createMockColumn("value", "number", "float64"),+ createMockColumn("category", "string", "object"),+ ],+ });+ const tablesMap: DatasetTablesMap = new Map([["df_analysis", dfTable]]);+ const provider = new TableContextProvider(tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("dataframe-table");+ });++ it("should handle tables with minimal information", () => {+ const minimalTable = createMockTable("minimal", {+ columns: [],+ num_rows: null,+ num_columns: null,+ source: "",+ primary_keys: null,+ indexes: null,+ });+ const tablesMap: DatasetTablesMap = new Map([["minimal", minimalTable]]);+ const provider = new TableContextProvider(tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("minimal-table");+ });+ });++ describe("formatContext", () => {+ it("should format context for basic table", () => {+ const table = createMockTable("products");+ const item: TableContextItem = {+ type: "data",+ uri: "products",+ name: "products",+ description: "memory",+ data: table,+ };++ const tablesMap: DatasetTablesMap = new Map([["products", table]]);+ const provider = new TableContextProvider(tablesMap);++ const context = provider.formatContext(item);+ expect(context).toMatchSnapshot("basic-table-context");+ });++ it("should format context for table without shape info", () => {+ const table = createMockTable("no_shape", {+ num_rows: null,+ num_columns: null,+ });+ const item: TableContextItem = {+ type: "data",+ uri: "no_shape",+ name: "no_shape",+ description: "memory",+ data: table,+ };++ const tablesMap: DatasetTablesMap = new Map([["no_shape", table]]);+ const provider = new TableContextProvider(tablesMap);++ const context = provider.formatContext(item);+ expect(context).toMatchSnapshot("no-shape-table-context");+ });++ it("should format context for table without columns", () => {+ const table = createMockTable("no_columns", {+ columns: [],+ });+ const item: TableContextItem = {+ type: "data",+ uri: "no_columns",+ name: "no_columns",+ description: "memory",+ data: table,+ };++ const tablesMap: DatasetTablesMap = new Map([["no_columns", table]]);+ const provider = new TableContextProvider(tablesMap);++ const context = provider.formatContext(item);+ expect(context).toMatchSnapshot("no-columns-table-context");+ });++ it("should format context for remote database table", () => {+ const table = createMockTable("remote_table", {+ source: "postgresql://localhost:5432/mydb",+ source_type: "connection",+ engine: "postgresql",+ columns: [+ createMockColumn("uuid", "string", "uuid"),+ createMockColumn("created_at", "string", "timestamp with time zone"),+ createMockColumn("metadata", "string", "jsonb"),+ ],+ });+ const item: TableContextItem = {+ type: "data",+ uri: "remote_table",+ name: "remote_table",+ description: "postgresql://localhost:5432/mydb",+ data: table,+ };++ const tablesMap: DatasetTablesMap = new Map([["remote_table", table]]);+ const provider = new TableContextProvider(tablesMap);++ const context = provider.formatContext(item);+ expect(context).toMatchSnapshot("remote-table-context");+ });+ });++ describe("getCompletions", () => {+ it("should return empty completions when no tables", () => {+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new TableContextProvider(tablesMap);++ const completions = provider.getCompletions();+ expect(completions).toMatchSnapshot("empty-completions");+ });++ it("should return completions for memory tables", () => {+ const table = createMockTable("users");+ const tablesMap: DatasetTablesMap = new Map([["users", table]]);+ const provider = new TableContextProvider(tablesMap);++ const completions = provider.getCompletions();+ expect(completions).toMatchSnapshot("memory-table-completions");+ });++ it("should return completions for remote tables", () => {+ const remoteTable = createMockTable("analytics", {+ source: "bigquery://project/dataset",+ source_type: "connection",+ });+ const tablesMap: DatasetTablesMap = new Map([["analytics", remoteTable]]);+ const provider = new TableContextProvider(tablesMap);++ const completions = provider.getCompletions();+ expect(completions).toMatchSnapshot("remote-table-completions");+ });++ it("should return completions for dataframes vs tables", () => {+ const regularTable = createMockTable("regular_table");+ const dataframeTable = createMockTable("df", {+ variable_name: "df",+ source: "pandas",+ });++ const tablesMap: DatasetTablesMap = new Map([+ ["regular_table", regularTable],+ ["df", dataframeTable],+ ]);+ const provider = new TableContextProvider(tablesMap);++ const completions = provider.getCompletions();+ expect(completions).toMatchSnapshot("mixed-table-dataframe-completions");+ });++ it("should handle tables with special characters in names", () => {+ const specialTable = createMockTable("my-table_with.special@chars");+ const tablesMap: DatasetTablesMap = new Map([+ ["my-table_with.special@chars", specialTable],+ ]);+ const provider = new TableContextProvider(tablesMap);++ const completions = provider.getCompletions();+ expect(completions).toMatchSnapshot("special-chars-table-completions");+ });+ });++ describe("provider properties", () => {+ it("should have correct provider properties", () => {+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new TableContextProvider(tablesMap);++ expect(provider.title).toBe("Tables");+ expect(provider.mentionPrefix).toBe("@");+ expect(provider.contextType).toBe("data");+ });+ });++ describe("createTableInfoElement", () => {+ it("should create info element for table with all properties", () => {+ const table = createMockTable("full_table", {+ source: "my_database.db",+ num_rows: 1000,+ num_columns: 5,+ columns: [+ createMockColumn("id", "integer", "bigint"),+ createMockColumn("name", "string", "varchar(255)"),+ createMockColumn("score", "number", "decimal(10,2)"),+ ],+ });+ const tablesMap: DatasetTablesMap = new Map([["full_table", table]]);+ const provider = new TableContextProvider(tablesMap);++ // @ts-expect-error - accessing private method for testing+ const element = provider.createTableInfoElement("full_table", table);++ expect(element.tagName).toBe("DIV");+ expect(element.classList.contains("mo-cm-tooltip")).toBe(true);+ expect(element.textContent).toMatchInlineSnapshot(+ `"full_tableSource: my_database.db1000 rows, 5 columnsColumnTypeMetadataidintegerPKnamestringscorenumber"`,+ );+ });++ it("should create info element for table without source", () => {+ const table = createMockTable("no_source", {+ source: "",+ });+ const tablesMap: DatasetTablesMap = new Map([["no_source", table]]);+ const provider = new TableContextProvider(tablesMap);++ // @ts-expect-error - accessing private method for testing+ const element = provider.createTableInfoElement("no_source", table);++ expect(element.textContent).toContain("no_source");+ expect(element.textContent).not.toContain("Source:");+ });++ it("should create info element for table without columns", () => {+ const table = createMockTable("no_cols", {+ columns: [],+ });+ const tablesMap: DatasetTablesMap = new Map([["no_cols", table]]);+ const provider = new TableContextProvider(tablesMap);++ // @ts-expect-error - accessing private method for testing+ const element = provider.createTableInfoElement("no_cols", table);++ expect(element.textContent).toContain("no_cols");+ // Should not contain a table element+ expect(element.querySelector("table")).toBeNull();+ });+ });+});diff --git a/frontend/src/core/ai/context/providers/__tests__/variable.test.ts b/frontend/src/core/ai/context/providers/__tests__/variable.test.tsnew file mode 100644index 0000000000..c891489e18--- /dev/null+++ b/frontend/src/core/ai/context/providers/__tests__/variable.test.ts@@ -0,0 +1,358 @@+/* Copyright 2024 Marimo. All rights reserved. */+/* eslint-disable @typescript-eslint/no-explicit-any */++import { describe, expect, it, vi } from "vitest";+import type { CellId } from "@/core/cells/ids";+import type { DatasetTablesMap } from "@/core/datasets/data-source-connections";+import type { Variable, VariableName, Variables } from "@/core/variables/types";+import { type VariableContextItem, VariableContextProvider } from "../variable";++// Mock the variable completions module+vi.mock("@/core/codemirror/completion/variable-completions", () => ({+ getVariableCompletions: vi.fn(+ (+ variables: Variables,+ _tableNames: string[],+ boost: number,+ prefix: string,+ ) => {+ return Object.entries(variables).map(([name, variable]) => ({+ name: `${prefix}${name}`,+ displayname: name,+ detail: variable.dataType || "unknown",+ boost,+ type: variable.dataType || "variable",+ apply: `${prefix}${name}`,+ section: "Variables",+ }));+ },+ ),+}));++// Mock data for testing+const createMockVariable = (+ name: string,+ options: Partial<Variable> = {},+): Variable => ({+ name: name as VariableName,+ declaredBy: ["cell1" as CellId],+ usedBy: ["cell2" as CellId],+ value: `value_of_${name}`,+ dataType: "str",+ ...options,+});++describe("VariableContextProvider", () => {+ describe("getItems", () => {+ it("should return empty array when no variables", () => {+ const variables: Variables = {};+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("empty-variables");+ });++ it("should return variable items for single variable", () => {+ const variables: Variables = {+ ["user_name" as VariableName]: createMockVariable("user_name", {+ value: '"John Doe"',+ dataType: "str",+ }),+ };+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("single-variable");+ });++ it("should return variable items for multiple variables with different types", () => {+ const variables: Variables = {+ ["user_id" as VariableName]: createMockVariable("user_id", {+ value: "123",+ dataType: "int",+ declaredBy: ["cell1" as CellId],+ usedBy: ["cell2" as CellId, "cell3" as CellId],+ }),+ ["is_active" as VariableName]: createMockVariable("is_active", {+ value: "True",+ dataType: "bool",+ declaredBy: ["cell2" as CellId],+ usedBy: [],+ }),+ ["scores" as VariableName]: createMockVariable("scores", {+ value: "[1, 2, 3, 4, 5]",+ dataType: "list",+ declaredBy: ["cell3" as CellId],+ usedBy: ["cell4" as CellId],+ }),+ ["config" as VariableName]: createMockVariable("config", {+ value: '{"debug": true, "timeout": 30}',+ dataType: "dict",+ declaredBy: ["cell1" as CellId],+ usedBy: ["cell2" as CellId, "cell4" as CellId],+ }),+ };+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("multiple-variables");+ });++ it("should handle variables with null/undefined values", () => {+ const variables: Variables = {+ ["null_var" as VariableName]: createMockVariable("null_var", {+ value: null,+ dataType: "NoneType",+ }),+ ["undefined_var" as VariableName]: createMockVariable("undefined_var", {+ value: undefined,+ dataType: null,+ }),+ ["empty_string" as VariableName]: createMockVariable("empty_string", {+ value: '""',+ dataType: "str",+ }),+ };+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("null-undefined-variables");+ });++ it("should handle complex data types", () => {+ const variables: Variables = {+ ["df" as VariableName]: createMockVariable("df", {+ value: "<DataFrame shape: (100, 5)>",+ dataType: "pandas.DataFrame",+ declaredBy: ["cell1" as CellId],+ usedBy: ["cell2" as CellId, "cell3" as CellId],+ }),+ ["model" as VariableName]: createMockVariable("model", {+ value: "<sklearn.linear_model.LinearRegression>",+ dataType: "sklearn.linear_model._base.LinearRegression",+ declaredBy: ["cell4" as CellId],+ usedBy: ["cell5" as CellId],+ }),+ ["array" as VariableName]: createMockVariable("array", {+ value: "array([1, 2, 3, 4, 5])",+ dataType: "numpy.ndarray",+ declaredBy: ["cell2" as CellId],+ usedBy: ["cell3" as CellId],+ }),+ };+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("complex-data-types");+ });++ it("should handle variables with special characters in names", () => {+ const variables: Variables = {+ ["_private_var" as VariableName]: createMockVariable("_private_var", {+ value: "42",+ dataType: "int",+ }),+ ["var_with_numbers123" as VariableName]: createMockVariable(+ "var_with_numbers123",+ {+ value: '"test"',+ dataType: "str",+ },+ ),+ ["CONSTANT_VAR" as VariableName]: createMockVariable("CONSTANT_VAR", {+ value: "3.14159",+ dataType: "float",+ }),+ };+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const items = provider.getItems();+ expect(items).toMatchSnapshot("special-chars-variables");+ });+ });++ describe("formatContext", () => {+ it("should format context for basic variable", () => {+ const variable = createMockVariable("username", {+ value: '"alice"',+ dataType: "str",+ });+ const item: VariableContextItem = {+ type: "variable",+ uri: "username",+ name: "username",+ description: "str",+ data: { variable },+ };++ const variables: Variables = { ["username" as VariableName]: variable };+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const context = provider.formatContext(item);+ expect(context).toMatchSnapshot("basic-variable-context");+ });++ it("should format context for variable without dataType", () => {+ const variable = createMockVariable("mystery_var", {+ value: "some_value",+ dataType: null,+ });+ const item: VariableContextItem = {+ type: "variable",+ uri: "mystery_var",+ name: "mystery_var",+ description: "",+ data: { variable },+ };++ const variables: Variables = {+ ["mystery_var" as VariableName]: variable,+ };+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const context = provider.formatContext(item);+ expect(context).toMatchSnapshot("no-datatype-variable-context");+ });++ it("should format context for variable with complex value", () => {+ const variable = createMockVariable("complex_data", {+ value:+ '{"users": [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}], "total": 2}',+ dataType: "dict",+ });+ const item: VariableContextItem = {+ type: "variable",+ uri: "complex_data",+ name: "complex_data",+ description: "dict",+ data: { variable },+ };++ const variables: Variables = {+ ["complex_data" as VariableName]: variable,+ };+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const context = provider.formatContext(item);+ expect(context).toMatchSnapshot("complex-value-variable-context");+ });++ it("should format context for dataframe variable", () => {+ const variable = createMockVariable("sales_df", {+ value:+ "<DataFrame shape: (1000, 8)>\n date product quantity price\n0 2023-01-01 Widget A 10 29.99\n1 2023-01-02 Widget B 5 49.99\n...",+ dataType: "pandas.DataFrame",+ });+ const item: VariableContextItem = {+ type: "variable",+ uri: "sales_df",+ name: "sales_df",+ description: "pandas.DataFrame",+ data: { variable },+ };++ const variables: Variables = { ["sales_df" as VariableName]: variable };+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const context = provider.formatContext(item);+ expect(context).toMatchSnapshot("dataframe-variable-context");+ });+ });++ describe("getCompletions", () => {+ it("should return empty completions when no variables", () => {+ const variables: Variables = {};+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const completions = provider.getCompletions();+ expect(completions).toMatchSnapshot("empty-variable-completions");+ });++ it("should return completions for variables", () => {+ const variables: Variables = {+ ["data" as VariableName]: createMockVariable("data", {+ dataType: "pandas.DataFrame",+ }),+ ["config" as VariableName]: createMockVariable("config", {+ dataType: "dict",+ }),+ ["results" as VariableName]: createMockVariable("results", {+ dataType: "list",+ }),+ };+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ const completions = provider.getCompletions();+ expect(completions).toMatchSnapshot("variable-completions");+ });++ it("should pass table names to completion function", () => {+ const variables: Variables = {+ ["var1" as VariableName]: createMockVariable("var1"),+ };+ const tablesMap: DatasetTablesMap = new Map([+ ["users", {} as any],+ ["orders", {} as any],+ ]);+ const provider = new VariableContextProvider(variables, tablesMap);++ const completions = provider.getCompletions();+ expect(completions).toMatchSnapshot("variable-completions-with-tables");+ });+ });++ describe("provider properties", () => {+ it("should have correct provider properties", () => {+ const variables: Variables = {};+ const tablesMap: DatasetTablesMap = new Map();+ const provider = new VariableContextProvider(variables, tablesMap);++ expect(provider.title).toBe("Variables");+ expect(provider.mentionPrefix).toBe("@");+ expect(provider.contextType).toBe("variable");+ });+ });++ describe("integration with tables", () => {+ it("should work with both variables and tables", () => {+ const variables: Variables = {+ ["df" as VariableName]: createMockVariable("df", {+ dataType: "pandas.DataFrame",+ value: "<DataFrame shape: (50, 3)>",+ }),+ ["connection_string" as VariableName]: createMockVariable(+ "connection_string",+ {+ dataType: "str",+ value: '"postgresql://localhost:5432/mydb"',+ },+ ),+ };++ const tablesMap: DatasetTablesMap = new Map([+ ["users", {} as any],+ ["products", {} as any],+ ]);++ const provider = new VariableContextProvider(variables, tablesMap);++ const items = provider.getItems();+ const completions = provider.getCompletions();++ expect(items).toMatchSnapshot("variables-with-tables-items");+ expect(completions).toMatchSnapshot("variables-with-tables-completions");+ });+ });+});diff --git a/frontend/src/core/ai/context/providers/common.ts b/frontend/src/core/ai/context/providers/common.tsnew file mode 100644index 0000000000..151b0eae31--- /dev/null+++ b/frontend/src/core/ai/context/providers/common.ts@@ -0,0 +1,7 @@+/* Copyright 2024 Marimo. All rights reserved. */++export const Boosts = {+ LOCAL_TABLE: 5,+ REMOTE_TABLE: 4,+ VARIABLE: 3,+} as const;diff --git a/frontend/src/core/ai/context/providers/tables.ts b/frontend/src/core/ai/context/providers/tables.tsnew file mode 100644index 0000000000..2d8fb8f1cf--- /dev/null+++ b/frontend/src/core/ai/context/providers/tables.ts@@ -0,0 +1,212 @@+/* Copyright 2024 Marimo. All rights reserved. */++import type { Completion } from "@codemirror/autocomplete";+import type { DatasetTablesMap } from "@/core/datasets/data-source-connections";+import type { DataTable } from "@/core/kernel/messages";+import type { AIContextItem } from "../registry";+import { AIContextProvider } from "../registry";+import { Boosts } from "./common";++export interface TableContextItem extends AIContextItem {+ type: "data";+ data: DataTable;+}++export class TableContextProvider extends AIContextProvider<TableContextItem> {+ readonly title = "Tables";+ readonly mentionPrefix = "@";+ readonly contextType = "data";++ constructor(private tablesMap: DatasetTablesMap) {+ super();+ }++ getItems(): TableContextItem[] {+ return [...this.tablesMap.entries()].map(([tableName, table]) => ({+ uri: this.asURI(tableName),+ name: tableName,+ type: this.contextType,+ description: table.source === "memory" ? "in-memory" : table.source,+ data: table,+ }));+ }++ formatContext(item: TableContextItem): string {+ const { data, uri: id } = item;+ const { columns, source, num_rows, num_columns } = data;+ const shape = [+ num_rows == null ? undefined : `${num_rows} rows`,+ num_columns == null ? undefined : `${num_columns} columns`,+ ]+ .filter(Boolean)+ .join(", ");++ let context = `Table: ${id}\nSource: ${source || "unknown"}`;+ if (shape) {+ context += `\nShape: ${shape}`;+ }++ if (columns && columns.length > 0) {+ context += `\nColumns:\n${columns.map((col) => ` - ${col.name}: ${col.type}`).join("\n")}`;+ }++ return context;+ }++ getCompletions(): Completion[] {+ return [];+ }++ formatCompletion(item: TableContextItem): Completion {+ const tableName = item.data.name;+ const table = item.data;+ return {+ label: `@${tableName}`,+ displayLabel: tableName,+ detail: table.source === "memory" ? "in-memory" : table.source,+ boost:+ table.source_type === "local"+ ? Boosts.LOCAL_TABLE+ : Boosts.REMOTE_TABLE,+ type: table.variable_name ? "dataframe" : "table",+ apply: `@${tableName}`,+ section: table.variable_name ? "Dataframe" : "Table",+ info: () => this.createTableInfoElement(tableName, table),+ };+ }++ private createTableInfoElement(+ tableName: string,+ table: DataTable,+ ): HTMLElement {+ const infoContainer = document.createElement("div");+ infoContainer.classList.add(+ "mo-cm-tooltip",+ "docs-documentation",+ "min-w-[200px]",+ "flex",+ "flex-col",+ "gap-1",+ "p-2",+ );++ // Table header with name and source+ const headerDiv = document.createElement("div");+ headerDiv.classList.add("flex", "flex-col", "gap-1");++ const nameDiv = document.createElement("div");+ nameDiv.classList.add("font-bold", "text-base");+ nameDiv.textContent = tableName;+ headerDiv.append(nameDiv);++ if (table.source) {+ const sourceDiv = document.createElement("div");+ sourceDiv.classList.add("text-xs", "text-muted-foreground");+ sourceDiv.textContent = `Source: ${table.source}`;+ headerDiv.append(sourceDiv);+ }++ infoContainer.append(headerDiv);++ // Table shape info+ const shape = [+ table.num_rows == null ? undefined : `${table.num_rows} rows`,+ table.num_columns == null ? undefined : `${table.num_columns} columns`,+ ]+ .filter(Boolean)+ .join(", ");++ if (shape) {+ const shapeDiv = document.createElement("div");+ shapeDiv.classList.add("text-xs", "bg-muted", "px-2", "py-1", "rounded");+ shapeDiv.textContent = shape;+ infoContainer.append(shapeDiv);+ }++ // Columns table+ if (table.columns && table.columns.length > 0) {+ const columnsDiv = document.createElement("div");+ columnsDiv.classList.add("overflow-auto", "max-h-60");++ const columnsTable = document.createElement("table");+ columnsTable.classList.add("w-full", "text-xs", "border-collapse");++ // Table header+ const headerRow = columnsTable.insertRow();+ headerRow.classList.add("bg-muted");++ const nameHeader = headerRow.insertCell();+ nameHeader.classList.add("p-2", "font-medium", "text-left");+ nameHeader.textContent = "Column";++ const typeHeader = headerRow.insertCell();+ typeHeader.classList.add("p-2", "font-medium", "text-left");+ typeHeader.textContent = "Type";++ // Check if any column has metadata before adding the header+ const hasAnyMetadata = table.columns.some(+ (column) => this.getItemMetadata(table, column) !== undefined,+ );++ let metadataHeader: HTMLTableCellElement | undefined;+ if (hasAnyMetadata) {+ metadataHeader = headerRow.insertCell();+ metadataHeader.classList.add("p-2", "font-medium", "text-left");+ metadataHeader.textContent = "Metadata";+ }++ // Table rows+ table.columns.forEach((column, index) => {+ const row = columnsTable.insertRow();+ row.classList.add(index % 2 === 0 ? "bg-background" : "bg-muted/30");++ const nameCell = row.insertCell();+ nameCell.classList.add("p-2", "font-mono");+ nameCell.textContent = column.name;++ const typeCell = row.insertCell();+ typeCell.classList.add("p-2", "text-muted-foreground");+ typeCell.textContent = column.type;++ if (hasAnyMetadata) {+ const metadataCell = row.insertCell();+ metadataCell.classList.add("p-2");++ const itemMetadata = this.getItemMetadata(table, column);+ if (itemMetadata) {+ metadataCell.append(itemMetadata);+ }+ }+ });++ columnsDiv.append(columnsTable);+ infoContainer.append(columnsDiv);+ }++ return infoContainer;+ }++ private getItemMetadata(+ table: DataTable,+ column: DataTable["columns"][0],+ ): HTMLSpanElement | undefined {+ const isPrimaryKey = table.primary_keys?.includes(column.name);+ const isIndexed = table.indexes?.includes(column.name);+ if (isPrimaryKey || isIndexed) {+ const badge = document.createElement("span");+ badge.textContent = isPrimaryKey ? "PK" : "IDX";+ const color = isPrimaryKey+ ? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"+ : "bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200";+ badge.classList.add(+ "text-xs",+ "px-1.5",+ "py-0.5",+ "rounded-full",+ "font-medium",+ ...color.split(" "),+ );+ return badge;+ }+ }+}diff --git a/frontend/src/core/ai/context/providers/variable.ts b/frontend/src/core/ai/context/providers/variable.tsnew file mode 100644index 0000000000..2013ddf0c8--- /dev/null+++ b/frontend/src/core/ai/context/providers/variable.ts@@ -0,0 +1,76 @@+/* Copyright 2024 Marimo. All rights reserved. */++import type { Completion } from "@codemirror/autocomplete";+import { createVariableInfoElement } from "@/core/codemirror/completion/variable-completions";+import type { DatasetTablesMap } from "@/core/datasets/data-source-connections";+import type { Variable, Variables } from "@/core/variables/types";+import { type AIContextItem, AIContextProvider } from "../registry";+import { Boosts } from "./common";++export interface VariableContextItem extends AIContextItem {+ type: "variable";+ data: {+ variable: Variable;+ };+}++export class VariableContextProvider extends AIContextProvider<VariableContextItem> {+ readonly title = "Variables";+ readonly mentionPrefix = "@";+ readonly contextType = "variable";++ constructor(+ private variables: Variables,+ private tablesMap: DatasetTablesMap,+ ) {+ super();+ }++ getItems(): VariableContextItem[] {+ const ignore = new Set(this.tablesMap.keys());++ return Object.entries(this.variables).flatMap(([name, variable]) => {+ if (ignore.has(name)) {+ return [];+ }+ return [+ {+ uri: this.asURI(name),+ name: name,+ type: this.contextType,+ description: variable.dataType ?? "",+ dataType: variable.dataType,+ data: {+ variable,+ },+ },+ ];+ });+ }++ formatCompletion(item: VariableContextItem): Completion {+ const { data } = item;+ const { variable } = data;+ return {+ label: `@${variable.name}`,+ displayLabel: variable.name,+ detail: variable.dataType ?? "",+ boost: Boosts.VARIABLE,+ type: this.contextType,+ section: "Variable",+ info: () => {+ return createVariableInfoElement(variable);+ },+ };+ }++ formatContext(item: VariableContextItem): string {+ const { uri: id, data } = item;+ const { variable } = data;+ return `Variable: ${id}\nType: ${variable.dataType || "unknown"}\nPreview: ${JSON.stringify(variable.value)}`;+ }++ getCompletions(): Completion[] {+ return [];+ }+}diff --git a/frontend/src/core/ai/context/registry.ts b/frontend/src/core/ai/context/registry.tsnew file mode 100644index 0000000000..165ce7c0e9--- /dev/null+++ b/frontend/src/core/ai/context/registry.ts@@ -0,0 +1,190 @@+/* Copyright 2024 Marimo. All rights reserved. */++import type { Completion } from "@codemirror/autocomplete";+import type { Resource } from "@marimo-team/codemirror-mcp";+import type { TypedString } from "@/utils/typed";++/**+ * Unique identifier for a context item in the format "type:id"+ * e.g., "variable://my_var", "data://users", "file://config.py"+ */+export type ContextLocatorId = TypedString<"ContextLocatorId">;++/**+ * Base interface for context items that can be mentioned in AI prompts+ */+export interface AIContextItem extends Resource<Record<string, unknown>> {+ data: Record<string, unknown>;+}++/**+ * Abstract base class for AI context providers with shared implementation+ */+export abstract class AIContextProvider<+ T extends AIContextItem = AIContextItem,+> {+ /** Human-readable title for this context type */+ abstract readonly title: string;++ /** Prefix used for mentions (e.g., "@" for variables, "#" for files) */+ abstract readonly mentionPrefix: "@" | "#";++ /** Context type identifier used in ContextLocatorId */+ abstract readonly contextType: string;++ /** Get all available items of this context type */+ abstract getItems(): T[];++ /** Format the context for inclusion in AI prompt */+ abstract formatContext(item: T): string;++ /** Generate CodeMirror completions for autocomplete - can be overridden for custom behavior */+ abstract getCompletions(): Completion[];++ /** Format completion */+ abstract formatCompletion(item: T): Completion;++ asURI(id: string): ContextLocatorId {+ return `${this.contextType}://${id}` as ContextLocatorId;+ }++ /** Parse context IDs from input text using the provider's mention prefix */+ parseContextIds(input: string): ContextLocatorId[] {+ // Match @type://id, e.g., @data://users+ const regex = new RegExp(+ `${this.mentionPrefix}([\\w-]+):\\/\\/([\\w./-]+)`,+ "g",+ );+ const matches = [...input.matchAll(regex)];+ const justURI = (match: string) => match.slice(1);++ const results = matches+ .filter(([, type]) => type === this.contextType)+ .map(([matchString]) => justURI(matchString) as ContextLocatorId);++ return [...new Set(results)];+ }++ /** Create a basic completion object - can be used by subclasses */+ protected createBasicCompletion(+ item: T,+ options?: {+ boost?: number;+ type?: string;+ section?: string;+ detail?: string;+ },+ ): Completion {+ return {+ label: `${this.mentionPrefix}${item.uri.split("://")[1]}`,+ displayLabel: item.name,+ detail: options?.detail || item.description,+ boost: options?.boost || 1,+ type: options?.type || this.contextType,+ apply: `${this.mentionPrefix}${item.uri}`,+ section: options?.section || this.title,+ };+ }+}++/**+ * Registry for managing different AI context providers+ */+export class AIContextRegistry<T extends AIContextItem> {+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ private providers = new Set<AIContextProvider<any>>();++ /**+ * Register a new context provider+ */+ register<U extends AIContextItem>(+ provider: AIContextProvider<U>,+ // eslint-disable-next-line @typescript-eslint/prefer-return-this-type+ ): AIContextRegistry<U | T> {+ this.providers.add(provider);+ return this;+ }++ /**+ * Get all registered providers+ */+ getProviders(): Set<AIContextProvider<T>> {+ return this.providers;+ }++ /**+ * Get a specific provider by type+ */+ getProvider(type: string): AIContextProvider | undefined {+ return [...this.providers].find(+ (provider) => provider.contextType === type,+ );+ }++ /**+ * Get all completions from all providers+ */+ getAllCompletions(): Completion[] {+ return [...this.providers].flatMap((provider) => provider.getCompletions());+ }++ getAllItems(): T[] {+ return [...this.providers].flatMap((provider) => provider.getItems());+ }++ /**+ * Parse context IDs from input across all providers+ */+ parseAllContextIds(input: string): ContextLocatorId[] {+ return [...this.providers].flatMap((provider) =>+ provider.parseContextIds(input),+ );+ }++ /**+ * Get context information for mentioned items+ */+ getContextInfo(contextIds: ContextLocatorId[]): T[] {+ const contextInfo: T[] = [];+ const allItems = new Map<ContextLocatorId, T>(+ this.getAllItems().map((item) => [item.uri as ContextLocatorId, item]),+ );++ for (const contextId of contextIds) {+ const item = allItems.get(contextId);+ if (item) {+ contextInfo.push(item);+ }+ }++ return contextInfo;+ }++ /**+ * Format context for AI prompt inclusion+ */+ formatContextForAI(contextIds: ContextLocatorId[]): string {+ const allItems = new Map<ContextLocatorId, T>(+ this.getAllItems().map((item) => [item.uri as ContextLocatorId, item]),+ );++ const contextInfo: T[] = [];+ for (const contextId of contextIds) {+ const item = allItems.get(contextId);+ if (item) {+ contextInfo.push(item);+ }+ }++ if (contextInfo.length === 0) {+ return "";+ }++ return contextInfo+ .map((item) => {+ const provider = this.getProvider(item.type);+ return provider?.formatContext(item) || "";+ })+ .join("\n\n");+ }+}diff --git a/frontend/src/core/codemirror/ai/resources.ts b/frontend/src/core/codemirror/ai/resources.tsnew file mode 100644index 0000000000..06efe57c2e--- /dev/null+++ b/frontend/src/core/codemirror/ai/resources.ts@@ -0,0 +1,90 @@+/* Copyright 2024 Marimo. All rights reserved. */++import type { Language } from "@codemirror/language";+import type { Extension } from "@codemirror/state";+import type { TooltipView } from "@codemirror/view";+import {+ hoverResource,+ type Resource,+ resourceCompletion,+ resourceDecorations,+ resourceInputFilter,+ resourcesField,+ resourceTheme,+} from "@marimo-team/codemirror-mcp";+import { getAIContextRegistry } from "@/core/ai/context/context";+import type { AIContextItem } from "@/core/ai/context/registry";+import type { JotaiStore } from "@/core/state/jotai";+import { Logger } from "@/utils/Logger";++export function resourceExtension(+ language: Language,+ store: JotaiStore,+): Extension[] {+ return [+ language.data.of({+ autocomplete: resourceCompletion(+ async (): Promise<Resource[]> => {+ const registry = getAIContextRegistry(store);+ const resources = registry.getAllItems();+ return resources;+ },+ (resource) => {+ const registry = getAIContextRegistry(store);+ const provider = registry.getProvider(resource.type);+ return provider?.formatCompletion(resource as AIContextItem) || {};+ },+ ),+ }),+ resourceDecorations,+ resourceInputFilter,+ resourcesField.init(() => {+ const registry = getAIContextRegistry(store);+ const resources = registry.getAllItems();+ return new Map(resources.map((resource) => [resource.uri, resource]));+ }),+ resourceTheme,+ hoverResource({+ createTooltip: (resource): TooltipView => {+ const registry = getAIContextRegistry(store);+ const provider = registry.getProvider(resource.type);+ if (!provider) {+ Logger.warn("No provider found for resource", resource);+ return asDom(resource.description || resource.name);+ }+ const completion = provider.formatCompletion(resource as AIContextItem);+ const fallback = resource.description || resource.name;+ if (!completion?.info) {+ return asDom(fallback);+ }+ if (typeof completion.info === "string") {+ return asDom(completion.info);+ }+ const info = completion.info(completion);+ if (!info) {+ return asDom(fallback);+ }+ if ("dom" in info) {+ return {+ dom: info.dom as HTMLElement,+ };+ }+ if ("then" in info) {+ Logger.warn("info is a promise. This is not supported", info);+ return asDom(fallback);+ }+ return {+ dom: info as HTMLElement,+ };+ },+ }),+ ];+}++function asDom(value: string): TooltipView {+ const tooltip = document.createElement("div");+ tooltip.innerHTML = value;+ return {+ dom: tooltip,+ };+}diff --git a/frontend/src/core/codemirror/completion/variable-completions.ts b/frontend/src/core/codemirror/completion/variable-completions.tsindex edff10ed86..ebb52035f3 100644--- a/frontend/src/core/codemirror/completion/variable-completions.ts+++ b/frontend/src/core/codemirror/completion/variable-completions.ts@@ -31,17 +31,17 @@ export function getVariableCompletions(});}-function createVariableInfoElement(variable: Variable): HTMLElement {+export function createVariableInfoElement(variable: Variable): HTMLElement {const infoContainer = document.createElement("div");infoContainer.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]",+ "flex",+ "flex-col",+ "gap-1",+ "p-2",);- infoContainer.style.display = "flex";- infoContainer.style.flexDirection = "column";- infoContainer.style.gap = ".8rem";- infoContainer.style.padding = "0.5rem";// Variable headerconst header = document.createElement("div");diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex d80a6f625b..08d5bd3065 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -133,6 +133,9 @@ importers:'@marimo-team/codemirror-languageserver':specifier: ^1.15.24version: 1.15.24(@codemirror/[email protected])(@codemirror/[email protected])+ '@marimo-team/codemirror-mcp':+ specifier: ^0.1.5+ version: 0.1.5(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@modelcontextprotocol/[email protected])'@marimo-team/marimo-api':specifier: workspace:*version: link:../packages/openapi@@ -1777,6 +1780,14 @@ packages:'@codemirror/state': ^6'@codemirror/view': ^6+ '@marimo-team/[email protected]':+ resolution: {integrity: sha512-Gt4DGeQO0YIE7mvgNmYfRS1UggnfuZTROHmze80huglUTnZVqIe+2MllZAm/e4jEkI3J9iFYtxzpNLcVlkM8Nw==}+ peerDependencies:+ '@codemirror/autocomplete': ^6+ '@codemirror/state': ^6+ '@codemirror/view': ^6+ '@modelcontextprotocol/sdk': ^1+'@marimo-team/[email protected]':resolution: {integrity: sha512-e2rU3kZGuBfl6EnzU0tekKcoLBDiz6JNRD/Nbgaf8a56SqC8GdUokdZoAlTbZDOxhhRKTT8ykjXzQZBnvWY/5g==}peerDependencies:@@ -1791,6 +1802,10 @@ packages:'@mermaid-js/[email protected]':resolution: {integrity: sha512-+PO02uGF6L6Cs0Bw8RpGhikVvMWEysfAyl27qTlroUB8jSWr1lL0Sf6zi78ZxlSnmgSY2AMMKVgghnN9jTtwkQ==}+ '@modelcontextprotocol/[email protected]':+ resolution: {integrity: sha512-EFLRNXR/ixpXQWu6/3Cu30ndDFIFNaqUXcTqsGebujeMan9FzhAaFFswLRiFj61rgygDRr8WO1N+UijjgRxX9g==}+ engines: {node: '>=18'}+'@mswjs/[email protected]':resolution: {integrity: sha512-RuzCup9Ct91Y7V79xwCb146RaBRHZ7NBbrIUySumd1rpKqHL5OonaqrGIbug5hNwP/fRyxFMA6ISgw4FTtYFYg==}engines: {node: '>=18'}@@ -4203,6 +4218,10 @@ packages:resolution: {integrity: sha512-d8XPSGjfyzlXC3Xx891DJRyZfqk5JU0BJrDQcsWomFIV1/BIzPW5HDH5iDdWpqWaav0YVIEzT1RHTwWr0FFshA==}+ resolution: {integrity: sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==}+ engines: {node: '>= 0.6'}+resolution: {integrity: sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ==}engines: {node: '>=10.13.0'}@@ -4468,6 +4487,10 @@ packages:resolution: {integrity: sha512-oD8Ydw+5lNoqq+en24iuPt1QixdPpe/nUF8azTHnviCZYu9zUC+TwdzIp5orpblJosNlgNbVmmAb//c6d6ImUQ==}+ resolution: {integrity: sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==}+ engines: {node: '>=18'}+resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==}@@ -4513,6 +4536,10 @@ packages:peerDependencies:esbuild: '>=0.18'+ resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}engines: {node: '>=8'}@@ -4774,12 +4801,24 @@ packages:resolution: {integrity: sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==}engines: {node: ^14.18.0 || >=16.10.0}+ resolution: {integrity: sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==}+ engines: {node: '>= 0.6'}++ resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==}+ engines: {node: '>= 0.6'}+resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==}resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}+ resolution: {integrity: sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==}+ engines: {node: '>=6.6.0'}+resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==}engines: {node: '>= 0.6'}@@ -4796,6 +4835,10 @@ packages:resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}+ resolution: {integrity: sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==}+ engines: {node: '>= 0.10'}+resolution: {integrity: sha512-s9whTXInMSgAp/NVXVNuVxVKzGH2qck3aQlVHxDCdAEPgtMKwc4Wq6/QKhgdEdgbLSi9rBTAcPoRa6JpiG4ksg==}@@ -5252,6 +5295,10 @@ packages:resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}engines: {node: '>=0.4.0'}+ resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==}@@ -5354,6 +5401,9 @@ packages:resolution: {integrity: sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==}+ resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}+resolution: {integrity: sha512-dYOZfUk57hSMPePoIQ1fZWl1Fkj+OshhEVuPacNKWzC1efe56OsHY3l/jCfiAgIICOU3VgOIdoq7ahg7r7n6MQ==}@@ -5372,6 +5422,10 @@ packages:resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}+ resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==}@@ -5457,6 +5511,9 @@ packages:resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==}engines: {node: '>=6'}+ resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}+resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==}engines: {node: '>=0.8.0'}@@ -5603,6 +5660,10 @@ packages:resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}engines: {node: '>=0.10.0'}+ resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}+ engines: {node: '>= 0.6'}+resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==}@@ -5613,10 +5674,28 @@ packages:resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}engines: {node: '>=0.8.x'}+ resolution: {integrity: sha512-nVpZkTMM9rF6AQ9gPJpFsNAMt48wIzB5TQgiTLdHiuO8XEDhUgZEhqKlZWXbIzo9VmJ/HvysHqEaVeD5v9TPvA==}+ engines: {node: '>=20.0.0'}++ resolution: {integrity: sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==}+ engines: {node: '>=18.0.0'}+resolution: {integrity: sha512-JhFGDVJ7tmDJItKhYgJCGLOWjuK9vPxiXoUFLwLDc99NlmklilbiQJwoctZtt13+xMw91MCk/REan6MWHqDjyA==}engines: {node: '>=12.0.0'}+ resolution: {integrity: sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw==}+ engines: {node: '>= 16'}+ peerDependencies:+ express: '>= 4.11'++ resolution: {integrity: sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==}+ engines: {node: '>= 18'}+resolution: {integrity: sha512-VO5fQUzZtI6C+vx4w/4BWJpg3s/5l+6pRQEHzFRM8WFi4XffSP1Z+4qi7GbjWbvRQEbdIco5mIMq+zX4rPuLrw==}@@ -5695,6 +5774,10 @@ packages:resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==}engines: {node: '>=8'}+ resolution: {integrity: sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==}@@ -5759,6 +5842,14 @@ packages:resolution: {integrity: sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA==}engines: {node: '>= 6'}+ resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}+ engines: {node: '>= 0.6'}++ resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==}@@ -6081,6 +6172,10 @@ packages:resolution: {integrity: sha512-q/qOkgjcnZ90v0wSaMwamhfAhIf6lhOsH0ehHFnQHAt1lA9MedSnmqEEnh8bq0njTBAK3IsmS2gEuXryfWCDkw==}+ resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==}engines: {node: '>= 14'}@@ -6185,6 +6280,10 @@ packages:resolution: {integrity: sha512-xgs2NH9AE66ucSq4cNG1nhSFghr5l6tdL15Pk+jl46bmmBapgoaY/AacXyaDznAqmGL99TiLSQgO/XazFSKYeQ==}engines: {node: '>=0.10.0'}+ resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==}+ engines: {node: '>= 0.10'}+resolution: {integrity: sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==}@@ -6329,6 +6428,9 @@ packages:resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==}+ resolution: {integrity: sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==}+resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==}engines: {node: '>= 0.4'}@@ -6836,6 +6938,10 @@ packages:resolution: {integrity: sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==}+ resolution: {integrity: sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==}@@ -6847,6 +6953,10 @@ packages:resolution: {integrity: sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==}engines: {node: '>=18'}+ resolution: {integrity: sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==}+ engines: {node: '>=18'}+resolution: {integrity: sha512-PGSmS0kfnTnMJCzJ16BLLCEe6oeYCamKFFdQKshi4BmM6FUwipjVOcBFGxqtQtirtAG4iZvHlqST9CpZKqlRjA==}@@ -6931,10 +7041,18 @@ packages:resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}engines: {node: '>= 0.6'}+ resolution: {integrity: sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==}+ engines: {node: '>= 0.6'}+resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}engines: {node: '>= 0.6'}+ resolution: {integrity: sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==}+ engines: {node: '>= 0.6'}+resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==}engines: {node: '>=4'}@@ -7037,6 +7155,10 @@ packages:engines: {node: '>= 4.4.x'}hasBin: true+ resolution: {integrity: sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==}+ engines: {node: '>= 0.6'}+resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==}@@ -7125,6 +7247,10 @@ packages:resolution: {integrity: sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-6vaNInhu+CHxtONf3zw3vq4SP2DOQhjBvIa3rNcG0+P7eKWlYH6Peu7rHizSloRU2EwMz6GraLieis9Ac9+p1w==}@@ -7245,6 +7371,10 @@ packages:resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==}+ resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-jXP7PFj2h5/v4UjDS8P7MZy6NJUQ7sspiFyxL4uc/+oKOL+KdtXzHnTV8INPGxBrLTXgalyG3kd12Qm7WrYc3A==}@@ -7352,6 +7482,10 @@ packages:resolution: {integrity: sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==}engines: {node: '>= 6'}+ resolution: {integrity: sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ==}+ engines: {node: '>=16.20.0'}+resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==}@@ -7666,6 +7800,10 @@ packages:resolution: {integrity: sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw==}+ resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}+ engines: {node: '>= 0.10'}+resolution: {integrity: sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==}@@ -7717,6 +7855,14 @@ packages:resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==}+ resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}+ engines: {node: '>= 0.6'}++ resolution: {integrity: sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-yFnq1nIQhT2uJY4TZVz2tgAiBb9lxSyvF4vC3S8POCK8xLzjGIxVv3/4dmYquQJ7AHxaZZArRGHiHKsEewKdTQ==}peerDependencies:@@ -8102,6 +8248,10 @@ packages:resolution: {integrity: sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ==}+ resolution: {integrity: sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==}+ engines: {node: '>= 18'}+resolution: {integrity: sha512-/MgRTK/5iOh7EmYz5uZAmHX0DNg9PdbyjVgDtLX4WwoWHmpI8uh9We877U6KizxPDlmeDslq/2MnS7kZXWR8Cw==}@@ -8168,9 +8318,17 @@ packages:engines: {node: '>=10'}hasBin: true+ resolution: {integrity: sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==}+ engines: {node: '>= 18'}+resolution: {integrity: sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==}+ resolution: {integrity: sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==}+ engines: {node: '>= 18'}+resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==}@@ -8186,6 +8344,9 @@ packages:resolution: {integrity: sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}+resolution: {integrity: sha512-b6i4ZpVuUxB9h5gfCxPiusKYkqTMOjEbBs4wMaFbkfia4yFv92UKZ6Df8WXcKbn08JNL/abvg3FnMAOfakDvUw==}@@ -8301,6 +8462,10 @@ packages:resolution: {integrity: sha512-D8vv82E/Kpmz3TXHKG8PPsCPg+RAX6cbCOyvjM6x04qZtQ47EtJFVwRsdov3n5d6/6ynrOY9XB4JkaZwB2xoRQ==}+ resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==}engines: {node: '>= 0.8'}@@ -8674,6 +8839,10 @@ packages:resolution: {integrity: sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==}+ resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}+ engines: {node: '>=0.6'}+resolution: {integrity: sha512-605uxS6bcYxGXw9qi62XyrV6Q3xwbndjachmNxu8HWTtVPxZfEJN9fd/SZS1Q54Sn2y0TMyMxFj/cJINqGHrKw==}hasBin: true@@ -8849,6 +9018,10 @@ packages:resolution: {integrity: sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==}engines: {node: '>=16'}+ resolution: {integrity: sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==}+ engines: {node: '>= 0.6'}+resolution: {integrity: sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==}@@ -8934,6 +9107,10 @@ packages:resolution: {integrity: sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==}engines: {node: '>= 4.0.0'}+ resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-4/u/j4FrCKdi17jaxuJA0jClGxB1AvU2hw/IuayPc4ay1XGaJs/rbb4v5WKwAjNifjmXK9PIFyuPiaK8azyR9w==}engines: {node: '>=14.0.0'}@@ -9009,6 +9186,10 @@ packages:resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==}+ resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-OkJ9CACVcN9R5Pi9uF6MZBF06pO6qFpDYHWSKBJsdHP5o724KrsgR6UvbnXFH82FdsiTOff/HqjuaG8C7FL+9Q==}@@ -10940,6 +11121,13 @@ snapshots:- encoding- utf-8-validate+ '@marimo-team/[email protected](@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@modelcontextprotocol/[email protected])':+ dependencies:+ '@codemirror/autocomplete': 6.18.6+ '@codemirror/state': 6.5.2+ '@codemirror/view': 6.38.1+ '@modelcontextprotocol/sdk': 1.17.2+'@marimo-team/[email protected]([email protected])':dependencies:mitt: 3.0.1@@ -10955,6 +11143,23 @@ snapshots:dependencies:langium: 3.3.1+ '@modelcontextprotocol/[email protected]':+ dependencies:+ ajv: 6.12.6+ content-type: 1.0.5+ cors: 2.8.5+ cross-spawn: 7.0.6+ eventsource: 3.0.7+ eventsource-parser: 3.0.3+ express: 5.1.0+ express-rate-limit: 7.5.1([email protected])+ pkce-challenge: 5.0.0+ raw-body: 3.0.0+ zod: 3.25.76+ zod-to-json-schema: 3.24.6([email protected])+ transitivePeerDependencies:+ - supports-color+'@mswjs/[email protected]':dependencies:'@open-draft/deferred-promise': 2.2.0@@ -14086,6 +14291,11 @@ snapshots:+ dependencies:+ mime-types: 3.0.1+ negotiator: 1.0.0+dependencies:acorn: 8.15.0@@ -14331,6 +14541,20 @@ snapshots:+ dependencies:+ bytes: 3.1.2+ content-type: 1.0.5+ debug: 4.4.1([email protected])+ http-errors: 2.0.0+ iconv-lite: 0.6.3+ on-finished: 2.4.1+ qs: 6.14.0+ raw-body: 3.0.0+ type-is: 2.0.1+ transitivePeerDependencies:+ - supports-color+@@ -14382,6 +14606,8 @@ snapshots:esbuild: 0.25.6load-tsconfig: 0.2.5+ [email protected]: {}+@@ -14662,10 +14888,18 @@ snapshots:+ dependencies:+ safe-buffer: 5.2.1++ [email protected]: {}++ [email protected]: {}+@@ -14680,6 +14914,11 @@ snapshots:+ dependencies:+ object-assign: 4.1.1+ vary: 1.1.2+dependencies:layout-base: 1.0.2@@ -15189,6 +15428,8 @@ snapshots:+ [email protected]: {}+@@ -15295,6 +15536,8 @@ snapshots:jsbn: 0.1.1safer-buffer: 2.1.2+ [email protected]: {}+@@ -15309,6 +15552,8 @@ snapshots:+ [email protected]: {}+dependencies:once: 1.4.0@@ -15494,6 +15739,8 @@ snapshots:+ [email protected]: {}+@@ -15706,6 +15953,8 @@ snapshots:+ [email protected]: {}+dependencies:d: 1.0.2@@ -15715,8 +15964,50 @@ snapshots:+ [email protected]: {}++ dependencies:+ eventsource-parser: 3.0.3++ dependencies:+ express: 5.1.0++ dependencies:+ accepts: 2.0.0+ body-parser: 2.2.0+ content-disposition: 1.0.0+ content-type: 1.0.5+ cookie: 0.7.2+ cookie-signature: 1.2.2+ debug: 4.4.1([email protected])+ encodeurl: 2.0.0+ escape-html: 1.0.3+ etag: 1.8.1+ finalhandler: 2.1.0+ fresh: 2.0.0+ http-errors: 2.0.0+ merge-descriptors: 2.0.0+ mime-types: 3.0.1+ on-finished: 2.4.1+ once: 1.4.0+ parseurl: 1.3.3+ proxy-addr: 2.0.7+ qs: 6.14.0+ range-parser: 1.2.1+ router: 2.2.0+ send: 1.2.0+ serve-static: 2.2.0+ statuses: 2.0.2+ type-is: 2.0.1+ vary: 1.1.2+ transitivePeerDependencies:+ - supports-color+@@ -15786,6 +16077,17 @@ snapshots:dependencies:to-regex-range: 5.0.1+ dependencies:+ debug: 4.4.1([email protected])+ encodeurl: 2.0.0+ escape-html: 1.0.3+ on-finished: 2.4.1+ parseurl: 1.3.3+ statuses: 2.0.2+ transitivePeerDependencies:+ - supports-color+@@ -15870,6 +16172,10 @@ snapshots:hasown: 2.0.2mime-types: 2.1.35+ [email protected]: {}++ [email protected]: {}+dependencies:inherits: 2.0.4@@ -16272,6 +16578,14 @@ snapshots:concat-stream: 1.6.2http-response-object: 1.1.0+ dependencies:+ depd: 2.0.0+ inherits: 2.0.4+ setprototypeof: 1.2.0+ statuses: 2.0.1+ toidentifier: 1.0.1+dependencies:agent-base: 7.1.4@@ -16365,6 +16679,8 @@ snapshots:+ [email protected]: {}+@@ -16484,6 +16800,8 @@ snapshots:+ [email protected]: {}+dependencies:call-bound: 1.0.4@@ -17059,12 +17377,16 @@ snapshots:+ [email protected]: {}++ [email protected]: {}+dependencies:source-map: 0.5.7@@ -17238,10 +17560,16 @@ snapshots:+ [email protected]: {}+dependencies:mime-db: 1.52.0+ dependencies:+ mime-db: 1.54.0+@@ -17355,6 +17683,8 @@ snapshots:transitivePeerDependencies:- supports-color+ [email protected]: {}+@@ -17445,6 +17775,10 @@ snapshots:define-properties: 1.2.1es-object-atoms: 1.1.1+ dependencies:+ ee-first: 1.1.1+dependencies:wrappy: 1.0.2@@ -17590,6 +17924,8 @@ snapshots:dependencies:entities: 6.0.1+ [email protected]: {}+dependencies:event-target-polyfill: 0.0.4@@ -17664,6 +18000,8 @@ snapshots:+ [email protected]: {}+dependencies:confbox: 0.1.8@@ -18014,6 +18352,11 @@ snapshots:+ dependencies:+ forwarded: 0.2.0+ ipaddr.js: 1.9.1+dependencies:punycode: 2.3.1@@ -18064,6 +18407,15 @@ snapshots:dependencies:safe-buffer: 5.2.1+ [email protected]: {}++ dependencies:+ bytes: 3.1.2+ http-errors: 2.0.0+ iconv-lite: 0.6.3+ unpipe: 1.0.0+[email protected](@types/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected]):dependencies:react: 19.1.0@@ -18696,6 +19048,16 @@ snapshots:points-on-curve: 0.2.0points-on-path: 0.2.1+ dependencies:+ debug: 4.4.1([email protected])+ depd: 2.0.0+ is-promise: 4.0.0+ parseurl: 1.3.3+ path-to-regexp: 8.2.0+ transitivePeerDependencies:+ - supports-color+dependencies:browser-namespace: 1.4.0@@ -18758,10 +19120,35 @@ snapshots:+ dependencies:+ debug: 4.4.1([email protected])+ encodeurl: 2.0.0+ escape-html: 1.0.3+ etag: 1.8.1+ fresh: 2.0.0+ http-errors: 2.0.0+ mime-types: 3.0.1+ ms: 2.1.3+ on-finished: 2.4.1+ range-parser: 1.2.1+ statuses: 2.0.2+ transitivePeerDependencies:+ - supports-color+dependencies:randombytes: 2.1.0+ dependencies:+ encodeurl: 2.0.0+ escape-html: 1.0.3+ parseurl: 1.3.3+ send: 1.2.0+ transitivePeerDependencies:+ - supports-color+@@ -18786,6 +19173,8 @@ snapshots:es-errors: 1.3.0es-object-atoms: 1.1.1+ [email protected]: {}+@@ -18924,6 +19313,8 @@ snapshots:static-eval: 2.1.1through2: 2.0.5+ [email protected]: {}+@@ -19378,6 +19769,8 @@ snapshots:+ [email protected]: {}+dependencies:commander: 2.20.3@@ -19533,6 +19926,12 @@ snapshots:+ dependencies:+ content-type: 1.0.5+ media-typer: 1.1.0+ mime-types: 3.0.1+@@ -19642,6 +20041,8 @@ snapshots:+ [email protected]: {}+dependencies:acorn: 8.15.0@@ -19706,6 +20107,8 @@ snapshots:spdx-correct: 3.2.0spdx-expression-parse: 3.0.1+ [email protected]: {}+