@ai-matrx/code-runtime 0.1.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/dist/execute.cjs +20 -4
- package/dist/execute.cjs.map +1 -1
- package/dist/execute.js +20 -4
- package/dist/execute.js.map +1 -1
- package/dist/gate-lists.json +1 -0
- package/dist/gate.cjs +1 -0
- package/dist/gate.cjs.map +1 -1
- package/dist/gate.js +1 -0
- package/dist/gate.js.map +1 -1
- package/dist/index.cjs +20 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/scope.cjs +13 -3
- package/dist/scope.cjs.map +1 -1
- package/dist/scope.js +13 -3
- package/dist/scope.js.map +1 -1
- package/package.json +5 -4
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/gate-lists.json","../src/gate.ts","../src/scope/entries.ts","../src/scope/build.ts","../src/scope/modules.ts","../src/scope/stand-in.ts","../src/execute-core.ts","../src/transform-core.ts","../src/compile.ts","../src/cache.ts","../src/kind.ts"],"sourcesContent":["{\n \"_comment\": [\n \"CANONICAL, MACHINE-READABLE source-gate lists for stored code compiled by @ai-matrx/code-runtime.\",\n \"ONE list per rule, sorted, byte-comparable across runtimes. Three guards keep the copies honest:\",\n \" - src/gate.test.ts asserts allowedImports equals listScopeEntryPaths() sorted\",\n \" (the documented scope registry is the truth);\",\n \" - aidream packages/matrx-ai/tests/test_component_source_gate_parity.py asserts the Python\",\n \" twins in kind_shared.py equal these arrays;\",\n \" - the database trigger's parity test asserts the trigger names every entry of every\",\n \" security list below.\"\n ],\n \"allowedImports\": [\n \"@/applets\",\n \"@/components/Markdown\",\n \"@/components/MarkdownStream\",\n \"@/components/agent-copy/CopyButtons\",\n \"@/components/agent-copy/CopyForAiButton\",\n \"@/components/kind-kit/KindHeaderBar\",\n \"@/components/kind-kit/KindPanel\",\n \"@/components/kind-kit/KindPanelGrid\",\n \"@/components/kind-kit/SortableList\",\n \"@/components/kind-kit/StreamingSkeleton\",\n \"@/components/kind-kit/TagList\",\n \"@/components/mardown\",\n \"@/components/markdown\",\n \"@/components/official/icons/IconResolver\",\n \"@/components/ui/accordion\",\n \"@/components/ui/alert\",\n \"@/components/ui/avatar\",\n \"@/components/ui/badge\",\n \"@/components/ui/button\",\n \"@/components/ui/card\",\n \"@/components/ui/checkbox\",\n \"@/components/ui/collapsible\",\n \"@/components/ui/dialog\",\n \"@/components/ui/dropdown-menu\",\n \"@/components/ui/input\",\n \"@/components/ui/label\",\n \"@/components/ui/popover\",\n \"@/components/ui/progress\",\n \"@/components/ui/radio-group\",\n \"@/components/ui/scroll-area\",\n \"@/components/ui/select\",\n \"@/components/ui/separator\",\n \"@/components/ui/sheet\",\n \"@/components/ui/skeleton\",\n \"@/components/ui/slider\",\n \"@/components/ui/switch\",\n \"@/components/ui/table\",\n \"@/components/ui/tabs\",\n \"@/components/ui/textarea\",\n \"@/components/ui/tooltip\",\n \"@/lib/utils\",\n \"@ai-matrx/applets/react\",\n \"@ai-matrx/design-system\",\n \"@ai-matrx/design-system/controls\",\n \"@ai-matrx/icons\",\n \"@react-three/fiber\",\n \"date-fns\",\n \"lodash\",\n \"lucide-react\",\n \"motion/react\",\n \"react\",\n \"react-katex\",\n \"react-pdf\",\n \"recharts\",\n \"three\",\n \"xlsx\"\n ],\n \"bannedGlobals\": [\n \"EventSource\",\n \"WebSocket\",\n \"XMLHttpRequest\",\n \"fetch\",\n \"importScripts\",\n \"localStorage\",\n \"sessionStorage\"\n ],\n \"bannedCallables\": [\n \"Function\",\n \"eval\"\n ],\n \"bannedMemberAccess\": [\n \"EventSource\",\n \"Function\",\n \"WebSocket\",\n \"XMLHttpRequest\",\n \"cookie\",\n \"eval\",\n \"fetch\",\n \"importScripts\",\n \"sendBeacon\"\n ],\n \"bannedMemberCalls\": [\n \"constructor\"\n ],\n \"bannedComputedAccess\": [\n \"globalThis\",\n \"self\",\n \"window\"\n ],\n \"bannedSyntax\": [\n \"dynamicImport\"\n ]\n}\n","/**\n * `@ai-matrx/code-runtime/gate` — THE ONE source gate for stored code.\n *\n * Every writer of stored component code (kind components, tool and emit\n * renderers, Applet files) runs `gate(files)` before the write; a database\n * trigger is the backstop and aidream's `kind_shared.py` is the Python twin.\n * The lists are DATA in `gate-lists.json` (exported as\n * `@ai-matrx/code-runtime/gate-lists.json`) so all three runtimes compare the\n * same bytes; parity tests on each side read this file.\n *\n * Moved here verbatim in behavior from matrx-frontend\n * `features/agent-apps/utils/component-source-gate.ts` (Q82 / B-17, DD-124),\n * widened to multi-file sources: a relative import must name a file in the\n * set, and every finding carries its file and line.\n *\n * WHAT THIS IS NOT: a sandbox. A string check cannot stop every escape, and\n * the runtime stubs shadow bare identifiers only. Real isolation is the\n * sandbox frame (opaque origin, `connect-src 'none'`).\n *\n * Pure: no React, no Babel — safe for servers, workers and write paths.\n */\nimport lists from \"./gate-lists.json\";\nimport type { Finding } from \"./types\";\n\nexport type { Finding } from \"./types\";\n\n/** Every module stored code may import (the documented scope registry). */\nexport const GATE_ALLOWED_IMPORTS: readonly string[] = lists.allowedImports;\n/** Globals stored code may never name as a bare identifier. */\nexport const GATE_BANNED_GLOBALS: readonly string[] = lists.bannedGlobals;\n/** Evaluators banned where called or constructed (`eval(`, `new Function(`). */\nexport const GATE_BANNED_CALLABLES: readonly string[] = lists.bannedCallables;\n/** Names banned as a property read (`window.fetch`, `document.cookie`). */\nexport const GATE_BANNED_MEMBER_ACCESS: readonly string[] = lists.bannedMemberAccess;\n/** Names banned as a method call on any object (`.constructor(`). */\nexport const GATE_BANNED_MEMBER_CALLS: readonly string[] = lists.bannedMemberCalls;\n/** Roots on which bracket access is refused (`window[\"fet\"+\"ch\"]`). */\nexport const GATE_BANNED_COMPUTED_ACCESS: readonly string[] = lists.bannedComputedAccess;\n/** Named syntax rules every runtime implements (`dynamicImport`). */\nexport const GATE_BANNED_SYNTAX: readonly string[] = lists.bannedSyntax;\n\n/** The raw lists, for parity tests and the database trigger's generator. */\nexport const GATE_LISTS = lists;\n\nconst IMPORT_RE = /^\\s*import\\s+(?:[^'\"]*?\\s+from\\s+)?['\"]([^'\"]+)['\"]/gm;\nconst EXPORT_FROM_RE = /^\\s*export\\s+(?:\\*|\\{[^}]*\\})\\s+from\\s+['\"]([^'\"]+)['\"]/gm;\nconst DYNAMIC_IMPORT_RE = /(?<![.\\w$])import\\s*\\(/g;\n\nfunction escapeForRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction lineAt(source: string, index: number): number {\n let line = 1;\n for (let i = 0; i < index && i < source.length; i++) {\n if (source.charCodeAt(i) === 10) line++;\n }\n return line;\n}\n\n/** Normalize a relative specifier against the importing file, without extension guessing. */\nexport function resolveRelativePath(fromFile: string, specifier: string): string {\n const base = fromFile.split(\"/\").slice(0, -1);\n for (const part of specifier.split(\"/\")) {\n if (part === \"\" || part === \".\") continue;\n if (part === \"..\") base.pop();\n else base.push(part);\n }\n return base.join(\"/\");\n}\n\nconst RESOLVE_SUFFIXES = [\"\", \".tsx\", \".ts\", \".jsx\", \".js\", \".json\", \"/index.tsx\", \"/index.ts\", \"/index.jsx\", \"/index.js\"];\n\n/** The file in `files` a relative specifier names, or null. */\nexport function resolveRelativeFile(\n files: Readonly<Record<string, string>>,\n fromFile: string,\n specifier: string,\n): string | null {\n const target = resolveRelativePath(fromFile, specifier);\n for (const suffix of RESOLVE_SUFFIXES) {\n const candidate = `${target}${suffix}`;\n if (Object.prototype.hasOwnProperty.call(files, candidate)) return candidate;\n }\n return null;\n}\n\n/** The module paths a source imports, in source order, de-duplicated. */\nexport function importPaths(source: string): string[] {\n const found = new Set<string>();\n for (const re of [IMPORT_RE, EXPORT_FROM_RE]) {\n re.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = re.exec(source ?? \"\")) !== null) {\n if (match[1]) found.add(match[1]);\n }\n }\n return [...found];\n}\n\nconst ALLOWED_SENTENCE =\n \"Rewrite it using only the documented scope (react, lucide-react, recharts, \" +\n \"@ai-matrx/design-system/controls, @ai-matrx/design-system, @/lib/utils, \" +\n \"@/components/ui/*, @/components/kind-kit/*, CopyButtons/CopyForAiButton, Markdown) \" +\n \"or a file of this component.\";\n\nfunction importFindings(files: Readonly<Record<string, string>>, file: string, source: string): Finding[] {\n const out: Finding[] = [];\n const allowed = new Set(GATE_ALLOWED_IMPORTS);\n for (const re of [IMPORT_RE, EXPORT_FROM_RE]) {\n re.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = re.exec(source)) !== null) {\n const path = match[1] ?? \"\";\n const line = lineAt(source, match.index + match[0].indexOf(path));\n if (path.startsWith(\"./\") || path.startsWith(\"../\")) {\n if (!resolveRelativeFile(files, file, path)) {\n out.push({\n rule: \"relative-import-missing\",\n file,\n line,\n severity: \"refuse\",\n message: `This file imports \"${path}\", but no file of this component has that name. Add the file or fix the path.`,\n });\n }\n continue;\n }\n if (!allowed.has(path)) {\n out.push({\n rule: \"import-not-allowed\",\n file,\n line,\n severity: \"refuse\",\n message: `This component imports \"${path}\", which is outside the sandbox scope, so it would render as a marked placeholder. ${ALLOWED_SENTENCE}`,\n });\n }\n }\n }\n DYNAMIC_IMPORT_RE.lastIndex = 0;\n const dyn = DYNAMIC_IMPORT_RE.exec(source);\n if (dyn) {\n out.push({\n rule: \"dynamicImport\",\n file,\n line: lineAt(source, dyn.index),\n severity: \"refuse\",\n message:\n \"This component uses a dynamic import(). The in-page compiler has no module loader, so the call would either fail at render or reach code nobody vetted. Import from the scope at the top of the file instead.\",\n });\n }\n return out;\n}\n\nfunction bannedGlobalMessage(name: string): string {\n return (\n `This component uses \"${name}\", which components stored in the database may ` +\n \"not use. They run inside the signed-in page, so anything that reaches the \" +\n \"network, browser storage, or the JavaScript evaluator could read or send \" +\n \"the reader's data. Render what the Shape hands you in props.data and use \" +\n \"a Shape action for anything the component needs from the server.\"\n );\n}\n\nfunction bannedMemberCallMessage(name: string): string {\n return (\n `This component uses \".${name}(\", which components stored in the database ` +\n \"may not use. Calling a value's constructor reaches the JavaScript \" +\n \"evaluator, so it could run code nobody reviewed inside the signed-in \" +\n \"page. Write the logic out directly instead.\"\n );\n}\n\nfunction bannedComputedAccessMessage(name: string): string {\n return (\n `This component uses \"${name}[\", which components stored in the database ` +\n \"may not use. Looking a property up by a computed name hides which \" +\n \"browser capability the component reaches, so no review can tell whether \" +\n `it is safe. Name what you need directly, or use props.data and a Shape ` +\n \"action for anything the component needs from the server.\"\n );\n}\n\nfunction globalFindings(file: string, code: string): Finding[] {\n const out: Finding[] = [];\n const push = (rule: string, re: RegExp, message: string) => {\n const m = re.exec(code);\n if (m) out.push({ rule, file, line: lineAt(code, m.index), severity: \"refuse\", message });\n };\n for (const name of GATE_BANNED_GLOBALS) {\n push(\"bannedGlobal\", new RegExp(`(?<![.\\\\w$])${escapeForRegExp(name)}\\\\b`), bannedGlobalMessage(name));\n }\n for (const name of GATE_BANNED_CALLABLES) {\n const e = escapeForRegExp(name);\n push(\"bannedCallable\", new RegExp(`\\\\bnew\\\\s+${e}\\\\s*\\\\(|(?<![.\\\\w$])${e}\\\\s*\\\\(`), bannedGlobalMessage(name));\n }\n for (const name of GATE_BANNED_MEMBER_ACCESS) {\n push(\"bannedMemberAccess\", new RegExp(`\\\\.\\\\s*${escapeForRegExp(name)}\\\\b`), bannedGlobalMessage(name));\n }\n for (const name of GATE_BANNED_MEMBER_CALLS) {\n push(\"bannedMemberCall\", new RegExp(`\\\\.\\\\s*${escapeForRegExp(name)}\\\\s*\\\\(`), bannedMemberCallMessage(name));\n }\n for (const name of GATE_BANNED_COMPUTED_ACCESS) {\n const e = escapeForRegExp(name);\n push(\"bannedComputedAccess\", new RegExp(`(?<![.\\\\w$])${e}\\\\s*\\\\[|\\\\.\\\\s*${e}\\\\s*\\\\[`), bannedComputedAccessMessage(name));\n }\n return out;\n}\n\n/**\n * THE ONE GATE (CONTRACTS §7). Every finding names its file and line; any\n * `refuse` finding means the code may not be stored. `.html` files and\n * `.json` files are not compiled in the page and are skipped.\n */\nexport function gate(files: Readonly<Record<string, string>>): Finding[] {\n const out: Finding[] = [];\n for (const [file, source] of Object.entries(files)) {\n if (/\\.(html?|json|css|md)$/i.test(file)) continue;\n const code = source ?? \"\";\n out.push(...importFindings(files, file, code), ...globalFindings(file, code));\n }\n return out;\n}\n\n/**\n * The single-body form today's writers call: the first refusing sentence, or\n * null when the source may be stored. `flavor: \"html\"` bodies render in an\n * opaque-origin iframe and are not checked.\n */\nexport function componentSourceGate(source: string, options?: { flavor?: string | null }): string | null {\n if ((options?.flavor ?? \"\").toLowerCase() === \"html\") return null;\n const finding = gate({ \"component.tsx\": source ?? \"\" }).find((f) => f.severity === \"refuse\");\n return finding ? finding.message : null;\n}\n","/**\n * THE ONE DOCUMENTED SCOPE REGISTRY — every import path stored code may name.\n *\n * Merged from matrx-frontend's two registries (`agent-apps/utils/\n * allowed-imports.ts` and `dynamic-react/toolRendererScope.ts`), which\n * disagreed on strategies, lists and loading. Rules that hold:\n * - every entry is EXPLICITLY named and documented; no wildcard;\n * - nothing here reaches data: no database client, no fetch wrapper, no\n * store — data reach belongs to the host (CONTRACTS §1);\n * - an entry is `package`-owned (this package ships its module, so a plain\n * Vite page gets it) or `host`-owned (declared and documented here, the\n * module supplied by the host through `provideScopeModules`); a host entry\n * no host supplied renders named stand-ins and is reported, never crashes;\n * - `@/components/ui/*` are LEGACY ALIASES kept while stored code uses them\n * (census 2026-10-06: 67 kind components, 78 apps). Each names the same\n * design-system export the frontend file re-exports; new code imports\n * `@ai-matrx/design-system/controls` (the primary UI set).\n *\n * Pure data: no React, no module loads — `gate.ts` and servers read it.\n * `gate-lists.json#allowedImports` must equal `listScopeEntryPaths()` sorted\n * (guard: `scope-registry.test.ts`).\n */\n\nexport type ScopeStrategy = \"named\" | \"spread\" | \"namespace\";\n\nexport interface ScopeEntryDeclaration {\n /** The import path stored code writes. */\n path: string;\n /** `named`: listed exports; `spread`: every export; `namespace`: the module under `namespaceName`. */\n strategy: ScopeStrategy;\n exports?: readonly string[];\n /** moduleKey → scope name (`{ default: \"MarkdownStream\" }`). */\n exportMap?: Readonly<Record<string, string>>;\n namespaceName?: string;\n /** Missing PascalCase names resolve to a visible stand-in (icon sets). */\n safeProxy?: boolean;\n /** Always present for chat code blocks (cheap, already in shared chunks). */\n core?: boolean;\n /** Identifiers whose bare use implies this entry (heavy-lib demand detection). */\n provides?: readonly string[];\n owner: \"package\" | \"host\";\n description: string;\n}\n\nconst REACT_EXPORTS = [\n \"useState\", \"useEffect\", \"useMemo\", \"useCallback\", \"useRef\", \"useReducer\", \"useContext\",\n \"useId\", \"useTransition\", \"useDeferredValue\", \"useLayoutEffect\", \"Fragment\",\n] as const;\n\nfunction ui(\n name: string,\n exports: readonly string[],\n description: string,\n): ScopeEntryDeclaration {\n return { path: `@/components/ui/${name}`, strategy: \"named\", exports, core: true, owner: \"package\", description };\n}\n\nfunction markdownAlias(path: string, description: string): ScopeEntryDeclaration {\n return { path, strategy: \"named\", exportMap: { default: \"MarkdownStream\" }, core: true, owner: \"host\", description };\n}\n\nfunction kindKit(name: string, exports: readonly string[], description: string): ScopeEntryDeclaration {\n return { path: `@/components/kind-kit/${name}`, strategy: \"named\", exports, owner: \"host\", description };\n}\n\nexport const SCOPE_ENTRIES: readonly ScopeEntryDeclaration[] = [\n // ── Core ─────────────────────────────────────────────────────────────────\n { path: \"react\", strategy: \"named\", exports: REACT_EXPORTS, exportMap: { default: \"React\" }, core: true, owner: \"package\", description: \"React core (hooks, Fragment)\" },\n { path: \"lucide-react\", strategy: \"spread\", safeProxy: true, core: true, owner: \"package\", description: \"Lucide icons; a missing name renders a marked placeholder\" },\n { path: \"@ai-matrx/icons\", strategy: \"named\", exports: [\"DynamicIcon\", \"renderIcon\", \"getIconComponent\"], core: true, owner: \"package\", description: \"DynamicIcon: any icon by string name\" },\n { path: \"@/components/official/icons/IconResolver\", strategy: \"named\", exports: [\"DynamicIcon\", \"renderIcon\", \"getIconComponent\"], core: true, owner: \"package\", description: \"Legacy alias of @ai-matrx/icons\" },\n { path: \"@/lib/utils\", strategy: \"named\", exports: [\"cn\"], core: true, owner: \"package\", description: \"cn(): className merge\" },\n\n // ── The primary UI set ───────────────────────────────────────────────────\n { path: \"@ai-matrx/design-system/controls\", strategy: \"spread\", core: true, owner: \"package\", description: \"THE controls: Button, Field, SearchField, Select, SegmentedControl, Tabs, Badge, Switch, Textarea, EmptyState…\" },\n { path: \"@ai-matrx/design-system\", strategy: \"spread\", owner: \"package\", description: \"Design-system surfaces: Card, Dialog, Popover, Tooltip, Table, Accordion…\" },\n\n // ── Copy actions ─────────────────────────────────────────────────────────\n { path: \"@/components/agent-copy/CopyButtons\", strategy: \"named\", exports: [\"CopyButtons\"], owner: \"host\", description: \"Copy / Copy-for-AI / JSON / Export bar from caller-supplied builders\" },\n { path: \"@/components/agent-copy/CopyForAiButton\", strategy: \"named\", exports: [\"CopyForAiButton\"], owner: \"host\", description: \"Single Copy-for-AI action\" },\n\n // ── kind-kit ─────────────────────────────────────────────────────────────\n kindKit(\"SortableList\", [\"SortableList\"], \"Drag-to-reorder list with arrow fallback and onRemove\"),\n kindKit(\"KindPanelGrid\", [\"KindPanelGrid\"], \"Content-aware auto-fit grid of equal-height panels\"),\n kindKit(\"KindPanel\", [\"KindPanel\"], \"Compact panel: header + overflow menu, subline, body, footer\"),\n kindKit(\"KindHeaderBar\", [\"KindHeaderBar\"], \"Kind title + stats + copy bar\"),\n kindKit(\"StreamingSkeleton\", [\"StreamingSkeleton\", \"useStreamingValue\", \"streamList\", \"streamText\"], \"Streaming skeletons + tolerant partial-value reads\"),\n kindKit(\"TagList\", [\"KeywordChip\", \"TagList\"], \"Wrapping chips with select, remove, inline edit, add\"),\n\n // ── Markdown (one renderer, four spellings stored code uses) ─────────────\n markdownAlias(\"@/components/MarkdownStream\", \"MarkdownStream: the one markdown renderer\"),\n markdownAlias(\"@/components/Markdown\", \"MarkdownStream (legacy path)\"),\n markdownAlias(\"@/components/markdown\", \"MarkdownStream (lowercase path)\"),\n markdownAlias(\"@/components/mardown\", \"MarkdownStream (common misspelling)\"),\n\n // ── Legacy UI aliases (each = the design-system export the app re-exports) ─\n ui(\"button\", [\"Button\"], \"Button\"),\n ui(\"input\", [\"Input\"], \"Input\"),\n ui(\"textarea\", [\"Textarea\"], \"Textarea\"),\n ui(\"card\", [\"Card\", \"CardAction\", \"CardContent\", \"CardDescription\", \"CardFooter\", \"CardHeader\", \"CardTitle\"], \"Card family\"),\n ui(\"label\", [\"Label\"], \"Label\"),\n ui(\"select\", [\"Select\", \"SelectContent\", \"SelectGroup\", \"SelectItem\", \"SelectLabel\", \"SelectScrollDownButton\", \"SelectScrollUpButton\", \"SelectSeparator\", \"SelectValue\", \"selectTriggerVariants\", \"SelectTrigger\", \"SelectTriggerLegacy\"], \"Select family\"),\n ui(\"slider\", [\"Slider\"], \"Slider\"),\n ui(\"switch\", [\"Switch\"], \"Switch\"),\n ui(\"tabs\", [\"Tabs\", \"TabsContent\", \"TabsList\", \"TabsTrigger\", \"TabsTriggerCore\", \"TabsListLegacy\", \"TabsTriggerLegacy\", \"TabsTriggerCoreLegacy\"], \"Tabs family\"),\n ui(\"badge\", [\"Badge\"], \"Badge\"),\n ui(\"tooltip\", [\"Tooltip\", \"TooltipContent\", \"TooltipProvider\", \"TooltipTrigger\"], \"Tooltip family\"),\n ui(\"accordion\", [\"Accordion\", \"AccordionContent\", \"AccordionItem\", \"AccordionTrigger\", \"useAccordionSize\"], \"Accordion family\"),\n ui(\"collapsible\", [\"Collapsible\", \"CollapsibleContent\", \"CollapsibleTrigger\"], \"Collapsible family\"),\n ui(\"progress\", [\"Progress\"], \"Progress bar\"),\n ui(\"separator\", [\"Separator\"], \"Separator\"),\n ui(\"scroll-area\", [\"ScrollArea\", \"ScrollBar\"], \"ScrollArea\"),\n ui(\"dialog\", [\"Dialog\", \"DialogClose\", \"DialogContent\", \"DialogContentPrimitive\", \"DialogDescription\", \"DialogFooter\", \"DialogHeader\", \"DialogOverlay\", \"DialogPortal\", \"DialogTitle\", \"DialogTrigger\", \"useDialogContainer\"], \"Dialog family\"),\n ui(\"sheet\", [\"Sheet\", \"SheetPortal\", \"SheetOverlay\", \"SheetTrigger\", \"SheetClose\", \"SheetContent\", \"SheetHeader\", \"SheetFooter\", \"SheetTitle\", \"SheetDescription\"], \"Sheet family\"),\n ui(\"dropdown-menu\", [\"DropdownMenu\", \"DropdownMenuCheckboxItem\", \"DropdownMenuContent\", \"DropdownMenuGroup\", \"DropdownMenuItem\", \"DropdownMenuLabel\", \"DropdownMenuPortal\", \"DropdownMenuRadioGroup\", \"DropdownMenuRadioItem\", \"DropdownMenuSeparator\", \"DropdownMenuShortcut\", \"DropdownMenuSub\", \"DropdownMenuSubContent\", \"DropdownMenuSubTrigger\", \"DropdownMenuTrigger\"], \"Dropdown menu family\"),\n ui(\"table\", [\"Table\", \"TableBody\", \"TableCaption\", \"TableCell\", \"TableFooter\", \"TableHead\", \"TableHeader\", \"TableRow\"], \"Table family\"),\n ui(\"checkbox\", [\"Checkbox\"], \"Checkbox\"),\n ui(\"radio-group\", [\"RadioGroup\", \"RadioGroupItem\"], \"Radio group\"),\n ui(\"popover\", [\"Popover\", \"PopoverTrigger\", \"PopoverContent\", \"PopoverAnchor\"], \"Popover family\"),\n ui(\"avatar\", [\"Avatar\", \"AvatarFallback\", \"AvatarImage\"], \"Avatar family\"),\n ui(\"alert\", [\"Alert\", \"AlertDescription\", \"AlertTitle\", \"alertVariants\"], \"Alert family\"),\n ui(\"skeleton\", [\"Skeleton\"], \"Skeleton\"),\n\n // ── Applet parts ─────────────────────────────────────────────────────────\n { path: \"@/applets\", strategy: \"named\", exports: [\"DataPage\", \"Applet\"], owner: \"host\", description: \"A table-built page and a nested Applet (legacy path; becomes @ai-matrx/applets/react)\" },\n { path: \"@ai-matrx/applets/react\", strategy: \"spread\", owner: \"host\", description: \"The Applet hooks: useRows, useJob, useValue, useAction, <Kind>, <Pages>, navigate…\" },\n\n // ── Heavy libraries (loaded only when referenced) ────────────────────────\n { path: \"recharts\", strategy: \"spread\", owner: \"package\", provides: [\"ResponsiveContainer\", \"LineChart\", \"BarChart\", \"AreaChart\", \"PieChart\", \"RadarChart\", \"ScatterChart\", \"ComposedChart\", \"RadialBarChart\"], description: \"Charts (recharts)\" },\n { path: \"motion/react\", strategy: \"spread\", owner: \"host\", provides: [\"motion\", \"AnimatePresence\", \"useAnimate\", \"useInView\"], description: \"Animation (motion)\" },\n { path: \"react-katex\", strategy: \"spread\", owner: \"host\", provides: [\"BlockMath\", \"InlineMath\"], description: \"Math typesetting (KaTeX)\" },\n { path: \"react-pdf\", strategy: \"named\", exports: [\"Document\", \"Page\", \"Outline\"], owner: \"host\", provides: [\"Document\", \"Page\", \"Outline\"], description: \"PDF viewing (react-pdf)\" },\n { path: \"xlsx\", strategy: \"namespace\", namespaceName: \"XLSX\", owner: \"host\", provides: [\"XLSX\"], description: \"Workbooks (xlsx)\" },\n { path: \"@react-three/fiber\", strategy: \"spread\", owner: \"host\", provides: [\"Canvas\", \"useFrame\", \"useThree\", \"useLoader\"], description: \"3D React renderer\" },\n { path: \"three\", strategy: \"namespace\", namespaceName: \"THREE\", owner: \"host\", provides: [\"THREE\"], description: \"3D engine (three.js)\" },\n { path: \"date-fns\", strategy: \"namespace\", namespaceName: \"dateFns\", owner: \"host\", provides: [\"dateFns\"], description: \"Date utilities (date-fns)\" },\n { path: \"lodash\", strategy: \"namespace\", namespaceName: \"_\", owner: \"host\", provides: [\"_\"], description: \"Utility helpers (lodash)\" },\n];\n\nconst BY_PATH = new Map(SCOPE_ENTRIES.map((e) => [e.path, e]));\n\nexport function getScopeEntry(path: string): ScopeEntryDeclaration | undefined {\n return BY_PATH.get(path);\n}\n\n/** Every documented path, in registry order. */\nexport function listScopeEntryPaths(): string[] {\n return SCOPE_ENTRIES.map((e) => e.path);\n}\n\n/** Every documented entry with its description (for builders, agents and docs). */\nexport function listScopeEntries(): readonly ScopeEntryDeclaration[] {\n return SCOPE_ENTRIES;\n}\n\n/**\n * The default scope for stored components (kind components, tool renderers,\n * Applets): everything except the heavy optional libraries, which are added\n * by demand detection. Order is spread precedence: later entries win.\n */\nexport function defaultComponentEntries(): string[] {\n return SCOPE_ENTRIES.filter((e) => !e.provides || e.path === \"recharts\").map((e) => e.path);\n}\n\n/** Paths always loaded for chat code blocks. */\nexport function coreEntryPaths(): string[] {\n return SCOPE_ENTRIES.filter((e) => e.core).map((e) => e.path);\n}\n\n/**\n * The entries a set of files needs: the core set, every documented path it\n * imports, and every heavy library whose identifiers it uses bare.\n */\nexport function detectEntries(files: Readonly<Record<string, string>>): string[] {\n const needed = new Set(coreEntryPaths());\n const code = Object.values(files).join(\"\\n\");\n const imported = new Set<string>();\n for (const m of code.matchAll(/from\\s+['\"]([^'\"]+)['\"]/g)) if (m[1]) imported.add(m[1]);\n for (const entry of SCOPE_ENTRIES) {\n if (entry.core) continue;\n if (imported.has(entry.path)) needed.add(entry.path);\n else if (entry.provides?.some((id) => new RegExp(`(?<![\\\\w$.])${id.replace(/[$]/g, \"\\\\$\")}\\\\b`).test(code))) {\n needed.add(entry.path);\n }\n }\n return SCOPE_ENTRIES.map((e) => e.path).filter((p) => needed.has(p));\n}\n","/**\n * Building a compile's scope: the flat values passed as function parameters\n * (so bodies that use `useState` or an icon without importing it keep\n * working) and the per-path module views `require` hands out.\n *\n * Behavior ported from matrx-frontend `allowed-imports.ts`\n * (`buildComponentScope`, `bindImportedIdentifiers`, the safe proxy) and\n * `toolRendererScope.ts` (namespace entries), collapsed into one builder.\n */\nimport * as ReactModule from \"react\";\n\nimport lists from \"../gate-lists.json\";\nimport type { ScopeSpec, UnresolvedImport } from \"../types\";\nimport { getScopeEntry, type ScopeEntryDeclaration } from \"./entries\";\nimport { announceFailedModule, readScopeModule } from \"./modules\";\nimport { createUnresolvedImportStandIn, readUnresolvedImportMark } from \"./stand-in\";\n\ntype AnyRecord = Record<string, unknown>;\n\nexport interface ScopeState {\n /** Flat scope: name → value (the function parameters). */\n values: AnyRecord;\n /** path → the module object `require(path)` returns. */\n modules: Map<string, AnyRecord>;\n /** Paths whose missing PascalCase names resolve to stand-ins. */\n safeProxyPaths: Map<string, { proxy: AnyRecord; keys: Set<string> }>;\n unresolved: UnresolvedImport[];\n /** Entries whose async module is not loaded yet (`prepareScope` first). */\n pending: string[];\n}\n\nexport function recordUnresolved(state: Pick<ScopeState, \"unresolved\">, entry: UnresolvedImport): void {\n if (!state.unresolved.some((e) => e.identifier === entry.identifier && e.importPath === entry.importPath)) {\n state.unresolved.push(entry);\n }\n}\n\nfunction asRecord(value: unknown): AnyRecord {\n return value && (typeof value === \"object\" || typeof value === \"function\") ? (value as AnyRecord) : {};\n}\n\nfunction ownKeys(mod: AnyRecord): string[] {\n try {\n return Object.keys(mod);\n } catch {\n return [];\n }\n}\n\n/** Missing PascalCase keys → a visible stand-in (icon sets). */\nfunction createSafeModuleProxy(importPath: string, moduleExports: AnyRecord, state: Pick<ScopeState, \"unresolved\">): AnyRecord {\n const target: AnyRecord = { ...moduleExports, __esModule: true };\n return new Proxy(target, {\n get(t, prop) {\n if (typeof prop !== \"string\") return Reflect.get(t, prop);\n if (prop in t) return t[prop];\n if (prop.startsWith(\"_\") || prop === \"default\" || prop === \"then\") return undefined;\n if (/^[A-Z]/.test(prop)) {\n const fallback = createUnresolvedImportStandIn(prop, importPath);\n t[prop] = fallback;\n recordUnresolved(state, { identifier: prop, importPath });\n return fallback;\n }\n return undefined;\n },\n has(t, prop) {\n if (typeof prop === \"string\" && /^[A-Z]/.test(prop)) return true;\n return prop in t;\n },\n });\n}\n\n/** The module object `require(path)` answers for one loaded entry. */\nfunction moduleView(entry: ScopeEntryDeclaration, mod: AnyRecord, state: Pick<ScopeState, \"unresolved\">): AnyRecord {\n if (entry.strategy === \"namespace\") {\n const ns = asRecord(mod.default ?? mod);\n return { ...ns, default: ns, __esModule: true };\n }\n if (entry.safeProxy) return createSafeModuleProxy(entry.path, mod, state);\n const view: AnyRecord = { ...mod, __esModule: true };\n for (const [moduleKey, scopeKey] of Object.entries(entry.exportMap ?? {})) {\n const value = moduleKey === \"default\" ? (mod.default ?? mod) : mod[moduleKey];\n view[scopeKey] = value;\n if (moduleKey === \"default\") view.default = value;\n }\n // A module with no default export has no default: `import X from` it is\n // reported and stands in (link time), never silently the module object.\n if (!(\"default\" in view)) view.default = mod.default;\n return view;\n}\n\nfunction applyToFlatScope(entry: ScopeEntryDeclaration, mod: AnyRecord, values: AnyRecord): void {\n if (entry.strategy === \"namespace\") {\n if (entry.namespaceName) values[entry.namespaceName] = mod.default ?? mod;\n return;\n }\n if (entry.strategy === \"spread\") {\n for (const key of ownKeys(mod)) {\n if (key === \"default\" || key === \"__esModule\") continue;\n values[key] = mod[key];\n }\n return;\n }\n for (const name of entry.exports ?? []) values[name] = mod[name];\n for (const [moduleKey, scopeKey] of Object.entries(entry.exportMap ?? {})) {\n values[scopeKey] = moduleKey === \"default\" ? (mod.default ?? mod) : mod[moduleKey];\n }\n}\n\n/**\n * Throwing stubs for the globals stored code may not use. Named error, never\n * silence: the reader's error boundary shows which global it reached for.\n * BACKSTOP, not a sandbox — bare identifiers only; `window.fetch` still\n * resolves. The write-time gate refuses `window.fetch`; the sandbox frame is\n * the real boundary.\n */\nexport function buildDangerousGlobalStubs(): AnyRecord {\n const stubs: AnyRecord = {};\n for (const name of [...lists.bannedGlobals, ...lists.bannedCallables]) {\n stubs[name] = function bannedGlobal(): never {\n throw new Error(\n `This component tried to use \"${name}\". Components stored in the ` +\n \"database run inside the signed-in page and may not reach the \" +\n \"network, browser storage, or the JavaScript evaluator. Render what \" +\n \"the Shape hands you in props.data, and use a Shape action for \" +\n \"anything you need from the server.\",\n );\n };\n }\n return stubs;\n}\n\n/** Build the full scope state for a spec. Never throws. */\nexport function buildScopeState(spec: ScopeSpec): ScopeState {\n const state: ScopeState = { values: {}, modules: new Map(), safeProxyPaths: new Map(), unresolved: [], pending: [] };\n const R = ReactModule as unknown as AnyRecord;\n // React core is always present (classic JSX needs `React`).\n state.values.React = R;\n for (const hook of [\"useState\", \"useEffect\", \"useMemo\", \"useCallback\", \"useRef\"]) state.values[hook] = R[hook];\n state.modules.set(\"react\", { ...R, default: R, __esModule: true });\n\n for (const path of spec.entries ?? []) {\n const entry = getScopeEntry(path);\n if (!entry) {\n recordUnresolved(state, { identifier: \"*\", importPath: path });\n continue;\n }\n const read = readScopeModule(path);\n if (read.state === \"pending\") {\n state.pending.push(path);\n continue;\n }\n if (read.state === \"missing\") {\n // A host-owned entry this host did not supply: nothing to report until\n // code reaches for it (an import of it, or a bare name, is recorded then).\n continue;\n }\n if (read.state === \"failed\") {\n // Announced once per page (loud), and a gap only for code that reaches\n // for it — an import of it, or a bare name, is recorded at link time.\n announceFailedModule(path, read.message);\n continue;\n }\n const mod = asRecord(read.module);\n const view = moduleView(entry, mod, state);\n state.modules.set(path, view);\n if (entry.safeProxy) {\n state.safeProxyPaths.set(path, { proxy: view, keys: new Set(ownKeys(mod)) });\n }\n applyToFlatScope(entry, mod, state.values);\n }\n\n if (state.values.MarkdownStream && !state.values.Markdown) state.values.Markdown = state.values.MarkdownStream;\n if (!state.values.DynamicIcon) {\n const icons = readScopeModule(\"@ai-matrx/icons\");\n if (icons.state === \"ready\") {\n const m = asRecord(icons.module);\n state.values.DynamicIcon = m.DynamicIcon;\n state.values.renderIcon = m.renderIcon;\n state.values.getIconComponent = m.getIconComponent;\n }\n }\n const overrides = spec.overrides ?? {};\n Object.assign(state.values, overrides);\n // An override replaces the NAME everywhere code can reach it — the flat\n // scope and every module view that exports it (named, or as its mapped\n // default), so `import Md from \"@/components/MarkdownStream\"` gets the\n // host's runtime-aware renderer too.\n if (Object.keys(overrides).length > 0) {\n for (const [path, view] of state.modules) {\n const entry = getScopeEntry(path);\n for (const [moduleKey, scopeKey] of Object.entries(entry?.exportMap ?? {})) {\n if (!(scopeKey in overrides)) continue;\n view[scopeKey] = overrides[scopeKey];\n if (moduleKey === \"default\") view.default = overrides[scopeKey];\n else view[moduleKey] = overrides[scopeKey];\n }\n for (const name of entry?.exports ?? []) {\n if (name in overrides) view[name] = overrides[name];\n }\n }\n }\n if (spec.shadowDangerousGlobals) Object.assign(state.values, buildDangerousGlobalStubs());\n return state;\n}\n\n/**\n * `buildScope` (CONTRACTS §7): the named, documented values a spec puts in\n * scope. Async entries not yet prepared are absent (see `prepareScope`).\n */\nexport function buildScope(spec: ScopeSpec): Record<string, unknown> {\n return { ...buildScopeState(spec).values };\n}\n\n/**\n * A stand-in for every bare JSX reference no scope value, module export or\n * author declaration supplies. Each is recorded.\n */\nexport function patchMissingJsx(\n identifiers: Iterable<string>,\n state: ScopeState,\n declared: ReadonlySet<string>,\n skip: ReadonlySet<string>,\n): void {\n for (const identifier of identifiers) {\n if (skip.has(identifier) || identifier in state.values || declared.has(identifier)) continue;\n let provided = false;\n for (const [, { proxy, keys }] of state.safeProxyPaths) {\n if (!keys.has(identifier)) continue;\n const value = proxy[identifier];\n if (value !== undefined) {\n state.values[identifier] = value;\n const mark = readUnresolvedImportMark(value);\n if (mark) recordUnresolved(state, mark);\n provided = true;\n break;\n }\n }\n if (provided) continue;\n state.values[identifier] = createUnresolvedImportStandIn(identifier);\n recordUnresolved(state, { identifier, importPath: null });\n }\n}\n","/**\n * Where each scope entry's MODULE comes from.\n *\n * Package-owned entries load modules this package ships (so a plain Vite page\n * needs nothing else); host-owned entries are supplied by the host with\n * `provideScopeModules`. A host may also replace a package-owned module (the\n * web app hands its own `@/components/ui/*` files so stored code renders\n * exactly as the app does). Loaders may be sync or async; async ones are\n * resolved by `prepareScope` before a compile.\n *\n * State lives on `globalThis` under a `Symbol.for` key — never module state —\n * so duplicated bundles and the ESM/CJS boundary share one registry.\n */\nimport * as ReactModule from \"react\";\nimport * as LucideModule from \"lucide-react\";\nimport * as IconsModule from \"@ai-matrx/icons\";\nimport * as DesignSystem from \"@ai-matrx/design-system\";\nimport * as Controls from \"@ai-matrx/design-system/controls\";\n\nimport { getScopeEntry } from \"./entries\";\n\nexport type ScopeModuleLoader = () => unknown;\n\ninterface ModuleStore {\n announced: Set<string>;\n provided: Map<string, ScopeModuleLoader>;\n loaded: Map<string, unknown>;\n pending: Map<string, Promise<unknown>>;\n failed: Map<string, string>;\n}\n\nconst STORE_KEY = Symbol.for(\"ai-matrx.code-runtime.modules\");\n\nfunction store(): ModuleStore {\n const g = globalThis as unknown as Record<symbol, ModuleStore | undefined>;\n let s = g[STORE_KEY];\n if (!s) {\n s = { announced: new Set(), provided: new Map(), loaded: new Map(), pending: new Map(), failed: new Map() };\n g[STORE_KEY] = s;\n }\n return s;\n}\n\nconst ds = DesignSystem as unknown as Record<string, unknown>;\nconst controls = Controls as unknown as Record<string, unknown>;\n\n/**\n * The legacy `@/components/ui/*` aliases resolve to the design system the\n * same way the web app's own files do (button, textarea, switch, the select\n * trigger and the tabs bar come from `/controls`; the rest — Input included —\n * from the root).\n */\nconst LEGACY_UI_MODULE: Record<string, unknown> = {\n ...ds,\n Button: controls.Button,\n Textarea: controls.Textarea,\n Switch: controls.Switch,\n SelectTrigger: controls.SelectTrigger,\n SelectTriggerLegacy: ds.SelectTrigger,\n TabsList: controls.TabsList,\n TabsTrigger: controls.TabsTrigger,\n TabsListLegacy: ds.TabsList,\n TabsTriggerLegacy: ds.TabsTrigger,\n};\n\nfunction packageLoader(path: string): ScopeModuleLoader | null {\n if (path === \"react\") return () => ReactModule;\n if (path === \"lucide-react\") return () => LucideModule;\n if (path === \"@ai-matrx/icons\" || path === \"@/components/official/icons/IconResolver\") return () => IconsModule;\n if (path === \"@ai-matrx/design-system\") return () => DesignSystem;\n if (path === \"@ai-matrx/design-system/controls\") return () => Controls;\n if (path === \"@/lib/utils\") return () => ({ cn: ds.cn });\n if (path.startsWith(\"@/components/ui/\")) return () => LEGACY_UI_MODULE;\n if (path === \"recharts\") return () => import(\"recharts\");\n return null;\n}\n\n/**\n * Supply (or replace) the modules for scope entries. Keys must be documented\n * registry paths; an unknown key throws, because a module nobody documented\n * is exactly the reach the registry exists to prevent.\n */\nexport function provideScopeModules(map: Readonly<Record<string, ScopeModuleLoader>>): void {\n const s = store();\n for (const [path, loader] of Object.entries(map)) {\n if (!getScopeEntry(path)) {\n throw new Error(\n `[code-runtime] \"${path}\" is not a documented scope entry. Add it to the registry in @ai-matrx/code-runtime (scope/entries.ts) with a description first.`,\n );\n }\n s.provided.set(path, loader);\n s.loaded.delete(path);\n s.pending.delete(path);\n s.failed.delete(path);\n }\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return !!value && typeof (value as { then?: unknown }).then === \"function\";\n}\n\nfunction loaderFor(path: string): ScopeModuleLoader | null {\n return store().provided.get(path) ?? packageLoader(path);\n}\n\nexport type ModuleState =\n | { state: \"ready\"; module: unknown }\n | { state: \"pending\" }\n | { state: \"missing\" }\n | { state: \"failed\"; message: string };\n\n/** Synchronously read a module, starting an async load when needed. */\nexport function readScopeModule(path: string): ModuleState {\n const s = store();\n if (s.loaded.has(path)) return { state: \"ready\", module: s.loaded.get(path) };\n const failed = s.failed.get(path);\n if (failed) return { state: \"failed\", message: failed };\n if (s.pending.has(path)) return { state: \"pending\" };\n const loader = loaderFor(path);\n if (!loader) return { state: \"missing\" };\n try {\n const value = loader();\n if (isPromiseLike(value)) {\n const promise = Promise.resolve(value).then(\n (mod) => {\n s.loaded.set(path, mod);\n s.pending.delete(path);\n return mod;\n },\n (err: unknown) => {\n s.failed.set(path, err instanceof Error ? err.message : String(err));\n s.pending.delete(path);\n return undefined;\n },\n );\n s.pending.set(path, promise);\n return { state: \"pending\" };\n }\n s.loaded.set(path, value);\n return { state: \"ready\", module: value };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n s.failed.set(path, message);\n return { state: \"failed\", message };\n }\n}\n\n/** Resolve every async module the given entries need. Never rejects. */\nexport async function prepareScopeModules(paths: readonly string[]): Promise<void> {\n const s = store();\n for (const path of paths) readScopeModule(path);\n await Promise.all(paths.map((p) => s.pending.get(p)).filter((p): p is Promise<unknown> => !!p));\n}\n\n/** A scope module that failed to load — one console error per path per page, never silence. */\nexport function announceFailedModule(path: string, message: string): void {\n const s = store();\n if (s.announced.has(path)) return;\n s.announced.add(path);\n console.error(`[code-runtime] The scope entry \"${path}\" failed to load (${message}); code that imports it renders marked placeholders.`);\n}\n\n/** Test seam: forget every provided and loaded module. */\nexport function resetScopeModules(): void {\n const s = store();\n s.announced.clear();\n s.provided.clear();\n s.loaded.clear();\n s.pending.clear();\n s.failed.clear();\n}\n","/**\n * NOTHING FAILS SILENTLY. Stored code that names something the scope cannot\n * supply still renders — one bad import must not blank a whole display — but\n * the gap is SHOWN where it sits: a compact dashed chip carrying the missing\n * name (tooltip: the import path), with the element's children rendered after\n * it. Moved verbatim from matrx-frontend\n * `features/agent-apps/utils/patch-scope-identifiers.ts`; the mark symbol is\n * unchanged (`Symbol.for`) so stand-ins made by either copy are recognised.\n */\nimport * as React from \"react\";\n\nimport type { UnresolvedImport } from \"../types\";\n\nconst UNRESOLVED_IMPORT_MARK = Symbol.for(\"matrx.sandbox.unresolvedImport\");\n\n/** The stand-in's own record, or null when `value` is a real binding. */\nexport function readUnresolvedImportMark(value: unknown): UnresolvedImport | null {\n if (!value || (typeof value !== \"object\" && typeof value !== \"function\")) return null;\n const mark = (value as Record<symbol, unknown>)[UNRESOLVED_IMPORT_MARK];\n return mark && typeof mark === \"object\" ? (mark as UnresolvedImport) : null;\n}\n\nexport function createUnresolvedImportStandIn(\n identifier: string,\n importPath: string | null = null,\n): React.ForwardRefExoticComponent<{ children?: React.ReactNode } & React.RefAttributes<HTMLSpanElement>> {\n const tip = importPath ? `Not found: ${identifier} in \"${importPath}\"` : `Not found: ${identifier}`;\n const StandIn = React.forwardRef<HTMLSpanElement, { children?: React.ReactNode }>(({ children }, ref) => {\n const chip = React.createElement(\n \"span\",\n {\n ref,\n title: tip,\n \"aria-label\": tip,\n role: \"note\",\n \"data-unresolved-import\": identifier,\n \"data-import-path\": importPath ?? undefined,\n className:\n \"inline-flex items-center gap-0.5 rounded border border-dashed border-destructive/60 px-1 align-middle font-mono text-[10px] leading-4 text-destructive\",\n },\n React.createElement(\n \"svg\",\n {\n width: 10,\n height: 10,\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: 2.5,\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n \"aria-hidden\": true,\n },\n React.createElement(\"path\", { d: \"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" }),\n React.createElement(\"line\", { x1: 12, y1: 9, x2: 12, y2: 13 }),\n React.createElement(\"line\", { x1: 12, y1: 17, x2: 12.01, y2: 17 }),\n ),\n identifier,\n );\n return children == null ? chip : React.createElement(React.Fragment, null, chip, children);\n });\n StandIn.displayName = `UnresolvedImport(${identifier})`;\n Object.defineProperty(StandIn, UNRESOLVED_IMPORT_MARK, {\n value: { identifier, importPath } satisfies UnresolvedImport,\n enumerable: false,\n });\n return StandIn;\n}\n\n/** One readable line per unresolved name. */\nexport function describeUnresolved(entry: UnresolvedImport): string {\n if (entry.identifier === \"*\") return `\"${entry.importPath}\" (not in this scope)`;\n return entry.importPath ? `${entry.identifier} from \"${entry.importPath}\"` : entry.identifier;\n}\n\nexport function stripLiteralsForScan(code: string): string {\n return code\n .replace(/\"(?:[^\"\\\\]|\\\\.)*\"/g, '\"\"')\n .replace(/'(?:[^'\\\\]|\\\\.)*'/g, \"''\")\n .replace(/`(?:[^`\\\\]|\\\\.)*`/gs, \"``\");\n}\n\n/** PascalCase identifiers used as JSX element types after the transform. */\nexport function extractJsxComponentIdentifiers(codeForScanning: string): Set<string> {\n const components = new Set<string>();\n const patterns = [\n // `(?![\\w$.])`: `<C.Button>` names the namespace `C`, which is an\n // import or a declaration, never a bare missing component.\n /React\\.createElement\\s*\\(\\s*([A-Z][a-zA-Z0-9]*)(?![\\w$.])/g,\n /\\.default\\.createElement\\s*\\(\\s*([A-Z][a-zA-Z0-9]*)(?![\\w$.])/g,\n /\\bjsxs?\\s*\\(\\s*([A-Z][a-zA-Z0-9]*)(?![\\w$.])/g,\n ];\n for (const pattern of patterns) {\n let match: RegExpExecArray | null;\n while ((match = pattern.exec(codeForScanning)) !== null) {\n if (match[1]) components.add(match[1]);\n }\n }\n return components;\n}\n\n/** Globals and built-ins never patched. */\nexport const PATCH_SCOPE_SKIP_IDENTIFIERS: ReadonlySet<string> = new Set([\n \"React\", \"Object\", \"Array\", \"String\", \"Number\", \"Boolean\", \"Date\", \"Math\", \"JSON\", \"Promise\", \"Error\",\n \"TypeError\", \"RangeError\", \"RegExp\", \"Map\", \"Set\", \"WeakMap\", \"WeakSet\", \"Symbol\", \"Proxy\", \"Reflect\",\n \"Intl\", \"URL\", \"FormData\", \"Headers\", \"Request\", \"Response\", \"AbortController\", \"HTMLElement\", \"SVGElement\",\n \"Event\", \"MouseEvent\", \"KeyboardEvent\", \"HTMLInputElement\", \"HTMLTextAreaElement\", \"HTMLSelectElement\",\n \"HTMLButtonElement\", \"HTMLDivElement\", \"HTMLFormElement\", \"Node\", \"Element\", \"Document\", \"Window\",\n \"Infinity\", \"NaN\", \"Fragment\",\n]);\n","/**\n * The FRAME half of a compile: a `TransformedGraph` + a `ScopeSpec` → a\n * component. No Babel. Each module runs once, through `new Function`, with\n * the flat scope as parameters and a `require` that resolves:\n * - a relative path → another file of the graph (`.tsx .ts .jsx .js .json`,\n * `/index.*`), evaluated once, cycles answered with the partial exports;\n * - a documented scope path in the spec → that entry's module view;\n * - anything else → a module whose PascalCase names are visible stand-ins.\n * Every name nothing supplies is recorded and returned (`unresolved`), and\n * reported once through `onUnresolved` under the caller's origin.\n */\nimport { resolveRelativeFile } from \"./gate\";\nimport { getScopeEntry } from \"./scope/entries\";\nimport {\n buildScopeState,\n patchMissingJsx,\n recordUnresolved,\n type ScopeState,\n} from \"./scope/build\";\nimport {\n createUnresolvedImportStandIn,\n describeUnresolved,\n extractJsxComponentIdentifiers,\n PATCH_SCOPE_SKIP_IDENTIFIERS,\n stripLiteralsForScan,\n} from \"./scope/stand-in\";\nimport type {\n CompileOptions,\n CompileResult,\n CompiledComponent,\n ScopeSpec,\n TransformedGraph,\n TransformedModule,\n UnresolvedImport,\n} from \"./types\";\n\ntype AnyRecord = Record<string, unknown>;\n\nconst IDENTIFIER_RE = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n\n/** A module for a path nothing supplies: every PascalCase name is a stand-in. */\nfunction missingModule(path: string): AnyRecord {\n const target: AnyRecord = { __esModule: true };\n return new Proxy(target, {\n get(t, prop) {\n if (typeof prop !== \"string\") return Reflect.get(t, prop);\n if (prop in t) return t[prop];\n if (prop === \"then\" || prop.startsWith(\"_\")) return undefined;\n if (prop === \"default\" || /^[A-Z]/.test(prop)) {\n const fallback = createUnresolvedImportStandIn(prop === \"default\" ? path.split(\"/\").pop() ?? path : prop, path);\n t[prop] = fallback;\n return fallback;\n }\n return undefined;\n },\n });\n}\n\n/**\n * THE IMPORT-BINDING CONTRACT, checked at link time: every value an import\n * names must exist. A missing PascalCase name becomes a visible stand-in in\n * the module view (so the element renders as a marked chip); every missing\n * name — any case — is recorded.\n */\nfunction bindImports(mod: TransformedModule, allFiles: Readonly<Record<string, string>>, state: ScopeState): void {\n for (const binding of mod.importBindings) {\n const { source, imported, local } = binding;\n if (source.startsWith(\"./\") || source.startsWith(\"../\")) {\n if (!resolveRelativeFile(allFiles, mod.file, source)) {\n recordUnresolved(state, { identifier: imported === \"*\" ? `* as ${local}` : imported, importPath: source });\n }\n continue;\n }\n const view = state.modules.get(source);\n if (!view) {\n recordUnresolved(state, {\n identifier: imported === \"*\" ? `* as ${local}` : imported === \"default\" ? local : imported,\n importPath: source,\n });\n continue;\n }\n if (imported === \"*\") continue;\n if (imported === \"default\") {\n if (view.default === undefined) {\n view.default = createUnresolvedImportStandIn(local, source);\n recordUnresolved(state, { identifier: local, importPath: source });\n }\n continue;\n }\n let present: boolean;\n try {\n present = view[imported] !== undefined;\n } catch {\n present = false;\n }\n if (!present) {\n if (/^[A-Z]/.test(imported)) view[imported] = createUnresolvedImportStandIn(imported, source);\n recordUnresolved(state, { identifier: imported === local ? local : `${imported} as ${local}`, importPath: source });\n }\n }\n}\n\nconst CONVENTIONAL_NAMES = /^(App|Main|Page|Component|Demo|Example|Root)$/;\n\nfunction pickCandidate(candidates: readonly string[], rule: CompileOptions[\"componentCandidate\"]): string | undefined {\n if (rule === \"conventional\") {\n const preferred = [...candidates].reverse().find((name) => CONVENTIONAL_NAMES.test(name));\n if (preferred) return preferred;\n }\n return candidates[candidates.length - 1];\n}\n\nfunction reportOnce(options: CompileOptions | undefined, unresolved: readonly UnresolvedImport[]): void {\n if (unresolved.length === 0) return;\n const origin = options?.origin ?? \"code-runtime\";\n if (options?.onUnresolved) {\n try {\n options.onUnresolved(origin, unresolved);\n } catch {\n // A broken reporter never breaks a compile.\n }\n return;\n }\n console.warn(`[code-runtime] ${origin}: ${unresolved.map(describeUnresolved).join(\", \")} could not be resolved; each renders as a marked placeholder.`);\n}\n\n/**\n * Link and evaluate a transformed graph. Never throws. `ok: false` carries\n * the evaluation error with the failing file named.\n */\nexport function executeGraph(graph: TransformedGraph, spec: ScopeSpec, options?: CompileOptions): CompileResult {\n const state = buildScopeState(spec);\n // An entry still loading blocks only when this code actually reaches for\n // it (imports it, or names one of its identifiers bare); otherwise the\n // compile proceeds without it and the load finishes in the background.\n const blocking = state.pending.filter((path) => {\n const entry = getScopeEntry(path);\n return Object.values(graph.modules).some(\n (m) =>\n m.importBindings.some((b) => b.source === path) ||\n (entry?.provides ?? []).some((id) => new RegExp(`(?<![\\\\w$.])${id.replace(/[$]/g, \"\\\\$\")}\\\\b`).test(m.code)),\n );\n });\n if (blocking.length > 0) {\n return {\n ok: false,\n error: {\n code: \"scope_not_ready\",\n message: `The scope entries ${blocking.join(\", \")} are still loading. Call prepareScope(spec) before compiling.`,\n retryable: true,\n },\n };\n }\n const fileSet = new Set(Object.keys(graph.modules));\n const allFiles = Object.fromEntries([...fileSet].map((f) => [f, \"\"]));\n for (const mod of Object.values(graph.modules)) bindImports(mod, allFiles, state);\n // Bare JSX references nothing supplies → stand-ins, per module (an author\n // declaration in any file of the graph does not hide a missing one in\n // another, so check each module against its own declarations).\n for (const mod of Object.values(graph.modules)) {\n const ids = extractJsxComponentIdentifiers(stripLiteralsForScan(mod.code));\n patchMissingJsx(ids, state, new Set(mod.declaredTopLevel), PATCH_SCOPE_SKIP_IDENTIFIERS);\n }\n\n const cache = new Map<string, { exports: AnyRecord; done: boolean }>();\n let current = graph.entry;\n\n const run = (file: string): AnyRecord => {\n const cached = cache.get(file);\n if (cached) return cached.exports;\n const mod = graph.modules[file];\n if (!mod) return missingModule(file);\n const module = { exports: {} as AnyRecord };\n const record = { exports: module.exports, done: false };\n cache.set(file, record);\n const declared = new Set(mod.declaredTopLevel);\n const paramNames = Object.keys(state.values).filter(\n (k) => IDENTIFIER_RE.test(k) && !k.startsWith(\"__\") && !declared.has(k) && k !== \"require\" && k !== \"module\" && k !== \"exports\",\n );\n const paramValues = paramNames.map((k) => state.values[k]);\n const requireFn = (specifier: string): unknown => {\n if (specifier.startsWith(\"./\") || specifier.startsWith(\"../\")) {\n const target = resolveRelativeFile(allFiles, file, specifier);\n if (!target) return missingModule(specifier);\n const prev = current;\n current = target;\n try {\n return run(target);\n } finally {\n current = prev;\n }\n }\n return state.modules.get(specifier) ?? missingModule(specifier);\n };\n const candidate = file === graph.entry ? pickCandidate(mod.componentCandidates, options?.componentCandidate) : undefined;\n const tail = candidate ? `\\n;return typeof ${candidate} !== \"undefined\" ? ${candidate} : undefined;` : \"\";\n // eslint-disable-next-line no-new-func\n const factory = new Function(...paramNames, \"require\", \"module\", \"exports\", `${mod.code}${tail}`);\n const returned: unknown = factory(...paramValues, requireFn, module, module.exports);\n if (module.exports !== record.exports) record.exports = module.exports;\n if (returned !== undefined && record.exports.default === undefined) {\n record.exports.__candidate = returned;\n }\n record.done = true;\n return record.exports;\n };\n\n try {\n const exportsOfEntry = run(graph.entry);\n const Component = (exportsOfEntry.default ?? exportsOfEntry.__candidate) as unknown;\n const unresolved = [...state.unresolved];\n reportOnce(options, unresolved);\n if (typeof Component !== \"function\" && !(Component && typeof Component === \"object\" && \"$$typeof\" in Component)) {\n return {\n ok: false,\n error: {\n code: \"no_component\",\n message:\n \"This code compiled but returned nothing to render. Export a React component as the default export of the entry file.\",\n retryable: false,\n diagnostic: graph.entry,\n },\n };\n }\n return {\n ok: true,\n Component: Component as CompiledComponent,\n unresolved: unresolved.map(describeUnresolved),\n unresolvedImports: unresolved,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return {\n ok: false,\n error: {\n code: \"evaluation_error\",\n message: fileSet.size > 1 ? `${current}: ${message}` : message,\n retryable: false,\n diagnostic: current,\n },\n };\n }\n}\n","/**\n * The PARENT half of a compile: source files → a `TransformedGraph` (plain\n * JSON). Babel lives only here. `@babel/standalone` is pure string → string\n * and executes nothing, so a sandbox frame receives this graph and runs\n * `execute` without ever loading Babel.\n *\n * Every file: React (classic runtime — the scope supplies `React`, there is no\n * module loader for an automatic JSX runtime) + TypeScript + CommonJS modules\n * in NON-strict mode, so the sloppy-mode bodies stored before multi-file\n * compiles behave exactly as before. Two collectors ride the same pass:\n * import specifiers (THE IMPORT-BINDING CONTRACT — validated at link time so a\n * name nothing supplies becomes a visible, reported stand-in) and top-level\n * bindings (kept out of the scope parameters, so an author's own `const Card`\n * shadows the injected scope instead of colliding with it).\n */\nimport { transform } from \"@babel/standalone\";\n\nimport type { ImportBinding, TransformResult, TransformedModule } from \"./types\";\n\ninterface ImportDeclarationPathLike {\n node: {\n importKind?: string;\n source: { value: string };\n specifiers: Array<{\n type: string;\n local: { name: string };\n importKind?: string;\n imported?: { name?: string; value?: string };\n }>;\n };\n}\n\ninterface ProgramPathLike {\n scope: { bindings: Record<string, { kind?: string } | undefined> };\n}\n\nfunction collectImportsPlugin(sink: ImportBinding[]) {\n return function collectImports() {\n return {\n name: \"code-runtime-collect-imports\",\n visitor: {\n ImportDeclaration(path: ImportDeclarationPathLike) {\n const { node } = path;\n if (node.importKind === \"type\") return;\n const source = node.source?.value ?? \"\";\n for (const specifier of node.specifiers ?? []) {\n if (specifier.importKind === \"type\") continue;\n const local = specifier.local?.name;\n if (!local) continue;\n if (specifier.type === \"ImportNamespaceSpecifier\") sink.push({ local, source, imported: \"*\" });\n else if (specifier.type === \"ImportDefaultSpecifier\") sink.push({ local, source, imported: \"default\" });\n else sink.push({ local, source, imported: specifier.imported?.name ?? specifier.imported?.value ?? local });\n }\n },\n },\n };\n };\n}\n\nfunction collectTopLevelPlugin(declared: Set<string>, candidates: string[]) {\n return function collectTopLevel() {\n return {\n name: \"code-runtime-collect-top-level\",\n visitor: {\n Program: {\n enter(path: ProgramPathLike) {\n for (const [name, binding] of Object.entries(path.scope.bindings)) {\n const kind = binding?.kind;\n if (kind === \"module\" || kind === \"param\") continue;\n declared.add(name);\n if (/^[A-Z]/.test(name)) candidates.push(name);\n }\n },\n },\n },\n };\n };\n}\n\nfunction languageOf(file: string): \"ts\" | \"tsx\" | \"jsx\" | \"js\" | \"json\" | \"text\" {\n const m = /\\.([a-z]+)$/i.exec(file);\n const ext = (m?.[1] ?? \"tsx\").toLowerCase();\n if (ext === \"ts\" || ext === \"mts\" || ext === \"cts\") return \"ts\";\n if (ext === \"tsx\") return \"tsx\";\n if (ext === \"jsx\") return \"jsx\";\n if (ext === \"js\" || ext === \"mjs\" || ext === \"cjs\") return \"js\";\n if (ext === \"json\") return \"json\";\n return \"text\";\n}\n\n/** Transform one file. Throws Babel's own error (with line) on bad syntax. */\nexport function transformModule(file: string, source: string): TransformedModule {\n const lang = languageOf(file);\n if (lang === \"json\") {\n JSON.parse(source);\n return { file, code: `module.exports = ${source};`, declaredTopLevel: [], componentCandidates: [], importBindings: [] };\n }\n if (lang === \"text\") {\n return { file, code: `module.exports = ${JSON.stringify(source)};`, declaredTopLevel: [], componentCandidates: [], importBindings: [] };\n }\n const declared = new Set<string>();\n const candidates: string[] = [];\n const importBindings: ImportBinding[] = [];\n // Babel's TypeScript preset decides JSX by extension; a stored single body\n // has no real filename, so it is always treated as .tsx (as before).\n const filename = lang === \"js\" ? file.replace(/\\.(m|c)?js$/i, \".jsx\") : file;\n const result = transform(source, {\n filename: /\\.[a-z]+$/i.test(filename) ? filename : `${filename}.tsx`,\n presets: [[\"react\", { runtime: \"classic\" }], \"typescript\"],\n plugins: [\n collectImportsPlugin(importBindings),\n collectTopLevelPlugin(declared, candidates),\n [\"transform-modules-commonjs\", { strictMode: false }],\n ],\n sourceType: \"module\",\n babelrc: false,\n configFile: false,\n } as Parameters<typeof transform>[1]);\n return {\n file,\n code: result?.code ?? \"\",\n declaredTopLevel: [...declared],\n componentCandidates: candidates,\n importBindings,\n };\n}\n\n/**\n * Transform a whole file graph. Never throws: a syntax error comes back as a\n * named error that says which file failed.\n */\nexport function transformFiles(files: Readonly<Record<string, string>>, entry: string): TransformResult {\n if (!Object.prototype.hasOwnProperty.call(files, entry)) {\n return {\n ok: false,\n error: { code: \"entry_missing\", message: `The entry file \"${entry}\" is not one of this component's files.`, retryable: false },\n };\n }\n const modules: Record<string, TransformedModule> = {};\n for (const [file, source] of Object.entries(files)) {\n try {\n modules[file] = transformModule(file, source ?? \"\");\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return {\n ok: false,\n error: {\n code: \"compile_error\",\n message: Object.keys(files).length > 1 ? `${file}: ${message}` : message,\n retryable: false,\n diagnostic: file,\n },\n };\n }\n }\n return { ok: true, graph: { entry, modules } };\n}\n","/**\n * `compile` (CONTRACTS §7): source files → a React component, in one call.\n * Transform (Babel) then execute (link + evaluate). Never throws.\n */\nimport { executeGraph } from \"./execute-core\";\nimport { prepareScopeModules } from \"./scope/modules\";\nimport { transformFiles } from \"./transform-core\";\nimport type { CompileOptions, CompileResult, ScopeSpec } from \"./types\";\n\nexport function compile(\n files: Readonly<Record<string, string>>,\n entry: string,\n scope: ScopeSpec,\n options?: CompileOptions,\n): CompileResult {\n const transformed = transformFiles(files, entry);\n if (!transformed.ok) return transformed;\n return executeGraph(transformed.graph, scope, options);\n}\n\n/** Load every async module a spec needs (e.g. recharts). Never rejects. */\nexport function prepareScope(spec: ScopeSpec): Promise<void> {\n return prepareScopeModules(spec.entries);\n}\n\n/** `prepareScope` then `compile`. */\nexport async function compileAsync(\n files: Readonly<Record<string, string>>,\n entry: string,\n scope: ScopeSpec,\n options?: CompileOptions,\n): Promise<CompileResult> {\n await prepareScope(scope);\n return compile(files, entry, scope, options);\n}\n\n/**\n * The single-body form every stored-component path uses today: one TSX\n * source, compiled as `component.tsx`.\n */\nexport function compileSource(code: string, scope: ScopeSpec, options?: CompileOptions): CompileResult {\n return compile({ \"component.tsx\": code }, \"component.tsx\", scope, options);\n}\n","/**\n * The compile cache: one compile per (id, version). A version bump (an edited\n * row) re-keys and recompiles; `invalidate(id)` drops every version of one id.\n * State is per cache instance; the shared default lives on `globalThis`.\n */\nimport type { CompileResult } from \"./types\";\n\nexport interface CompileCache {\n get(id: string, version: string | number | null | undefined, compileFn: () => CompileResult): CompileResult;\n peek(id: string, version: string | number | null | undefined): CompileResult | undefined;\n invalidate(id: string): void;\n clear(): void;\n readonly size: number;\n}\n\nexport function createCompileCache(): CompileCache {\n const entries = new Map<string, CompileResult>();\n const keyOf = (id: string, version: string | number | null | undefined) => `${id}\\u0000${version ?? \"\"}`;\n return {\n get(id, version, compileFn) {\n const key = keyOf(id, version);\n const hit = entries.get(key);\n if (hit) return hit;\n const result = compileFn();\n // A scope that was still loading is retryable — never cache it.\n if (result.ok || !result.error.retryable) entries.set(key, result);\n return result;\n },\n peek(id, version) {\n return entries.get(keyOf(id, version));\n },\n invalidate(id) {\n const prefix = `${id}\\u0000`;\n for (const key of [...entries.keys()]) if (key.startsWith(prefix)) entries.delete(key);\n },\n clear() {\n entries.clear();\n },\n get size() {\n return entries.size;\n },\n };\n}\n\nconst DEFAULT_KEY = Symbol.for(\"ai-matrx.code-runtime.cache\");\n\n/** The process-wide default cache. */\nexport function defaultCompileCache(): CompileCache {\n const g = globalThis as unknown as Record<symbol, CompileCache | undefined>;\n let cache = g[DEFAULT_KEY];\n if (!cache) {\n cache = createCompileCache();\n g[DEFAULT_KEY] = cache;\n }\n return cache;\n}\n","/**\n * The compiler every host injects into `@ai-matrx/content-ir-react`'s\n * DB-component cache (its `DbKindComponentCompiler` port). The render layer\n * keeps the compiler host-injected on purpose (security shape); this is the\n * one compiler hosts inject.\n */\nimport { compileSource } from \"./compile\";\nimport type { CompileOptions, CompiledComponent } from \"./types\";\n\nexport interface KindComponentCompilerOptions {\n /** Origin for unresolved-name reports (default `kind-component`). */\n origin?: () => string;\n onUnresolved?: CompileOptions[\"onUnresolved\"];\n /** Host replacements by scope name. */\n overrides?: Record<string, unknown>;\n}\n\n/**\n * Structurally `DbKindComponentCompiler`: `{ code, allowedImports }` in,\n * `{ Component | error }` out, never throws. Bodies in\n * `content_ir.kind_component` are organization-authored, so the dangerous\n * globals are always shadowed.\n */\nexport function kindComponentCompiler(options: KindComponentCompilerOptions = {}) {\n return (args: { code: string; allowedImports: string[] }): {\n Component: CompiledComponent | null;\n error: string | null;\n } => {\n if (!args.code || !args.code.trim()) return { Component: null, error: null };\n const compileOptions: CompileOptions = { origin: options.origin?.() ?? \"kind-component\" };\n if (options.onUnresolved) compileOptions.onUnresolved = options.onUnresolved;\n const result = compileSource(\n args.code,\n {\n entries: args.allowedImports,\n shadowDangerousGlobals: true,\n ...(options.overrides ? { overrides: options.overrides } : {}),\n },\n compileOptions,\n );\n return result.ok ? { Component: result.Component, error: null } : { Component: null, error: result.error.message };\n };\n}\n"],"mappings":";;;AAAA;AAAA,EACE,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAkB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AA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D;AAAA,MACA;AAAA,IACF;AACA,WAAO,OAAO,KAAK,EAAE,WAAW,OAAO,WAAW,OAAO,KAAK,IAAI,EAAE,WAAW,MAAM,OAAO,OAAO,MAAM,QAAQ;AAAA,EACnH;AACF;","names":["ReactModule","ReactModule"]}
|
|
1
|
+
{"version":3,"sources":["../src/gate-lists.json","../src/gate.ts","../src/scope/entries.ts","../src/scope/build.ts","../src/scope/modules.ts","../src/scope/stand-in.ts","../src/execute-core.ts","../src/transform-core.ts","../src/compile.ts","../src/cache.ts","../src/kind.ts"],"sourcesContent":["{\n \"_comment\": [\n \"CANONICAL, MACHINE-READABLE source-gate lists for stored code compiled by @ai-matrx/code-runtime.\",\n \"ONE list per rule, sorted, byte-comparable across runtimes. Three guards keep the copies honest:\",\n \" - src/gate.test.ts asserts allowedImports equals listScopeEntryPaths() sorted\",\n \" (the documented scope registry is the truth);\",\n \" - aidream packages/matrx-ai/tests/test_component_source_gate_parity.py asserts the Python\",\n \" twins in kind_shared.py equal these arrays;\",\n \" - the database trigger's parity test asserts the trigger names every entry of every\",\n \" security list below.\"\n ],\n \"allowedImports\": [\n \"@/applets\",\n \"@/components/Markdown\",\n \"@/components/MarkdownStream\",\n \"@/components/agent-copy/CopyButtons\",\n \"@/components/agent-copy/CopyForAiButton\",\n \"@/components/kind-kit/KindActionButton\",\n \"@/components/kind-kit/KindHeaderBar\",\n \"@/components/kind-kit/KindPanel\",\n \"@/components/kind-kit/KindPanelGrid\",\n \"@/components/kind-kit/SortableList\",\n \"@/components/kind-kit/StreamingSkeleton\",\n \"@/components/kind-kit/TagList\",\n \"@/components/mardown\",\n \"@/components/markdown\",\n \"@/components/official/icons/IconResolver\",\n \"@/components/ui/accordion\",\n \"@/components/ui/alert\",\n \"@/components/ui/avatar\",\n \"@/components/ui/badge\",\n \"@/components/ui/button\",\n \"@/components/ui/card\",\n \"@/components/ui/checkbox\",\n \"@/components/ui/collapsible\",\n \"@/components/ui/dialog\",\n \"@/components/ui/dropdown-menu\",\n \"@/components/ui/input\",\n \"@/components/ui/label\",\n \"@/components/ui/popover\",\n \"@/components/ui/progress\",\n \"@/components/ui/radio-group\",\n \"@/components/ui/scroll-area\",\n \"@/components/ui/select\",\n \"@/components/ui/separator\",\n \"@/components/ui/sheet\",\n \"@/components/ui/skeleton\",\n \"@/components/ui/slider\",\n \"@/components/ui/switch\",\n \"@/components/ui/table\",\n \"@/components/ui/tabs\",\n \"@/components/ui/textarea\",\n \"@/components/ui/tooltip\",\n \"@/lib/utils\",\n \"@ai-matrx/applets/react\",\n \"@ai-matrx/design-system\",\n \"@ai-matrx/design-system/controls\",\n \"@ai-matrx/icons\",\n \"@react-three/fiber\",\n \"date-fns\",\n \"lodash\",\n \"lucide-react\",\n \"motion/react\",\n \"react\",\n \"react-katex\",\n \"react-pdf\",\n \"recharts\",\n \"three\",\n \"xlsx\"\n ],\n \"bannedGlobals\": [\n \"EventSource\",\n \"WebSocket\",\n \"XMLHttpRequest\",\n \"fetch\",\n \"importScripts\",\n \"localStorage\",\n \"sessionStorage\"\n ],\n \"bannedCallables\": [\n \"Function\",\n \"eval\"\n ],\n \"bannedMemberAccess\": [\n \"EventSource\",\n \"Function\",\n \"WebSocket\",\n \"XMLHttpRequest\",\n \"cookie\",\n \"eval\",\n \"fetch\",\n \"importScripts\",\n \"sendBeacon\"\n ],\n \"bannedMemberCalls\": [\n \"constructor\"\n ],\n \"bannedComputedAccess\": [\n \"globalThis\",\n \"self\",\n \"window\"\n ],\n \"bannedSyntax\": [\n \"dynamicImport\"\n ]\n}\n","/**\n * `@ai-matrx/code-runtime/gate` — THE ONE source gate for stored code.\n *\n * Every writer of stored component code (kind components, tool and emit\n * renderers, Applet files) runs `gate(files)` before the write; a database\n * trigger is the backstop and aidream's `kind_shared.py` is the Python twin.\n * The lists are DATA in `gate-lists.json` (exported as\n * `@ai-matrx/code-runtime/gate-lists.json`) so all three runtimes compare the\n * same bytes; parity tests on each side read this file.\n *\n * Moved here verbatim in behavior from matrx-frontend\n * `features/agent-apps/utils/component-source-gate.ts` (Q82 / B-17, DD-124),\n * widened to multi-file sources: a relative import must name a file in the\n * set, and every finding carries its file and line.\n *\n * WHAT THIS IS NOT: a sandbox. A string check cannot stop every escape, and\n * the runtime stubs shadow bare identifiers only. Real isolation is the\n * sandbox frame (opaque origin, `connect-src 'none'`).\n *\n * Pure: no React, no Babel — safe for servers, workers and write paths.\n */\nimport lists from \"./gate-lists.json\";\nimport type { Finding } from \"./types\";\n\nexport type { Finding } from \"./types\";\n\n/** Every module stored code may import (the documented scope registry). */\nexport const GATE_ALLOWED_IMPORTS: readonly string[] = lists.allowedImports;\n/** Globals stored code may never name as a bare identifier. */\nexport const GATE_BANNED_GLOBALS: readonly string[] = lists.bannedGlobals;\n/** Evaluators banned where called or constructed (`eval(`, `new Function(`). */\nexport const GATE_BANNED_CALLABLES: readonly string[] = lists.bannedCallables;\n/** Names banned as a property read (`window.fetch`, `document.cookie`). */\nexport const GATE_BANNED_MEMBER_ACCESS: readonly string[] = lists.bannedMemberAccess;\n/** Names banned as a method call on any object (`.constructor(`). */\nexport const GATE_BANNED_MEMBER_CALLS: readonly string[] = lists.bannedMemberCalls;\n/** Roots on which bracket access is refused (`window[\"fet\"+\"ch\"]`). */\nexport const GATE_BANNED_COMPUTED_ACCESS: readonly string[] = lists.bannedComputedAccess;\n/** Named syntax rules every runtime implements (`dynamicImport`). */\nexport const GATE_BANNED_SYNTAX: readonly string[] = lists.bannedSyntax;\n\n/** The raw lists, for parity tests and the database trigger's generator. */\nexport const GATE_LISTS = lists;\n\nconst IMPORT_RE = /^\\s*import\\s+(?:[^'\"]*?\\s+from\\s+)?['\"]([^'\"]+)['\"]/gm;\nconst EXPORT_FROM_RE = /^\\s*export\\s+(?:\\*|\\{[^}]*\\})\\s+from\\s+['\"]([^'\"]+)['\"]/gm;\nconst DYNAMIC_IMPORT_RE = /(?<![.\\w$])import\\s*\\(/g;\n\nfunction escapeForRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction lineAt(source: string, index: number): number {\n let line = 1;\n for (let i = 0; i < index && i < source.length; i++) {\n if (source.charCodeAt(i) === 10) line++;\n }\n return line;\n}\n\n/** Normalize a relative specifier against the importing file, without extension guessing. */\nexport function resolveRelativePath(fromFile: string, specifier: string): string {\n const base = fromFile.split(\"/\").slice(0, -1);\n for (const part of specifier.split(\"/\")) {\n if (part === \"\" || part === \".\") continue;\n if (part === \"..\") base.pop();\n else base.push(part);\n }\n return base.join(\"/\");\n}\n\nconst RESOLVE_SUFFIXES = [\"\", \".tsx\", \".ts\", \".jsx\", \".js\", \".json\", \"/index.tsx\", \"/index.ts\", \"/index.jsx\", \"/index.js\"];\n\n/** The file in `files` a relative specifier names, or null. */\nexport function resolveRelativeFile(\n files: Readonly<Record<string, string>>,\n fromFile: string,\n specifier: string,\n): string | null {\n const target = resolveRelativePath(fromFile, specifier);\n for (const suffix of RESOLVE_SUFFIXES) {\n const candidate = `${target}${suffix}`;\n if (Object.prototype.hasOwnProperty.call(files, candidate)) return candidate;\n }\n return null;\n}\n\n/** The module paths a source imports, in source order, de-duplicated. */\nexport function importPaths(source: string): string[] {\n const found = new Set<string>();\n for (const re of [IMPORT_RE, EXPORT_FROM_RE]) {\n re.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = re.exec(source ?? \"\")) !== null) {\n if (match[1]) found.add(match[1]);\n }\n }\n return [...found];\n}\n\nconst ALLOWED_SENTENCE =\n \"Rewrite it using only the documented scope (react, lucide-react, recharts, \" +\n \"@ai-matrx/design-system/controls, @ai-matrx/design-system, @/lib/utils, \" +\n \"@/components/ui/*, @/components/kind-kit/*, CopyButtons/CopyForAiButton, Markdown) \" +\n \"or a file of this component.\";\n\nfunction importFindings(files: Readonly<Record<string, string>>, file: string, source: string): Finding[] {\n const out: Finding[] = [];\n const allowed = new Set(GATE_ALLOWED_IMPORTS);\n for (const re of [IMPORT_RE, EXPORT_FROM_RE]) {\n re.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = re.exec(source)) !== null) {\n const path = match[1] ?? \"\";\n const line = lineAt(source, match.index + match[0].indexOf(path));\n if (path.startsWith(\"./\") || path.startsWith(\"../\")) {\n if (!resolveRelativeFile(files, file, path)) {\n out.push({\n rule: \"relative-import-missing\",\n file,\n line,\n severity: \"refuse\",\n message: `This file imports \"${path}\", but no file of this component has that name. Add the file or fix the path.`,\n });\n }\n continue;\n }\n if (!allowed.has(path)) {\n out.push({\n rule: \"import-not-allowed\",\n file,\n line,\n severity: \"refuse\",\n message: `This component imports \"${path}\", which is outside the sandbox scope, so it would render as a marked placeholder. ${ALLOWED_SENTENCE}`,\n });\n }\n }\n }\n DYNAMIC_IMPORT_RE.lastIndex = 0;\n const dyn = DYNAMIC_IMPORT_RE.exec(source);\n if (dyn) {\n out.push({\n rule: \"dynamicImport\",\n file,\n line: lineAt(source, dyn.index),\n severity: \"refuse\",\n message:\n \"This component uses a dynamic import(). The in-page compiler has no module loader, so the call would either fail at render or reach code nobody vetted. Import from the scope at the top of the file instead.\",\n });\n }\n return out;\n}\n\nfunction bannedGlobalMessage(name: string): string {\n return (\n `This component uses \"${name}\", which components stored in the database may ` +\n \"not use. They run inside the signed-in page, so anything that reaches the \" +\n \"network, browser storage, or the JavaScript evaluator could read or send \" +\n \"the reader's data. Render what the Shape hands you in props.data and use \" +\n \"a Shape action for anything the component needs from the server.\"\n );\n}\n\nfunction bannedMemberCallMessage(name: string): string {\n return (\n `This component uses \".${name}(\", which components stored in the database ` +\n \"may not use. Calling a value's constructor reaches the JavaScript \" +\n \"evaluator, so it could run code nobody reviewed inside the signed-in \" +\n \"page. Write the logic out directly instead.\"\n );\n}\n\nfunction bannedComputedAccessMessage(name: string): string {\n return (\n `This component uses \"${name}[\", which components stored in the database ` +\n \"may not use. Looking a property up by a computed name hides which \" +\n \"browser capability the component reaches, so no review can tell whether \" +\n `it is safe. Name what you need directly, or use props.data and a Shape ` +\n \"action for anything the component needs from the server.\"\n );\n}\n\nfunction globalFindings(file: string, code: string): Finding[] {\n const out: Finding[] = [];\n const push = (rule: string, re: RegExp, message: string) => {\n const m = re.exec(code);\n if (m) out.push({ rule, file, line: lineAt(code, m.index), severity: \"refuse\", message });\n };\n for (const name of GATE_BANNED_GLOBALS) {\n push(\"bannedGlobal\", new RegExp(`(?<![.\\\\w$])${escapeForRegExp(name)}\\\\b`), bannedGlobalMessage(name));\n }\n for (const name of GATE_BANNED_CALLABLES) {\n const e = escapeForRegExp(name);\n push(\"bannedCallable\", new RegExp(`\\\\bnew\\\\s+${e}\\\\s*\\\\(|(?<![.\\\\w$])${e}\\\\s*\\\\(`), bannedGlobalMessage(name));\n }\n for (const name of GATE_BANNED_MEMBER_ACCESS) {\n push(\"bannedMemberAccess\", new RegExp(`\\\\.\\\\s*${escapeForRegExp(name)}\\\\b`), bannedGlobalMessage(name));\n }\n for (const name of GATE_BANNED_MEMBER_CALLS) {\n push(\"bannedMemberCall\", new RegExp(`\\\\.\\\\s*${escapeForRegExp(name)}\\\\s*\\\\(`), bannedMemberCallMessage(name));\n }\n for (const name of GATE_BANNED_COMPUTED_ACCESS) {\n const e = escapeForRegExp(name);\n push(\"bannedComputedAccess\", new RegExp(`(?<![.\\\\w$])${e}\\\\s*\\\\[|\\\\.\\\\s*${e}\\\\s*\\\\[`), bannedComputedAccessMessage(name));\n }\n return out;\n}\n\n/**\n * THE ONE GATE (CONTRACTS §7). Every finding names its file and line; any\n * `refuse` finding means the code may not be stored. `.html` files and\n * `.json` files are not compiled in the page and are skipped.\n */\nexport function gate(files: Readonly<Record<string, string>>): Finding[] {\n const out: Finding[] = [];\n for (const [file, source] of Object.entries(files)) {\n if (/\\.(html?|json|css|md)$/i.test(file)) continue;\n const code = source ?? \"\";\n out.push(...importFindings(files, file, code), ...globalFindings(file, code));\n }\n return out;\n}\n\n/**\n * The single-body form today's writers call: the first refusing sentence, or\n * null when the source may be stored. `flavor: \"html\"` bodies render in an\n * opaque-origin iframe and are not checked.\n */\nexport function componentSourceGate(source: string, options?: { flavor?: string | null }): string | null {\n if ((options?.flavor ?? \"\").toLowerCase() === \"html\") return null;\n const finding = gate({ \"component.tsx\": source ?? \"\" }).find((f) => f.severity === \"refuse\");\n return finding ? finding.message : null;\n}\n","/**\n * THE ONE DOCUMENTED SCOPE REGISTRY — every import path stored code may name.\n *\n * Merged from matrx-frontend's two registries (`agent-apps/utils/\n * allowed-imports.ts` and `dynamic-react/toolRendererScope.ts`), which\n * disagreed on strategies, lists and loading. Rules that hold:\n * - every entry is EXPLICITLY named and documented; no wildcard;\n * - nothing here reaches data: no database client, no fetch wrapper, no\n * store — data reach belongs to the host (CONTRACTS §1);\n * - an entry is `package`-owned (this package ships its module, so a plain\n * Vite page gets it) or `host`-owned (declared and documented here, the\n * module supplied by the host through `provideScopeModules`); a host entry\n * no host supplied renders named stand-ins and is reported, never crashes;\n * - `@/components/ui/*` are LEGACY ALIASES kept while stored code uses them\n * (census 2026-10-06: 67 kind components, 78 apps). Each names the same\n * design-system export the frontend file re-exports; new code imports\n * `@ai-matrx/design-system/controls` (the primary UI set).\n *\n * Pure data: no React, no module loads — `gate.ts` and servers read it.\n * `gate-lists.json#allowedImports` must equal `listScopeEntryPaths()` sorted\n * (guard: `scope-registry.test.ts`).\n */\n\nexport type ScopeStrategy = \"named\" | \"spread\" | \"namespace\";\n\nexport interface ScopeEntryDeclaration {\n /** The import path stored code writes. */\n path: string;\n /** `named`: listed exports; `spread`: every export; `namespace`: the module under `namespaceName`. */\n strategy: ScopeStrategy;\n exports?: readonly string[];\n /** moduleKey → scope name (`{ default: \"MarkdownStream\" }`). */\n exportMap?: Readonly<Record<string, string>>;\n namespaceName?: string;\n /** Missing PascalCase names resolve to a visible stand-in (icon sets). */\n safeProxy?: boolean;\n /** Always present for chat code blocks (cheap, already in shared chunks). */\n core?: boolean;\n /** Identifiers whose bare use implies this entry (heavy-lib demand detection). */\n provides?: readonly string[];\n owner: \"package\" | \"host\";\n description: string;\n}\n\nconst REACT_EXPORTS = [\n \"useState\", \"useEffect\", \"useMemo\", \"useCallback\", \"useRef\", \"useReducer\", \"useContext\",\n \"useId\", \"useTransition\", \"useDeferredValue\", \"useLayoutEffect\", \"Fragment\",\n] as const;\n\nfunction ui(\n name: string,\n exports: readonly string[],\n description: string,\n): ScopeEntryDeclaration {\n return { path: `@/components/ui/${name}`, strategy: \"named\", exports, core: true, owner: \"package\", description };\n}\n\nfunction markdownAlias(path: string, description: string): ScopeEntryDeclaration {\n return { path, strategy: \"named\", exportMap: { default: \"MarkdownStream\" }, core: true, owner: \"host\", description };\n}\n\nfunction kindKit(name: string, exports: readonly string[], description: string): ScopeEntryDeclaration {\n return { path: `@/components/kind-kit/${name}`, strategy: \"named\", exports, owner: \"package\", description };\n}\n\nexport const SCOPE_ENTRIES: readonly ScopeEntryDeclaration[] = [\n // ── Core ─────────────────────────────────────────────────────────────────\n { path: \"react\", strategy: \"named\", exports: REACT_EXPORTS, exportMap: { default: \"React\" }, core: true, owner: \"package\", description: \"React core (hooks, Fragment)\" },\n { path: \"lucide-react\", strategy: \"spread\", safeProxy: true, core: true, owner: \"package\", description: \"Lucide icons; a missing name renders a marked placeholder\" },\n { path: \"@ai-matrx/icons\", strategy: \"named\", exports: [\"DynamicIcon\", \"renderIcon\", \"getIconComponent\"], core: true, owner: \"package\", description: \"DynamicIcon: any icon by string name\" },\n { path: \"@/components/official/icons/IconResolver\", strategy: \"named\", exports: [\"DynamicIcon\", \"renderIcon\", \"getIconComponent\"], core: true, owner: \"package\", description: \"Legacy alias of @ai-matrx/icons\" },\n { path: \"@/lib/utils\", strategy: \"named\", exports: [\"cn\"], core: true, owner: \"package\", description: \"cn(): className merge\" },\n\n // ── The primary UI set ───────────────────────────────────────────────────\n { path: \"@ai-matrx/design-system/controls\", strategy: \"spread\", core: true, owner: \"package\", description: \"THE controls: Button, Field, SearchField, Select, SegmentedControl, Tabs, Badge, Switch, Textarea, EmptyState…\" },\n { path: \"@ai-matrx/design-system\", strategy: \"spread\", owner: \"package\", description: \"Design-system surfaces: Card, Dialog, Popover, Tooltip, Table, Accordion…\" },\n\n // ── Copy actions ─────────────────────────────────────────────────────────\n { path: \"@/components/agent-copy/CopyButtons\", strategy: \"named\", exports: [\"CopyButtons\"], owner: \"package\", description: \"Copy / Copy-for-AI / JSON / Export bar from caller-supplied builders (the kind-kit copy-bar slot: the host's own bar when registered, a plain Copy button otherwise)\" },\n { path: \"@/components/agent-copy/CopyForAiButton\", strategy: \"named\", exports: [\"CopyForAiButton\"], owner: \"host\", description: \"Single Copy-for-AI action\" },\n\n // ── kind-kit (@ai-matrx/content-ir-react/kind-kit; hosts register its copy\n // bar and read notices with setKindKitHost) ───────────────────────────\n kindKit(\"SortableList\", [\"SortableList\"], \"Drag-to-reorder list with arrow fallback and onRemove\"),\n kindKit(\"KindPanelGrid\", [\"KindPanelGrid\"], \"Content-aware auto-fit grid of equal-height panels\"),\n kindKit(\"KindPanel\", [\"KindPanel\"], \"Compact panel: header + overflow menu, subline, body, footer\"),\n kindKit(\"KindHeaderBar\", [\"KindHeaderBar\"], \"Kind title + stats + copy bar\"),\n kindKit(\"KindActionButton\", [\"KindActionButton\"], \"Button for the component's runAction prop: busy, optional confirm, inline error\"),\n kindKit(\"StreamingSkeleton\", [\"StreamingSkeleton\", \"useStreamingValue\", \"streamList\", \"streamText\"], \"Streaming skeletons + tolerant partial-value reads\"),\n kindKit(\"TagList\", [\"KeywordChip\", \"TagList\"], \"Wrapping chips with select, remove, inline edit, add\"),\n\n // ── Markdown (one renderer, four spellings stored code uses) ─────────────\n markdownAlias(\"@/components/MarkdownStream\", \"MarkdownStream: the one markdown renderer\"),\n markdownAlias(\"@/components/Markdown\", \"MarkdownStream (legacy path)\"),\n markdownAlias(\"@/components/markdown\", \"MarkdownStream (lowercase path)\"),\n markdownAlias(\"@/components/mardown\", \"MarkdownStream (common misspelling)\"),\n\n // ── Legacy UI aliases (each = the design-system export the app re-exports) ─\n ui(\"button\", [\"Button\"], \"Button\"),\n ui(\"input\", [\"Input\"], \"Input\"),\n ui(\"textarea\", [\"Textarea\"], \"Textarea\"),\n ui(\"card\", [\"Card\", \"CardAction\", \"CardContent\", \"CardDescription\", \"CardFooter\", \"CardHeader\", \"CardTitle\"], \"Card family\"),\n ui(\"label\", [\"Label\"], \"Label\"),\n ui(\"select\", [\"Select\", \"SelectContent\", \"SelectGroup\", \"SelectItem\", \"SelectLabel\", \"SelectScrollDownButton\", \"SelectScrollUpButton\", \"SelectSeparator\", \"SelectValue\", \"selectTriggerVariants\", \"SelectTrigger\", \"SelectTriggerLegacy\"], \"Select family\"),\n ui(\"slider\", [\"Slider\"], \"Slider\"),\n ui(\"switch\", [\"Switch\"], \"Switch\"),\n ui(\"tabs\", [\"Tabs\", \"TabsContent\", \"TabsList\", \"TabsTrigger\", \"TabsTriggerCore\", \"TabsListLegacy\", \"TabsTriggerLegacy\", \"TabsTriggerCoreLegacy\"], \"Tabs family\"),\n ui(\"badge\", [\"Badge\"], \"Badge\"),\n ui(\"tooltip\", [\"Tooltip\", \"TooltipContent\", \"TooltipProvider\", \"TooltipTrigger\"], \"Tooltip family\"),\n ui(\"accordion\", [\"Accordion\", \"AccordionContent\", \"AccordionItem\", \"AccordionTrigger\", \"useAccordionSize\"], \"Accordion family\"),\n ui(\"collapsible\", [\"Collapsible\", \"CollapsibleContent\", \"CollapsibleTrigger\"], \"Collapsible family\"),\n ui(\"progress\", [\"Progress\"], \"Progress bar\"),\n ui(\"separator\", [\"Separator\"], \"Separator\"),\n ui(\"scroll-area\", [\"ScrollArea\", \"ScrollBar\"], \"ScrollArea\"),\n ui(\"dialog\", [\"Dialog\", \"DialogClose\", \"DialogContent\", \"DialogContentPrimitive\", \"DialogDescription\", \"DialogFooter\", \"DialogHeader\", \"DialogOverlay\", \"DialogPortal\", \"DialogTitle\", \"DialogTrigger\", \"useDialogContainer\"], \"Dialog family\"),\n ui(\"sheet\", [\"Sheet\", \"SheetPortal\", \"SheetOverlay\", \"SheetTrigger\", \"SheetClose\", \"SheetContent\", \"SheetHeader\", \"SheetFooter\", \"SheetTitle\", \"SheetDescription\"], \"Sheet family\"),\n ui(\"dropdown-menu\", [\"DropdownMenu\", \"DropdownMenuCheckboxItem\", \"DropdownMenuContent\", \"DropdownMenuGroup\", \"DropdownMenuItem\", \"DropdownMenuLabel\", \"DropdownMenuPortal\", \"DropdownMenuRadioGroup\", \"DropdownMenuRadioItem\", \"DropdownMenuSeparator\", \"DropdownMenuShortcut\", \"DropdownMenuSub\", \"DropdownMenuSubContent\", \"DropdownMenuSubTrigger\", \"DropdownMenuTrigger\"], \"Dropdown menu family\"),\n ui(\"table\", [\"Table\", \"TableBody\", \"TableCaption\", \"TableCell\", \"TableFooter\", \"TableHead\", \"TableHeader\", \"TableRow\"], \"Table family\"),\n ui(\"checkbox\", [\"Checkbox\"], \"Checkbox\"),\n ui(\"radio-group\", [\"RadioGroup\", \"RadioGroupItem\"], \"Radio group\"),\n ui(\"popover\", [\"Popover\", \"PopoverTrigger\", \"PopoverContent\", \"PopoverAnchor\"], \"Popover family\"),\n ui(\"avatar\", [\"Avatar\", \"AvatarFallback\", \"AvatarImage\"], \"Avatar family\"),\n ui(\"alert\", [\"Alert\", \"AlertDescription\", \"AlertTitle\", \"alertVariants\"], \"Alert family\"),\n ui(\"skeleton\", [\"Skeleton\"], \"Skeleton\"),\n\n // ── Applet parts ─────────────────────────────────────────────────────────\n { path: \"@/applets\", strategy: \"named\", exports: [\"DataPage\", \"Applet\"], owner: \"host\", description: \"A table-built page and a nested Applet (legacy path; becomes @ai-matrx/applets/react)\" },\n { path: \"@ai-matrx/applets/react\", strategy: \"spread\", owner: \"host\", description: \"The Applet hooks: useRows, useJob, useValue, useAction, <Kind>, <Pages>, navigate…\" },\n\n // ── Heavy libraries (loaded only when referenced) ────────────────────────\n { path: \"recharts\", strategy: \"spread\", owner: \"package\", provides: [\"ResponsiveContainer\", \"LineChart\", \"BarChart\", \"AreaChart\", \"PieChart\", \"RadarChart\", \"ScatterChart\", \"ComposedChart\", \"RadialBarChart\"], description: \"Charts (recharts)\" },\n { path: \"motion/react\", strategy: \"spread\", owner: \"host\", provides: [\"motion\", \"AnimatePresence\", \"useAnimate\", \"useInView\"], description: \"Animation (motion)\" },\n { path: \"react-katex\", strategy: \"spread\", owner: \"host\", provides: [\"BlockMath\", \"InlineMath\"], description: \"Math typesetting (KaTeX)\" },\n { path: \"react-pdf\", strategy: \"named\", exports: [\"Document\", \"Page\", \"Outline\"], owner: \"host\", provides: [\"Document\", \"Page\", \"Outline\"], description: \"PDF viewing (react-pdf)\" },\n { path: \"xlsx\", strategy: \"namespace\", namespaceName: \"XLSX\", owner: \"host\", provides: [\"XLSX\"], description: \"Workbooks (xlsx)\" },\n { path: \"@react-three/fiber\", strategy: \"spread\", owner: \"host\", provides: [\"Canvas\", \"useFrame\", \"useThree\", \"useLoader\"], description: \"3D React renderer\" },\n { path: \"three\", strategy: \"namespace\", namespaceName: \"THREE\", owner: \"host\", provides: [\"THREE\"], description: \"3D engine (three.js)\" },\n { path: \"date-fns\", strategy: \"namespace\", namespaceName: \"dateFns\", owner: \"host\", provides: [\"dateFns\"], description: \"Date utilities (date-fns)\" },\n { path: \"lodash\", strategy: \"namespace\", namespaceName: \"_\", owner: \"host\", provides: [\"_\"], description: \"Utility helpers (lodash)\" },\n];\n\nconst BY_PATH = new Map(SCOPE_ENTRIES.map((e) => [e.path, e]));\n\nexport function getScopeEntry(path: string): ScopeEntryDeclaration | undefined {\n return BY_PATH.get(path);\n}\n\n/** Every documented path, in registry order. */\nexport function listScopeEntryPaths(): string[] {\n return SCOPE_ENTRIES.map((e) => e.path);\n}\n\n/** Every documented entry with its description (for builders, agents and docs). */\nexport function listScopeEntries(): readonly ScopeEntryDeclaration[] {\n return SCOPE_ENTRIES;\n}\n\n/**\n * The default scope for stored components (kind components, tool renderers,\n * Applets): everything except the heavy optional libraries, which are added\n * by demand detection. Order is spread precedence: later entries win.\n */\nexport function defaultComponentEntries(): string[] {\n return SCOPE_ENTRIES.filter((e) => !e.provides || e.path === \"recharts\").map((e) => e.path);\n}\n\n/** Paths always loaded for chat code blocks. */\nexport function coreEntryPaths(): string[] {\n return SCOPE_ENTRIES.filter((e) => e.core).map((e) => e.path);\n}\n\n/**\n * The entries a set of files needs: the core set, every documented path it\n * imports, and every heavy library whose identifiers it uses bare.\n */\nexport function detectEntries(files: Readonly<Record<string, string>>): string[] {\n const needed = new Set(coreEntryPaths());\n const code = Object.values(files).join(\"\\n\");\n const imported = new Set<string>();\n for (const m of code.matchAll(/from\\s+['\"]([^'\"]+)['\"]/g)) if (m[1]) imported.add(m[1]);\n for (const entry of SCOPE_ENTRIES) {\n if (entry.core) continue;\n if (imported.has(entry.path)) needed.add(entry.path);\n else if (entry.provides?.some((id) => new RegExp(`(?<![\\\\w$.])${id.replace(/[$]/g, \"\\\\$\")}\\\\b`).test(code))) {\n needed.add(entry.path);\n }\n }\n return SCOPE_ENTRIES.map((e) => e.path).filter((p) => needed.has(p));\n}\n","/**\n * Building a compile's scope: the flat values passed as function parameters\n * (so bodies that use `useState` or an icon without importing it keep\n * working) and the per-path module views `require` hands out.\n *\n * Behavior ported from matrx-frontend `allowed-imports.ts`\n * (`buildComponentScope`, `bindImportedIdentifiers`, the safe proxy) and\n * `toolRendererScope.ts` (namespace entries), collapsed into one builder.\n */\nimport * as ReactModule from \"react\";\n\nimport lists from \"../gate-lists.json\";\nimport type { ScopeSpec, UnresolvedImport } from \"../types\";\nimport { getScopeEntry, type ScopeEntryDeclaration } from \"./entries\";\nimport { announceFailedModule, readScopeModule } from \"./modules\";\nimport { createUnresolvedImportStandIn, readUnresolvedImportMark } from \"./stand-in\";\n\ntype AnyRecord = Record<string, unknown>;\n\nexport interface ScopeState {\n /** Flat scope: name → value (the function parameters). */\n values: AnyRecord;\n /** path → the module object `require(path)` returns. */\n modules: Map<string, AnyRecord>;\n /** Paths whose missing PascalCase names resolve to stand-ins. */\n safeProxyPaths: Map<string, { proxy: AnyRecord; keys: Set<string> }>;\n unresolved: UnresolvedImport[];\n /** Entries whose async module is not loaded yet (`prepareScope` first). */\n pending: string[];\n}\n\nexport function recordUnresolved(state: Pick<ScopeState, \"unresolved\">, entry: UnresolvedImport): void {\n if (!state.unresolved.some((e) => e.identifier === entry.identifier && e.importPath === entry.importPath)) {\n state.unresolved.push(entry);\n }\n}\n\nfunction asRecord(value: unknown): AnyRecord {\n return value && (typeof value === \"object\" || typeof value === \"function\") ? (value as AnyRecord) : {};\n}\n\nfunction ownKeys(mod: AnyRecord): string[] {\n try {\n return Object.keys(mod);\n } catch {\n return [];\n }\n}\n\n/** Missing PascalCase keys → a visible stand-in (icon sets). */\nfunction createSafeModuleProxy(importPath: string, moduleExports: AnyRecord, state: Pick<ScopeState, \"unresolved\">): AnyRecord {\n const target: AnyRecord = { ...moduleExports, __esModule: true };\n return new Proxy(target, {\n get(t, prop) {\n if (typeof prop !== \"string\") return Reflect.get(t, prop);\n if (prop in t) return t[prop];\n if (prop.startsWith(\"_\") || prop === \"default\" || prop === \"then\") return undefined;\n if (/^[A-Z]/.test(prop)) {\n const fallback = createUnresolvedImportStandIn(prop, importPath);\n t[prop] = fallback;\n recordUnresolved(state, { identifier: prop, importPath });\n return fallback;\n }\n return undefined;\n },\n has(t, prop) {\n if (typeof prop === \"string\" && /^[A-Z]/.test(prop)) return true;\n return prop in t;\n },\n });\n}\n\n/** The module object `require(path)` answers for one loaded entry. */\nfunction moduleView(entry: ScopeEntryDeclaration, mod: AnyRecord, state: Pick<ScopeState, \"unresolved\">): AnyRecord {\n if (entry.strategy === \"namespace\") {\n const ns = asRecord(mod.default ?? mod);\n return { ...ns, default: ns, __esModule: true };\n }\n if (entry.safeProxy) return createSafeModuleProxy(entry.path, mod, state);\n const view: AnyRecord = { ...mod, __esModule: true };\n for (const [moduleKey, scopeKey] of Object.entries(entry.exportMap ?? {})) {\n const value = moduleKey === \"default\" ? (mod.default ?? mod) : mod[moduleKey];\n view[scopeKey] = value;\n if (moduleKey === \"default\") view.default = value;\n }\n // A module with no default export has no default: `import X from` it is\n // reported and stands in (link time), never silently the module object.\n if (!(\"default\" in view)) view.default = mod.default;\n return view;\n}\n\nfunction applyToFlatScope(entry: ScopeEntryDeclaration, mod: AnyRecord, values: AnyRecord): void {\n if (entry.strategy === \"namespace\") {\n if (entry.namespaceName) values[entry.namespaceName] = mod.default ?? mod;\n return;\n }\n if (entry.strategy === \"spread\") {\n for (const key of ownKeys(mod)) {\n if (key === \"default\" || key === \"__esModule\") continue;\n // A spread NEVER shadows a JavaScript or DOM global: lucide exports\n // icons named Map, File, Image, Text, Infinity…, and injecting them\n // as bare parameters turned `new Map()` into \"Map is not a\n // constructor\". A global-named export still reaches code that imports\n // it, and a bare JSX use of it is bound at link time (patchMissingJsx).\n if (key in globalThis) continue;\n values[key] = mod[key];\n }\n return;\n }\n for (const name of entry.exports ?? []) values[name] = mod[name];\n for (const [moduleKey, scopeKey] of Object.entries(entry.exportMap ?? {})) {\n values[scopeKey] = moduleKey === \"default\" ? (mod.default ?? mod) : mod[moduleKey];\n }\n}\n\n/**\n * Throwing stubs for the globals stored code may not use. Named error, never\n * silence: the reader's error boundary shows which global it reached for.\n * BACKSTOP, not a sandbox — bare identifiers only; `window.fetch` still\n * resolves. The write-time gate refuses `window.fetch`; the sandbox frame is\n * the real boundary.\n */\nexport function buildDangerousGlobalStubs(): AnyRecord {\n const stubs: AnyRecord = {};\n for (const name of [...lists.bannedGlobals, ...lists.bannedCallables]) {\n stubs[name] = function bannedGlobal(): never {\n throw new Error(\n `This component tried to use \"${name}\". Components stored in the ` +\n \"database run inside the signed-in page and may not reach the \" +\n \"network, browser storage, or the JavaScript evaluator. Render what \" +\n \"the Shape hands you in props.data, and use a Shape action for \" +\n \"anything you need from the server.\",\n );\n };\n }\n return stubs;\n}\n\n/** Build the full scope state for a spec. Never throws. */\nexport function buildScopeState(spec: ScopeSpec): ScopeState {\n const state: ScopeState = { values: {}, modules: new Map(), safeProxyPaths: new Map(), unresolved: [], pending: [] };\n const R = ReactModule as unknown as AnyRecord;\n // React core is always present (classic JSX needs `React`).\n state.values.React = R;\n for (const hook of [\"useState\", \"useEffect\", \"useMemo\", \"useCallback\", \"useRef\"]) state.values[hook] = R[hook];\n state.modules.set(\"react\", { ...R, default: R, __esModule: true });\n\n for (const path of spec.entries ?? []) {\n const entry = getScopeEntry(path);\n if (!entry) {\n recordUnresolved(state, { identifier: \"*\", importPath: path });\n continue;\n }\n const read = readScopeModule(path);\n if (read.state === \"pending\") {\n state.pending.push(path);\n continue;\n }\n if (read.state === \"missing\") {\n // A host-owned entry this host did not supply: nothing to report until\n // code reaches for it (an import of it, or a bare name, is recorded then).\n continue;\n }\n if (read.state === \"failed\") {\n // Announced once per page (loud), and a gap only for code that reaches\n // for it — an import of it, or a bare name, is recorded at link time.\n announceFailedModule(path, read.message);\n continue;\n }\n const mod = asRecord(read.module);\n const view = moduleView(entry, mod, state);\n state.modules.set(path, view);\n if (entry.safeProxy) {\n state.safeProxyPaths.set(path, { proxy: view, keys: new Set(ownKeys(mod)) });\n }\n applyToFlatScope(entry, mod, state.values);\n }\n\n if (state.values.MarkdownStream && !state.values.Markdown) state.values.Markdown = state.values.MarkdownStream;\n if (!state.values.DynamicIcon) {\n const icons = readScopeModule(\"@ai-matrx/icons\");\n if (icons.state === \"ready\") {\n const m = asRecord(icons.module);\n state.values.DynamicIcon = m.DynamicIcon;\n state.values.renderIcon = m.renderIcon;\n state.values.getIconComponent = m.getIconComponent;\n }\n }\n const overrides = spec.overrides ?? {};\n Object.assign(state.values, overrides);\n // An override replaces the NAME everywhere code can reach it — the flat\n // scope and every module view that exports it (named, or as its mapped\n // default), so `import Md from \"@/components/MarkdownStream\"` gets the\n // host's runtime-aware renderer too.\n if (Object.keys(overrides).length > 0) {\n for (const [path, view] of state.modules) {\n const entry = getScopeEntry(path);\n for (const [moduleKey, scopeKey] of Object.entries(entry?.exportMap ?? {})) {\n if (!(scopeKey in overrides)) continue;\n view[scopeKey] = overrides[scopeKey];\n if (moduleKey === \"default\") view.default = overrides[scopeKey];\n else view[moduleKey] = overrides[scopeKey];\n }\n for (const name of entry?.exports ?? []) {\n if (name in overrides) view[name] = overrides[name];\n }\n }\n }\n if (spec.shadowDangerousGlobals) Object.assign(state.values, buildDangerousGlobalStubs());\n return state;\n}\n\n/**\n * `buildScope` (CONTRACTS §7): the named, documented values a spec puts in\n * scope. Async entries not yet prepared are absent (see `prepareScope`).\n */\nexport function buildScope(spec: ScopeSpec): Record<string, unknown> {\n return { ...buildScopeState(spec).values };\n}\n\n/**\n * A stand-in for every bare JSX reference no scope value, module export or\n * author declaration supplies. Each is recorded.\n */\nexport function patchMissingJsx(\n identifiers: Iterable<string>,\n state: ScopeState,\n declared: ReadonlySet<string>,\n skip: ReadonlySet<string>,\n): void {\n for (const identifier of identifiers) {\n if (identifier in state.values || declared.has(identifier)) continue;\n // A name a spread module (an icon set) exports, used as a JSX ELEMENT, is\n // that export even when it shares a global's name (`<Map />` is the icon;\n // `new Map()` elsewhere in the same file would then need the icon imported\n // under another name). Anything else on the skip list is left alone.\n const providedBySpread = [...state.safeProxyPaths.values()].some(({ keys }) => keys.has(identifier));\n if (skip.has(identifier) && !providedBySpread) continue;\n let provided = false;\n for (const [, { proxy, keys }] of state.safeProxyPaths) {\n if (!keys.has(identifier)) continue;\n const value = proxy[identifier];\n if (value !== undefined) {\n state.values[identifier] = value;\n const mark = readUnresolvedImportMark(value);\n if (mark) recordUnresolved(state, mark);\n provided = true;\n break;\n }\n }\n if (provided) continue;\n state.values[identifier] = createUnresolvedImportStandIn(identifier);\n recordUnresolved(state, { identifier, importPath: null });\n }\n}\n","/**\n * Where each scope entry's MODULE comes from.\n *\n * Package-owned entries load modules this package ships (so a plain Vite page\n * needs nothing else); host-owned entries are supplied by the host with\n * `provideScopeModules`. A host may also replace a package-owned module (the\n * web app hands its own `@/components/ui/*` files so stored code renders\n * exactly as the app does). Loaders may be sync or async; async ones are\n * resolved by `prepareScope` before a compile.\n *\n * State lives on `globalThis` under a `Symbol.for` key — never module state —\n * so duplicated bundles and the ESM/CJS boundary share one registry.\n */\nimport * as ReactModule from \"react\";\nimport * as LucideModule from \"lucide-react\";\nimport * as IconsModule from \"@ai-matrx/icons\";\nimport * as DesignSystem from \"@ai-matrx/design-system\";\nimport * as Controls from \"@ai-matrx/design-system/controls\";\nimport * as KindKit from \"@ai-matrx/content-ir-react/kind-kit\";\n\nimport { getScopeEntry } from \"./entries\";\n\nexport type ScopeModuleLoader = () => unknown;\n\ninterface ModuleStore {\n announced: Set<string>;\n provided: Map<string, ScopeModuleLoader>;\n loaded: Map<string, unknown>;\n pending: Map<string, Promise<unknown>>;\n failed: Map<string, string>;\n}\n\nconst STORE_KEY = Symbol.for(\"ai-matrx.code-runtime.modules\");\n\nfunction store(): ModuleStore {\n const g = globalThis as unknown as Record<symbol, ModuleStore | undefined>;\n let s = g[STORE_KEY];\n if (!s) {\n s = { announced: new Set(), provided: new Map(), loaded: new Map(), pending: new Map(), failed: new Map() };\n g[STORE_KEY] = s;\n }\n return s;\n}\n\nconst ds = DesignSystem as unknown as Record<string, unknown>;\nconst controls = Controls as unknown as Record<string, unknown>;\n\n/**\n * The legacy `@/components/ui/*` aliases resolve to the design system the\n * same way the web app's own files do (button, textarea, switch, the select\n * trigger and the tabs bar come from `/controls`; the rest — Input included —\n * from the root).\n */\nconst LEGACY_UI_MODULE: Record<string, unknown> = {\n ...ds,\n Button: controls.Button,\n Textarea: controls.Textarea,\n Switch: controls.Switch,\n SelectTrigger: controls.SelectTrigger,\n SelectTriggerLegacy: ds.SelectTrigger,\n TabsList: controls.TabsList,\n TabsTrigger: controls.TabsTrigger,\n TabsListLegacy: ds.TabsList,\n TabsTriggerLegacy: ds.TabsTrigger,\n};\n\nconst COPY_BUTTONS_MODULE = {\n CopyButtons: (props: Parameters<typeof KindKit.DefaultCopyButtons>[0]) =>\n ReactModule.createElement(KindKit.getKindKitHost().CopyButtons, props),\n};\n\nfunction packageLoader(path: string): ScopeModuleLoader | null {\n if (path === \"react\") return () => ReactModule;\n if (path === \"lucide-react\") return () => LucideModule;\n if (path === \"@ai-matrx/icons\" || path === \"@/components/official/icons/IconResolver\") return () => IconsModule;\n if (path === \"@ai-matrx/design-system\") return () => DesignSystem;\n if (path === \"@ai-matrx/design-system/controls\") return () => Controls;\n if (path === \"@/lib/utils\") return () => ({ cn: ds.cn });\n if (path.startsWith(\"@/components/ui/\")) return () => LEGACY_UI_MODULE;\n if (path.startsWith(\"@/components/kind-kit/\")) return () => KindKit;\n // ONE copy-bar slot: kind-kit's. The host registers its own bar there\n // (setKindKitHost); without one, the kit's honest default renders.\n if (path === \"@/components/agent-copy/CopyButtons\") return () => COPY_BUTTONS_MODULE;\n if (path === \"recharts\") return () => import(\"recharts\");\n return null;\n}\n\n/**\n * Supply (or replace) the modules for scope entries. Keys must be documented\n * registry paths; an unknown key throws, because a module nobody documented\n * is exactly the reach the registry exists to prevent.\n */\nexport function provideScopeModules(map: Readonly<Record<string, ScopeModuleLoader>>): void {\n const s = store();\n for (const [path, loader] of Object.entries(map)) {\n if (!getScopeEntry(path)) {\n throw new Error(\n `[code-runtime] \"${path}\" is not a documented scope entry. Add it to the registry in @ai-matrx/code-runtime (scope/entries.ts) with a description first.`,\n );\n }\n s.provided.set(path, loader);\n s.loaded.delete(path);\n s.pending.delete(path);\n s.failed.delete(path);\n }\n}\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return !!value && typeof (value as { then?: unknown }).then === \"function\";\n}\n\nfunction loaderFor(path: string): ScopeModuleLoader | null {\n return store().provided.get(path) ?? packageLoader(path);\n}\n\nexport type ModuleState =\n | { state: \"ready\"; module: unknown }\n | { state: \"pending\" }\n | { state: \"missing\" }\n | { state: \"failed\"; message: string };\n\n/** Synchronously read a module, starting an async load when needed. */\nexport function readScopeModule(path: string): ModuleState {\n const s = store();\n if (s.loaded.has(path)) return { state: \"ready\", module: s.loaded.get(path) };\n const failed = s.failed.get(path);\n if (failed) return { state: \"failed\", message: failed };\n if (s.pending.has(path)) return { state: \"pending\" };\n const loader = loaderFor(path);\n if (!loader) return { state: \"missing\" };\n try {\n const value = loader();\n if (isPromiseLike(value)) {\n const promise = Promise.resolve(value).then(\n (mod) => {\n s.loaded.set(path, mod);\n s.pending.delete(path);\n return mod;\n },\n (err: unknown) => {\n s.failed.set(path, err instanceof Error ? err.message : String(err));\n s.pending.delete(path);\n return undefined;\n },\n );\n s.pending.set(path, promise);\n return { state: \"pending\" };\n }\n s.loaded.set(path, value);\n return { state: \"ready\", module: value };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n s.failed.set(path, message);\n return { state: \"failed\", message };\n }\n}\n\n/** Resolve every async module the given entries need. Never rejects. */\nexport async function prepareScopeModules(paths: readonly string[]): Promise<void> {\n const s = store();\n for (const path of paths) readScopeModule(path);\n await Promise.all(paths.map((p) => s.pending.get(p)).filter((p): p is Promise<unknown> => !!p));\n}\n\n/** A scope module that failed to load — one console error per path per page, never silence. */\nexport function announceFailedModule(path: string, message: string): void {\n const s = store();\n if (s.announced.has(path)) return;\n s.announced.add(path);\n console.error(`[code-runtime] The scope entry \"${path}\" failed to load (${message}); code that imports it renders marked placeholders.`);\n}\n\n/** Test seam: forget every provided and loaded module. */\nexport function resetScopeModules(): void {\n const s = store();\n s.announced.clear();\n s.provided.clear();\n s.loaded.clear();\n s.pending.clear();\n s.failed.clear();\n}\n","/**\n * NOTHING FAILS SILENTLY. Stored code that names something the scope cannot\n * supply still renders — one bad import must not blank a whole display — but\n * the gap is SHOWN where it sits: a compact dashed chip carrying the missing\n * name (tooltip: the import path), with the element's children rendered after\n * it. Moved verbatim from matrx-frontend\n * `features/agent-apps/utils/patch-scope-identifiers.ts`; the mark symbol is\n * unchanged (`Symbol.for`) so stand-ins made by either copy are recognised.\n */\nimport * as React from \"react\";\n\nimport type { UnresolvedImport } from \"../types\";\n\nconst UNRESOLVED_IMPORT_MARK = Symbol.for(\"matrx.sandbox.unresolvedImport\");\n\n/** The stand-in's own record, or null when `value` is a real binding. */\nexport function readUnresolvedImportMark(value: unknown): UnresolvedImport | null {\n if (!value || (typeof value !== \"object\" && typeof value !== \"function\")) return null;\n const mark = (value as Record<symbol, unknown>)[UNRESOLVED_IMPORT_MARK];\n return mark && typeof mark === \"object\" ? (mark as UnresolvedImport) : null;\n}\n\nexport function createUnresolvedImportStandIn(\n identifier: string,\n importPath: string | null = null,\n): React.ForwardRefExoticComponent<{ children?: React.ReactNode } & React.RefAttributes<HTMLSpanElement>> {\n const tip = importPath ? `Not found: ${identifier} in \"${importPath}\"` : `Not found: ${identifier}`;\n const StandIn = React.forwardRef<HTMLSpanElement, { children?: React.ReactNode }>(({ children }, ref) => {\n const chip = React.createElement(\n \"span\",\n {\n ref,\n title: tip,\n \"aria-label\": tip,\n role: \"note\",\n \"data-unresolved-import\": identifier,\n \"data-import-path\": importPath ?? undefined,\n className:\n \"inline-flex items-center gap-0.5 rounded border border-dashed border-destructive/60 px-1 align-middle font-mono text-[10px] leading-4 text-destructive\",\n },\n React.createElement(\n \"svg\",\n {\n width: 10,\n height: 10,\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n stroke: \"currentColor\",\n strokeWidth: 2.5,\n strokeLinecap: \"round\",\n strokeLinejoin: \"round\",\n \"aria-hidden\": true,\n },\n React.createElement(\"path\", { d: \"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" }),\n React.createElement(\"line\", { x1: 12, y1: 9, x2: 12, y2: 13 }),\n React.createElement(\"line\", { x1: 12, y1: 17, x2: 12.01, y2: 17 }),\n ),\n identifier,\n );\n return children == null ? chip : React.createElement(React.Fragment, null, chip, children);\n });\n StandIn.displayName = `UnresolvedImport(${identifier})`;\n Object.defineProperty(StandIn, UNRESOLVED_IMPORT_MARK, {\n value: { identifier, importPath } satisfies UnresolvedImport,\n enumerable: false,\n });\n return StandIn;\n}\n\n/** One readable line per unresolved name. */\nexport function describeUnresolved(entry: UnresolvedImport): string {\n if (entry.identifier === \"*\") return `\"${entry.importPath}\" (not in this scope)`;\n return entry.importPath ? `${entry.identifier} from \"${entry.importPath}\"` : entry.identifier;\n}\n\nexport function stripLiteralsForScan(code: string): string {\n return code\n .replace(/\"(?:[^\"\\\\]|\\\\.)*\"/g, '\"\"')\n .replace(/'(?:[^'\\\\]|\\\\.)*'/g, \"''\")\n .replace(/`(?:[^`\\\\]|\\\\.)*`/gs, \"``\");\n}\n\n/** PascalCase identifiers used as JSX element types after the transform. */\nexport function extractJsxComponentIdentifiers(codeForScanning: string): Set<string> {\n const components = new Set<string>();\n const patterns = [\n // `(?![\\w$.])`: `<C.Button>` names the namespace `C`, which is an\n // import or a declaration, never a bare missing component.\n /React\\.createElement\\s*\\(\\s*([A-Z][a-zA-Z0-9]*)(?![\\w$.])/g,\n /\\.default\\.createElement\\s*\\(\\s*([A-Z][a-zA-Z0-9]*)(?![\\w$.])/g,\n /\\bjsxs?\\s*\\(\\s*([A-Z][a-zA-Z0-9]*)(?![\\w$.])/g,\n ];\n for (const pattern of patterns) {\n let match: RegExpExecArray | null;\n while ((match = pattern.exec(codeForScanning)) !== null) {\n if (match[1]) components.add(match[1]);\n }\n }\n return components;\n}\n\n/** Globals and built-ins never patched. */\nexport const PATCH_SCOPE_SKIP_IDENTIFIERS: ReadonlySet<string> = new Set([\n \"React\", \"Object\", \"Array\", \"String\", \"Number\", \"Boolean\", \"Date\", \"Math\", \"JSON\", \"Promise\", \"Error\",\n \"TypeError\", \"RangeError\", \"RegExp\", \"Map\", \"Set\", \"WeakMap\", \"WeakSet\", \"Symbol\", \"Proxy\", \"Reflect\",\n \"Intl\", \"URL\", \"FormData\", \"Headers\", \"Request\", \"Response\", \"AbortController\", \"HTMLElement\", \"SVGElement\",\n \"Event\", \"MouseEvent\", \"KeyboardEvent\", \"HTMLInputElement\", \"HTMLTextAreaElement\", \"HTMLSelectElement\",\n \"HTMLButtonElement\", \"HTMLDivElement\", \"HTMLFormElement\", \"Node\", \"Element\", \"Document\", \"Window\",\n \"Infinity\", \"NaN\", \"Fragment\",\n]);\n","/**\n * The FRAME half of a compile: a `TransformedGraph` + a `ScopeSpec` → a\n * component. No Babel. Each module runs once, through `new Function`, with\n * the flat scope as parameters and a `require` that resolves:\n * - a relative path → another file of the graph (`.tsx .ts .jsx .js .json`,\n * `/index.*`), evaluated once, cycles answered with the partial exports;\n * - a documented scope path in the spec → that entry's module view;\n * - anything else → a module whose PascalCase names are visible stand-ins.\n * Every name nothing supplies is recorded and returned (`unresolved`), and\n * reported once through `onUnresolved` under the caller's origin.\n */\nimport { resolveRelativeFile } from \"./gate\";\nimport { getScopeEntry } from \"./scope/entries\";\nimport {\n buildScopeState,\n patchMissingJsx,\n recordUnresolved,\n type ScopeState,\n} from \"./scope/build\";\nimport {\n createUnresolvedImportStandIn,\n describeUnresolved,\n extractJsxComponentIdentifiers,\n PATCH_SCOPE_SKIP_IDENTIFIERS,\n stripLiteralsForScan,\n} from \"./scope/stand-in\";\nimport type {\n CompileOptions,\n CompileResult,\n CompiledComponent,\n ScopeSpec,\n TransformedGraph,\n TransformedModule,\n UnresolvedImport,\n} from \"./types\";\n\ntype AnyRecord = Record<string, unknown>;\n\nconst IDENTIFIER_RE = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n\n/** A module for a path nothing supplies: every PascalCase name is a stand-in. */\nfunction missingModule(path: string): AnyRecord {\n const target: AnyRecord = { __esModule: true };\n return new Proxy(target, {\n get(t, prop) {\n if (typeof prop !== \"string\") return Reflect.get(t, prop);\n if (prop in t) return t[prop];\n if (prop === \"then\" || prop.startsWith(\"_\")) return undefined;\n if (prop === \"default\" || /^[A-Z]/.test(prop)) {\n const fallback = createUnresolvedImportStandIn(prop === \"default\" ? path.split(\"/\").pop() ?? path : prop, path);\n t[prop] = fallback;\n return fallback;\n }\n return undefined;\n },\n });\n}\n\n/**\n * THE IMPORT-BINDING CONTRACT, checked at link time: every value an import\n * names must exist. A missing PascalCase name becomes a visible stand-in in\n * the module view (so the element renders as a marked chip); every missing\n * name — any case — is recorded.\n */\nfunction bindImports(mod: TransformedModule, allFiles: Readonly<Record<string, string>>, state: ScopeState): void {\n for (const binding of mod.importBindings) {\n const { source, imported, local } = binding;\n if (source.startsWith(\"./\") || source.startsWith(\"../\")) {\n if (!resolveRelativeFile(allFiles, mod.file, source)) {\n recordUnresolved(state, { identifier: imported === \"*\" ? `* as ${local}` : imported, importPath: source });\n }\n continue;\n }\n const view = state.modules.get(source);\n if (!view) {\n recordUnresolved(state, {\n identifier: imported === \"*\" ? `* as ${local}` : imported === \"default\" ? local : imported,\n importPath: source,\n });\n continue;\n }\n if (imported === \"*\") continue;\n if (imported === \"default\") {\n if (view.default === undefined) {\n view.default = createUnresolvedImportStandIn(local, source);\n recordUnresolved(state, { identifier: local, importPath: source });\n }\n continue;\n }\n let present: boolean;\n try {\n present = view[imported] !== undefined;\n } catch {\n present = false;\n }\n if (!present && state.values[imported] !== undefined) {\n // The old compiler's rule, which stored code relies on: a named import\n // the module does not export resolves to the same name from another\n // scope entry (`import { KindPanelGrid } from \"…/kind-kit/KindPanel\"`).\n view[imported] = state.values[imported];\n present = true;\n }\n if (!present) {\n if (/^[A-Z]/.test(imported)) view[imported] = createUnresolvedImportStandIn(imported, source);\n recordUnresolved(state, { identifier: imported === local ? local : `${imported} as ${local}`, importPath: source });\n }\n }\n}\n\nconst CONVENTIONAL_NAMES = /^(App|Main|Page|Component|Demo|Example|Root)$/;\n\nfunction pickCandidate(candidates: readonly string[], rule: CompileOptions[\"componentCandidate\"]): string | undefined {\n if (rule === \"conventional\") {\n const preferred = [...candidates].reverse().find((name) => CONVENTIONAL_NAMES.test(name));\n if (preferred) return preferred;\n }\n return candidates[candidates.length - 1];\n}\n\nfunction reportOnce(options: CompileOptions | undefined, unresolved: readonly UnresolvedImport[]): void {\n if (unresolved.length === 0) return;\n const origin = options?.origin ?? \"code-runtime\";\n if (options?.onUnresolved) {\n try {\n options.onUnresolved(origin, unresolved);\n } catch {\n // A broken reporter never breaks a compile.\n }\n return;\n }\n console.warn(`[code-runtime] ${origin}: ${unresolved.map(describeUnresolved).join(\", \")} could not be resolved; each renders as a marked placeholder.`);\n}\n\n/**\n * Link and evaluate a transformed graph. Never throws. `ok: false` carries\n * the evaluation error with the failing file named.\n */\nexport function executeGraph(graph: TransformedGraph, spec: ScopeSpec, options?: CompileOptions): CompileResult {\n const state = buildScopeState(spec);\n // An entry still loading blocks only when this code actually reaches for\n // it (imports it, or names one of its identifiers bare); otherwise the\n // compile proceeds without it and the load finishes in the background.\n const blocking = state.pending.filter((path) => {\n const entry = getScopeEntry(path);\n return Object.values(graph.modules).some(\n (m) =>\n m.importBindings.some((b) => b.source === path) ||\n (entry?.provides ?? []).some((id) => new RegExp(`(?<![\\\\w$.])${id.replace(/[$]/g, \"\\\\$\")}\\\\b`).test(m.code)),\n );\n });\n if (blocking.length > 0) {\n return {\n ok: false,\n error: {\n code: \"scope_not_ready\",\n message: `The scope entries ${blocking.join(\", \")} are still loading. Call prepareScope(spec) before compiling.`,\n retryable: true,\n },\n };\n }\n const fileSet = new Set(Object.keys(graph.modules));\n const allFiles = Object.fromEntries([...fileSet].map((f) => [f, \"\"]));\n for (const mod of Object.values(graph.modules)) bindImports(mod, allFiles, state);\n // Bare JSX references nothing supplies → stand-ins, per module (an author\n // declaration in any file of the graph does not hide a missing one in\n // another, so check each module against its own declarations).\n for (const mod of Object.values(graph.modules)) {\n const ids = extractJsxComponentIdentifiers(stripLiteralsForScan(mod.code));\n patchMissingJsx(ids, state, new Set(mod.declaredTopLevel), PATCH_SCOPE_SKIP_IDENTIFIERS);\n }\n\n const cache = new Map<string, { exports: AnyRecord; done: boolean }>();\n let current = graph.entry;\n\n const run = (file: string): AnyRecord => {\n const cached = cache.get(file);\n if (cached) return cached.exports;\n const mod = graph.modules[file];\n if (!mod) return missingModule(file);\n const module = { exports: {} as AnyRecord };\n const record = { exports: module.exports, done: false };\n cache.set(file, record);\n const declared = new Set(mod.declaredTopLevel);\n const paramNames = Object.keys(state.values).filter(\n (k) => IDENTIFIER_RE.test(k) && !k.startsWith(\"__\") && !declared.has(k) && k !== \"require\" && k !== \"module\" && k !== \"exports\",\n );\n const paramValues = paramNames.map((k) => state.values[k]);\n const requireFn = (specifier: string): unknown => {\n if (specifier.startsWith(\"./\") || specifier.startsWith(\"../\")) {\n const target = resolveRelativeFile(allFiles, file, specifier);\n if (!target) return missingModule(specifier);\n const prev = current;\n current = target;\n try {\n return run(target);\n } finally {\n current = prev;\n }\n }\n return state.modules.get(specifier) ?? missingModule(specifier);\n };\n const candidate = file === graph.entry ? pickCandidate(mod.componentCandidates, options?.componentCandidate) : undefined;\n const tail = candidate ? `\\n;return typeof ${candidate} !== \"undefined\" ? ${candidate} : undefined;` : \"\";\n // eslint-disable-next-line no-new-func\n const factory = new Function(...paramNames, \"require\", \"module\", \"exports\", `${mod.code}${tail}`);\n const returned: unknown = factory(...paramValues, requireFn, module, module.exports);\n if (module.exports !== record.exports) record.exports = module.exports;\n if (returned !== undefined && record.exports.default === undefined) {\n record.exports.__candidate = returned;\n }\n record.done = true;\n return record.exports;\n };\n\n try {\n const exportsOfEntry = run(graph.entry);\n const Component = (exportsOfEntry.default ?? exportsOfEntry.__candidate) as unknown;\n const unresolved = [...state.unresolved];\n reportOnce(options, unresolved);\n if (typeof Component !== \"function\" && !(Component && typeof Component === \"object\" && \"$$typeof\" in Component)) {\n return {\n ok: false,\n error: {\n code: \"no_component\",\n message:\n \"This code compiled but returned nothing to render. Export a React component as the default export of the entry file.\",\n retryable: false,\n diagnostic: graph.entry,\n },\n };\n }\n return {\n ok: true,\n Component: Component as CompiledComponent,\n unresolved: unresolved.map(describeUnresolved),\n unresolvedImports: unresolved,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return {\n ok: false,\n error: {\n code: \"evaluation_error\",\n message: fileSet.size > 1 ? `${current}: ${message}` : message,\n retryable: false,\n diagnostic: current,\n },\n };\n }\n}\n","/**\n * The PARENT half of a compile: source files → a `TransformedGraph` (plain\n * JSON). Babel lives only here. `@babel/standalone` is pure string → string\n * and executes nothing, so a sandbox frame receives this graph and runs\n * `execute` without ever loading Babel.\n *\n * Every file: React (classic runtime — the scope supplies `React`, there is no\n * module loader for an automatic JSX runtime) + TypeScript + CommonJS modules\n * in NON-strict mode, so the sloppy-mode bodies stored before multi-file\n * compiles behave exactly as before. Two collectors ride the same pass:\n * import specifiers (THE IMPORT-BINDING CONTRACT — validated at link time so a\n * name nothing supplies becomes a visible, reported stand-in) and top-level\n * bindings (kept out of the scope parameters, so an author's own `const Card`\n * shadows the injected scope instead of colliding with it).\n */\nimport { transform } from \"@babel/standalone\";\n\nimport type { ImportBinding, TransformResult, TransformedModule } from \"./types\";\n\ninterface ImportDeclarationPathLike {\n node: {\n importKind?: string;\n source: { value: string };\n specifiers: Array<{\n type: string;\n local: { name: string };\n importKind?: string;\n imported?: { name?: string; value?: string };\n }>;\n };\n}\n\ninterface ProgramPathLike {\n scope: { bindings: Record<string, { kind?: string } | undefined> };\n}\n\nfunction collectImportsPlugin(sink: ImportBinding[]) {\n return function collectImports() {\n return {\n name: \"code-runtime-collect-imports\",\n visitor: {\n ImportDeclaration(path: ImportDeclarationPathLike) {\n const { node } = path;\n if (node.importKind === \"type\") return;\n const source = node.source?.value ?? \"\";\n for (const specifier of node.specifiers ?? []) {\n if (specifier.importKind === \"type\") continue;\n const local = specifier.local?.name;\n if (!local) continue;\n if (specifier.type === \"ImportNamespaceSpecifier\") sink.push({ local, source, imported: \"*\" });\n else if (specifier.type === \"ImportDefaultSpecifier\") sink.push({ local, source, imported: \"default\" });\n else sink.push({ local, source, imported: specifier.imported?.name ?? specifier.imported?.value ?? local });\n }\n },\n },\n };\n };\n}\n\nfunction collectTopLevelPlugin(declared: Set<string>, candidates: string[]) {\n return function collectTopLevel() {\n return {\n name: \"code-runtime-collect-top-level\",\n visitor: {\n Program: {\n enter(path: ProgramPathLike) {\n for (const [name, binding] of Object.entries(path.scope.bindings)) {\n const kind = binding?.kind;\n if (kind === \"module\" || kind === \"param\") continue;\n declared.add(name);\n if (/^[A-Z]/.test(name)) candidates.push(name);\n }\n },\n },\n },\n };\n };\n}\n\nfunction languageOf(file: string): \"ts\" | \"tsx\" | \"jsx\" | \"js\" | \"json\" | \"text\" {\n const m = /\\.([a-z]+)$/i.exec(file);\n const ext = (m?.[1] ?? \"tsx\").toLowerCase();\n if (ext === \"ts\" || ext === \"mts\" || ext === \"cts\") return \"ts\";\n if (ext === \"tsx\") return \"tsx\";\n if (ext === \"jsx\") return \"jsx\";\n if (ext === \"js\" || ext === \"mjs\" || ext === \"cjs\") return \"js\";\n if (ext === \"json\") return \"json\";\n return \"text\";\n}\n\n/** Transform one file. Throws Babel's own error (with line) on bad syntax. */\nexport function transformModule(file: string, source: string): TransformedModule {\n const lang = languageOf(file);\n if (lang === \"json\") {\n JSON.parse(source);\n return { file, code: `module.exports = ${source};`, declaredTopLevel: [], componentCandidates: [], importBindings: [] };\n }\n if (lang === \"text\") {\n return { file, code: `module.exports = ${JSON.stringify(source)};`, declaredTopLevel: [], componentCandidates: [], importBindings: [] };\n }\n const declared = new Set<string>();\n const candidates: string[] = [];\n const importBindings: ImportBinding[] = [];\n // Babel's TypeScript preset decides JSX by extension; a stored single body\n // has no real filename, so it is always treated as .tsx (as before).\n const filename = lang === \"js\" ? file.replace(/\\.(m|c)?js$/i, \".jsx\") : file;\n const result = transform(source, {\n filename: /\\.[a-z]+$/i.test(filename) ? filename : `${filename}.tsx`,\n presets: [[\"react\", { runtime: \"classic\" }], \"typescript\"],\n plugins: [\n collectImportsPlugin(importBindings),\n collectTopLevelPlugin(declared, candidates),\n [\"transform-modules-commonjs\", { strictMode: false }],\n ],\n sourceType: \"module\",\n babelrc: false,\n configFile: false,\n } as Parameters<typeof transform>[1]);\n return {\n file,\n code: result?.code ?? \"\",\n declaredTopLevel: [...declared],\n componentCandidates: candidates,\n importBindings,\n };\n}\n\n/**\n * Transform a whole file graph. Never throws: a syntax error comes back as a\n * named error that says which file failed.\n */\nexport function transformFiles(files: Readonly<Record<string, string>>, entry: string): TransformResult {\n if (!Object.prototype.hasOwnProperty.call(files, entry)) {\n return {\n ok: false,\n error: { code: \"entry_missing\", message: `The entry file \"${entry}\" is not one of this component's files.`, retryable: false },\n };\n }\n const modules: Record<string, TransformedModule> = {};\n for (const [file, source] of Object.entries(files)) {\n try {\n modules[file] = transformModule(file, source ?? \"\");\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return {\n ok: false,\n error: {\n code: \"compile_error\",\n message: Object.keys(files).length > 1 ? `${file}: ${message}` : message,\n retryable: false,\n diagnostic: file,\n },\n };\n }\n }\n return { ok: true, graph: { entry, modules } };\n}\n","/**\n * `compile` (CONTRACTS §7): source files → a React component, in one call.\n * Transform (Babel) then execute (link + evaluate). Never throws.\n */\nimport { executeGraph } from \"./execute-core\";\nimport { prepareScopeModules } from \"./scope/modules\";\nimport { transformFiles } from \"./transform-core\";\nimport type { CompileOptions, CompileResult, ScopeSpec } from \"./types\";\n\nexport function compile(\n files: Readonly<Record<string, string>>,\n entry: string,\n scope: ScopeSpec,\n options?: CompileOptions,\n): CompileResult {\n const transformed = transformFiles(files, entry);\n if (!transformed.ok) return transformed;\n return executeGraph(transformed.graph, scope, options);\n}\n\n/** Load every async module a spec needs (e.g. recharts). Never rejects. */\nexport function prepareScope(spec: ScopeSpec): Promise<void> {\n return prepareScopeModules(spec.entries);\n}\n\n/** `prepareScope` then `compile`. */\nexport async function compileAsync(\n files: Readonly<Record<string, string>>,\n entry: string,\n scope: ScopeSpec,\n options?: CompileOptions,\n): Promise<CompileResult> {\n await prepareScope(scope);\n return compile(files, entry, scope, options);\n}\n\n/**\n * The single-body form every stored-component path uses today: one TSX\n * source, compiled as `component.tsx`.\n */\nexport function compileSource(code: string, scope: ScopeSpec, options?: CompileOptions): CompileResult {\n return compile({ \"component.tsx\": code }, \"component.tsx\", scope, options);\n}\n","/**\n * The compile cache: one compile per (id, version). A version bump (an edited\n * row) re-keys and recompiles; `invalidate(id)` drops every version of one id.\n * State is per cache instance; the shared default lives on `globalThis`.\n */\nimport type { CompileResult } from \"./types\";\n\nexport interface CompileCache {\n get(id: string, version: string | number | null | undefined, compileFn: () => CompileResult): CompileResult;\n peek(id: string, version: string | number | null | undefined): CompileResult | undefined;\n invalidate(id: string): void;\n clear(): void;\n readonly size: number;\n}\n\nexport function createCompileCache(): CompileCache {\n const entries = new Map<string, CompileResult>();\n const keyOf = (id: string, version: string | number | null | undefined) => `${id}\\u0000${version ?? \"\"}`;\n return {\n get(id, version, compileFn) {\n const key = keyOf(id, version);\n const hit = entries.get(key);\n if (hit) return hit;\n const result = compileFn();\n // A scope that was still loading is retryable — never cache it.\n if (result.ok || !result.error.retryable) entries.set(key, result);\n return result;\n },\n peek(id, version) {\n return entries.get(keyOf(id, version));\n },\n invalidate(id) {\n const prefix = `${id}\\u0000`;\n for (const key of [...entries.keys()]) if (key.startsWith(prefix)) entries.delete(key);\n },\n clear() {\n entries.clear();\n },\n get size() {\n return entries.size;\n },\n };\n}\n\nconst DEFAULT_KEY = Symbol.for(\"ai-matrx.code-runtime.cache\");\n\n/** The process-wide default cache. */\nexport function defaultCompileCache(): CompileCache {\n const g = globalThis as unknown as Record<symbol, CompileCache | undefined>;\n let cache = g[DEFAULT_KEY];\n if (!cache) {\n cache = createCompileCache();\n g[DEFAULT_KEY] = cache;\n }\n return cache;\n}\n","/**\n * The compiler every host injects into `@ai-matrx/content-ir-react`'s\n * DB-component cache (its `DbKindComponentCompiler` port). The render layer\n * keeps the compiler host-injected on purpose (security shape); this is the\n * one compiler hosts inject.\n */\nimport { compileSource } from \"./compile\";\nimport type { CompileOptions, CompiledComponent } from \"./types\";\n\nexport interface KindComponentCompilerOptions {\n /** Origin for unresolved-name reports (default `kind-component`). */\n origin?: () => string;\n onUnresolved?: CompileOptions[\"onUnresolved\"];\n /** Host replacements by scope name. */\n overrides?: Record<string, unknown>;\n}\n\n/**\n * Structurally `DbKindComponentCompiler`: `{ code, allowedImports }` in,\n * `{ Component | error }` out, never throws. Bodies in\n * `content_ir.kind_component` are organization-authored, so the dangerous\n * globals are always shadowed.\n */\nexport function kindComponentCompiler(options: KindComponentCompilerOptions = {}) {\n return (args: { code: string; allowedImports: string[] }): {\n Component: CompiledComponent | null;\n error: string | null;\n } => {\n if (!args.code || !args.code.trim()) return { Component: null, error: null };\n const compileOptions: CompileOptions = { origin: options.origin?.() ?? \"kind-component\" };\n if (options.onUnresolved) compileOptions.onUnresolved = options.onUnresolved;\n const result = compileSource(\n args.code,\n {\n entries: args.allowedImports,\n shadowDangerousGlobals: true,\n ...(options.overrides ? { overrides: options.overrides } : {}),\n },\n compileOptions,\n );\n return result.ok ? { Component: result.Component, error: null } : { Component: null, error: result.error.message };\n };\n}\n"],"mappings":";;;AAAA;AAAA,EACE,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,gBAAkB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,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AAAA,IACF;AACA,WAAO,OAAO,KAAK,EAAE,WAAW,OAAO,WAAW,OAAO,KAAK,IAAI,EAAE,WAAW,MAAM,OAAO,OAAO,MAAM,QAAQ;AAAA,EACnH;AACF;","names":["ReactModule","ReactModule"]}
|
package/dist/scope.cjs
CHANGED
|
@@ -70,6 +70,7 @@ var gate_lists_default = {
|
|
|
70
70
|
"@/components/MarkdownStream",
|
|
71
71
|
"@/components/agent-copy/CopyButtons",
|
|
72
72
|
"@/components/agent-copy/CopyForAiButton",
|
|
73
|
+
"@/components/kind-kit/KindActionButton",
|
|
73
74
|
"@/components/kind-kit/KindHeaderBar",
|
|
74
75
|
"@/components/kind-kit/KindPanel",
|
|
75
76
|
"@/components/kind-kit/KindPanelGrid",
|
|
@@ -181,7 +182,7 @@ function markdownAlias(path, description) {
|
|
|
181
182
|
return { path, strategy: "named", exportMap: { default: "MarkdownStream" }, core: true, owner: "host", description };
|
|
182
183
|
}
|
|
183
184
|
function kindKit(name, exports, description) {
|
|
184
|
-
return { path: `@/components/kind-kit/${name}`, strategy: "named", exports, owner: "
|
|
185
|
+
return { path: `@/components/kind-kit/${name}`, strategy: "named", exports, owner: "package", description };
|
|
185
186
|
}
|
|
186
187
|
var SCOPE_ENTRIES = [
|
|
187
188
|
// ── Core ─────────────────────────────────────────────────────────────────
|
|
@@ -194,13 +195,15 @@ var SCOPE_ENTRIES = [
|
|
|
194
195
|
{ path: "@ai-matrx/design-system/controls", strategy: "spread", core: true, owner: "package", description: "THE controls: Button, Field, SearchField, Select, SegmentedControl, Tabs, Badge, Switch, Textarea, EmptyState\u2026" },
|
|
195
196
|
{ path: "@ai-matrx/design-system", strategy: "spread", owner: "package", description: "Design-system surfaces: Card, Dialog, Popover, Tooltip, Table, Accordion\u2026" },
|
|
196
197
|
// ── Copy actions ─────────────────────────────────────────────────────────
|
|
197
|
-
{ path: "@/components/agent-copy/CopyButtons", strategy: "named", exports: ["CopyButtons"], owner: "
|
|
198
|
+
{ path: "@/components/agent-copy/CopyButtons", strategy: "named", exports: ["CopyButtons"], owner: "package", description: "Copy / Copy-for-AI / JSON / Export bar from caller-supplied builders (the kind-kit copy-bar slot: the host's own bar when registered, a plain Copy button otherwise)" },
|
|
198
199
|
{ path: "@/components/agent-copy/CopyForAiButton", strategy: "named", exports: ["CopyForAiButton"], owner: "host", description: "Single Copy-for-AI action" },
|
|
199
|
-
// ── kind-kit
|
|
200
|
+
// ── kind-kit (@ai-matrx/content-ir-react/kind-kit; hosts register its copy
|
|
201
|
+
// bar and read notices with setKindKitHost) ───────────────────────────
|
|
200
202
|
kindKit("SortableList", ["SortableList"], "Drag-to-reorder list with arrow fallback and onRemove"),
|
|
201
203
|
kindKit("KindPanelGrid", ["KindPanelGrid"], "Content-aware auto-fit grid of equal-height panels"),
|
|
202
204
|
kindKit("KindPanel", ["KindPanel"], "Compact panel: header + overflow menu, subline, body, footer"),
|
|
203
205
|
kindKit("KindHeaderBar", ["KindHeaderBar"], "Kind title + stats + copy bar"),
|
|
206
|
+
kindKit("KindActionButton", ["KindActionButton"], "Button for the component's runAction prop: busy, optional confirm, inline error"),
|
|
204
207
|
kindKit("StreamingSkeleton", ["StreamingSkeleton", "useStreamingValue", "streamList", "streamText"], "Streaming skeletons + tolerant partial-value reads"),
|
|
205
208
|
kindKit("TagList", ["KeywordChip", "TagList"], "Wrapping chips with select, remove, inline edit, add"),
|
|
206
209
|
// ── Markdown (one renderer, four spellings stored code uses) ─────────────
|
|
@@ -286,6 +289,7 @@ var LucideModule = __toESM(require("lucide-react"), 1);
|
|
|
286
289
|
var IconsModule = __toESM(require("@ai-matrx/icons"), 1);
|
|
287
290
|
var DesignSystem = __toESM(require("@ai-matrx/design-system"), 1);
|
|
288
291
|
var Controls = __toESM(require("@ai-matrx/design-system/controls"), 1);
|
|
292
|
+
var KindKit = __toESM(require("@ai-matrx/content-ir-react/kind-kit"), 1);
|
|
289
293
|
var STORE_KEY = /* @__PURE__ */ Symbol.for("ai-matrx.code-runtime.modules");
|
|
290
294
|
function store() {
|
|
291
295
|
const g = globalThis;
|
|
@@ -310,6 +314,9 @@ var LEGACY_UI_MODULE = {
|
|
|
310
314
|
TabsListLegacy: ds.TabsList,
|
|
311
315
|
TabsTriggerLegacy: ds.TabsTrigger
|
|
312
316
|
};
|
|
317
|
+
var COPY_BUTTONS_MODULE = {
|
|
318
|
+
CopyButtons: (props) => ReactModule.createElement(KindKit.getKindKitHost().CopyButtons, props)
|
|
319
|
+
};
|
|
313
320
|
function packageLoader(path) {
|
|
314
321
|
if (path === "react") return () => ReactModule;
|
|
315
322
|
if (path === "lucide-react") return () => LucideModule;
|
|
@@ -318,6 +325,8 @@ function packageLoader(path) {
|
|
|
318
325
|
if (path === "@ai-matrx/design-system/controls") return () => Controls;
|
|
319
326
|
if (path === "@/lib/utils") return () => ({ cn: ds.cn });
|
|
320
327
|
if (path.startsWith("@/components/ui/")) return () => LEGACY_UI_MODULE;
|
|
328
|
+
if (path.startsWith("@/components/kind-kit/")) return () => KindKit;
|
|
329
|
+
if (path === "@/components/agent-copy/CopyButtons") return () => COPY_BUTTONS_MODULE;
|
|
321
330
|
if (path === "recharts") return () => import("recharts");
|
|
322
331
|
return null;
|
|
323
332
|
}
|
|
@@ -510,6 +519,7 @@ function applyToFlatScope(entry, mod, values) {
|
|
|
510
519
|
if (entry.strategy === "spread") {
|
|
511
520
|
for (const key of ownKeys(mod)) {
|
|
512
521
|
if (key === "default" || key === "__esModule") continue;
|
|
522
|
+
if (key in globalThis) continue;
|
|
513
523
|
values[key] = mod[key];
|
|
514
524
|
}
|
|
515
525
|
return;
|