@ai-matrx/alchemy 0.6.2 → 0.8.2

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.
Files changed (113) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/actions.cjs +374 -0
  3. package/dist/actions.cjs.map +1 -0
  4. package/dist/actions.d.cts +773 -0
  5. package/dist/actions.d.ts +773 -0
  6. package/dist/actions.js +351 -0
  7. package/dist/actions.js.map +1 -0
  8. package/dist/checks.cjs +31 -2
  9. package/dist/checks.cjs.map +1 -1
  10. package/dist/checks.d.cts +24 -1
  11. package/dist/checks.d.ts +24 -1
  12. package/dist/checks.js +31 -2
  13. package/dist/checks.js.map +1 -1
  14. package/dist/core.cjs +1757 -2
  15. package/dist/core.cjs.map +1 -1
  16. package/dist/core.d.cts +595 -1
  17. package/dist/core.d.ts +595 -1
  18. package/dist/core.js +1749 -2
  19. package/dist/core.js.map +1 -1
  20. package/dist/declare.cjs +12 -10
  21. package/dist/declare.cjs.map +1 -1
  22. package/dist/declare.d.cts +18 -2
  23. package/dist/declare.d.ts +18 -2
  24. package/dist/declare.js +12 -10
  25. package/dist/declare.js.map +1 -1
  26. package/dist/index.cjs +1757 -2
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +595 -1
  29. package/dist/index.d.ts +595 -1
  30. package/dist/index.js +1749 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/menu.cjs +436 -0
  33. package/dist/menu.cjs.map +1 -0
  34. package/dist/menu.d.cts +834 -0
  35. package/dist/menu.d.ts +834 -0
  36. package/dist/menu.js +413 -0
  37. package/dist/menu.js.map +1 -0
  38. package/dist/operate-document.cjs +163 -0
  39. package/dist/operate-document.cjs.map +1 -0
  40. package/dist/operate-document.d.cts +132 -0
  41. package/dist/operate-document.d.ts +132 -0
  42. package/dist/operate-document.js +130 -0
  43. package/dist/operate-document.js.map +1 -0
  44. package/dist/operate-rich-html.cjs +129 -0
  45. package/dist/operate-rich-html.cjs.map +1 -0
  46. package/dist/operate-rich-html.d.cts +136 -0
  47. package/dist/operate-rich-html.d.ts +136 -0
  48. package/dist/operate-rich-html.js +96 -0
  49. package/dist/operate-rich-html.js.map +1 -0
  50. package/dist/operate-server.cjs +157 -0
  51. package/dist/operate-server.cjs.map +1 -0
  52. package/dist/operate-server.d.cts +183 -0
  53. package/dist/operate-server.d.ts +183 -0
  54. package/dist/operate-server.js +134 -0
  55. package/dist/operate-server.js.map +1 -0
  56. package/dist/operate-xlsx.cjs +248 -0
  57. package/dist/operate-xlsx.cjs.map +1 -0
  58. package/dist/operate-xlsx.d.cts +129 -0
  59. package/dist/operate-xlsx.d.ts +129 -0
  60. package/dist/operate-xlsx.js +215 -0
  61. package/dist/operate-xlsx.js.map +1 -0
  62. package/dist/operate.cjs +1774 -0
  63. package/dist/operate.cjs.map +1 -0
  64. package/dist/operate.d.cts +595 -0
  65. package/dist/operate.d.ts +595 -0
  66. package/dist/operate.js +1750 -0
  67. package/dist/operate.js.map +1 -0
  68. package/dist/ports.cjs.map +1 -1
  69. package/dist/ports.d.cts +361 -3
  70. package/dist/ports.d.ts +361 -3
  71. package/dist/react-bar.cjs +686 -0
  72. package/dist/react-bar.cjs.map +1 -0
  73. package/dist/react-bar.d.cts +379 -0
  74. package/dist/react-bar.d.ts +379 -0
  75. package/dist/react-bar.js +665 -0
  76. package/dist/react-bar.js.map +1 -0
  77. package/dist/react-host.cjs +301 -0
  78. package/dist/react-host.cjs.map +1 -0
  79. package/dist/react-host.d.cts +820 -0
  80. package/dist/react-host.d.ts +820 -0
  81. package/dist/react-host.js +269 -0
  82. package/dist/react-host.js.map +1 -0
  83. package/dist/react-menu.cjs +735 -0
  84. package/dist/react-menu.cjs.map +1 -0
  85. package/dist/react-menu.d.cts +370 -0
  86. package/dist/react-menu.d.ts +370 -0
  87. package/dist/react-menu.js +722 -0
  88. package/dist/react-menu.js.map +1 -0
  89. package/dist/react-overflow.cjs +592 -0
  90. package/dist/react-overflow.cjs.map +1 -0
  91. package/dist/react-overflow.d.cts +817 -0
  92. package/dist/react-overflow.d.ts +817 -0
  93. package/dist/react-overflow.js +571 -0
  94. package/dist/react-overflow.js.map +1 -0
  95. package/dist/react-palette.cjs +489 -0
  96. package/dist/react-palette.cjs.map +1 -0
  97. package/dist/react-palette.d.cts +359 -0
  98. package/dist/react-palette.d.ts +359 -0
  99. package/dist/react-palette.js +457 -0
  100. package/dist/react-palette.js.map +1 -0
  101. package/dist/react-selection.cjs +617 -0
  102. package/dist/react-selection.cjs.map +1 -0
  103. package/dist/react-selection.d.cts +357 -0
  104. package/dist/react-selection.d.ts +357 -0
  105. package/dist/react-selection.js +596 -0
  106. package/dist/react-selection.js.map +1 -0
  107. package/dist/react-sheet.cjs +616 -0
  108. package/dist/react-sheet.cjs.map +1 -0
  109. package/dist/react-sheet.d.cts +361 -0
  110. package/dist/react-sheet.d.ts +361 -0
  111. package/dist/react-sheet.js +595 -0
  112. package/dist/react-sheet.js.map +1 -0
  113. package/package.json +148 -5
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/react-menu.ts","../src/react/menu.tsx","../src/menu/layouts.ts","../src/react/engine.tsx","../src/declare/sensitivity.ts","../src/actions/projection.ts","../src/actions/run.ts","../src/menu/model.ts","../src/react/context.ts","../src/react/dropdown-nodes.tsx"],"sourcesContent":["/** `@ai-matrx/alchemy/react/menu` — the right-click (context) layout, T1. Load by dynamic import only. */\nexport { ContextMenuPanel, type ContextMenuPanelProps } from \"./react/menu\";\n","\"use client\";\n/**\n * `@ai-matrx/alchemy/react/menu` — the right-click (context) layout, T1.\n * Reached only through the T0 shell's dynamic import (`/react/host`); it\n * draws `context(model, arrangement)` at the pointer. classic · tiered ·\n * command (type-to-filter over every leaf with its breadcrumb).\n */\nimport * as React from \"react\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n TooltipProvider,\n} from \"@ai-matrx/design-system\";\nimport { context, filterPalette, palette } from \"../menu/layouts\";\nimport type { ContextArrangement, Density } from \"../menu/types\";\nimport type { ClickTarget } from \"../actions/types\";\nimport { useMenuEngine, type MenuEngineOptions } from \"./engine\";\nimport { LeafButton, SectionList } from \"./dropdown-nodes\";\n\nexport interface ContextMenuPanelProps extends MenuEngineOptions {\n target: ClickTarget;\n /** Viewport coordinates of the gesture. */\n point: { x: number; y: number };\n open: boolean;\n onOpenChange(open: boolean): void;\n arrangement?: ContextArrangement;\n density?: Density;\n}\n\nexport function ContextMenuPanel({\n target,\n point,\n open,\n onOpenChange,\n arrangement = \"command\",\n density = \"comfortable\",\n ...options\n}: ContextMenuPanelProps): React.ReactElement {\n const engine = useMenuEngine(target, { ...options, onRan: (id, r) => { options.onRan?.(id, r); onOpenChange(false); } });\n const [query, setQuery] = React.useState(\"\");\n const arranged = engine.model ? context(engine.model, arrangement) : null;\n const filtered = engine.model && query.trim() ? filterPalette(palette(engine.model), query) : null;\n return (\n <DropdownMenu open={open} onOpenChange={onOpenChange} modal={false}>\n <DropdownMenuTrigger asChild>\n <span aria-hidden style={{ position: \"fixed\", left: point.x, top: point.y, width: 0, height: 0 }} />\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"start\"\n data-alchemy-layout={`context-${arrangement}`}\n // The menu opens before the right-button release; Radix treats an item\n // pointer-up with no pointer-down as a click, so that release would run\n // whatever row opened beneath the pointer. Consume only the secondary\n // release; primary clicks and the keyboard follow Radix's normal path.\n onPointerUpCapture={(event) => {\n if (event.button === 2) event.preventDefault();\n }}\n className={`w-72 max-h-[var(--radix-dropdown-menu-content-available-height)] overflow-y-auto ${density === \"compact\" ? \"text-xs\" : \"\"}`}\n >\n <TooltipProvider>\n {engine.model?.header ? (\n <DropdownMenuLabel className=\"truncate text-xs font-normal text-muted-foreground\" title={engine.model.header.text}>\n {engine.model.header.label}: {engine.model.header.text}\n </DropdownMenuLabel>\n ) : null}\n {!arranged ? (\n <div className=\"px-2 py-1.5 text-xs text-muted-foreground\">Loading…</div>\n ) : (\n <>\n {arranged.strip.length ? (\n <div role=\"toolbar\" aria-label=\"Clipboard\" className=\"flex items-center gap-0.5 px-1 py-1\">\n {arranged.strip.map((node) => (\n <LeafButton key={node.id} node={node} engine={engine} showLabel={false} />\n ))}\n </div>\n ) : null}\n {arranged.filterable ? (\n <div className=\"px-1 pb-1\">\n <input\n aria-label=\"Filter actions\"\n placeholder=\"Type to filter…\"\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n onKeyDown={(e) => {\n e.stopPropagation();\n if (e.key === \"Enter\" && filtered?.leaves[0]) void engine.run(filtered.leaves[0].node.id);\n }}\n className=\"h-7 w-full rounded-md border border-border bg-transparent px-2 text-sm outline-none\"\n />\n </div>\n ) : null}\n {(arranged.strip.length || arranged.filterable) && arranged.sections.length ? <DropdownMenuSeparator /> : null}\n {filtered ? (\n filtered.leaves.length ? (\n filtered.leaves.map(({ node, breadcrumb }) => (\n <DropdownMenuItem\n key={node.id}\n data-alchemy-node={node.id}\n onSelect={() => {\n if (node.kind === \"submenu\") void engine.expand(node.id);\n else void engine.run(node.id);\n }}\n className=\"flex-col items-start gap-0\"\n >\n <span>{node.label}</span>\n <span className=\"text-xs text-muted-foreground\">{breadcrumb.join(\" › \")}</span>\n </DropdownMenuItem>\n ))\n ) : (\n <div className=\"px-2 py-1.5 text-xs text-muted-foreground\">No action matches “{query}”.</div>\n )\n ) : (\n <SectionList sections={arranged.sections} engine={engine} />\n )}\n </>\n )}\n </TooltipProvider>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\nexport default ContextMenuPanel;\n","/**\n * Layouts — pure arrangements of one MenuModel (CONTRACT §2.5).\n *\n * Every layout is a function over the SAME model: it decides which nodes sit\n * at the top level, which fold under a named submenu and which go into a\n * strip. None adds, drops or renames a leaf — `leafIds(arranged)` equals\n * `leafIds(model)` for every layout (THE LOSSLESS LAW, proven by test).\n *\n * The clipboard group IS the universal verb strip: in the strip layouts it is\n * drawn icon-only; elsewhere its rows are drawn in place. Unavailable verbs\n * (the only greyed nodes, R1 c) appear in every layout identically.\n */\nimport type {\n ArrangedBar,\n ArrangedContext,\n ArrangedPalette,\n ArrangedSelectionToolbar,\n ArrangedSheet,\n ContextArrangement,\n MenuLeafNode,\n MenuModel,\n MenuNode,\n MenuSection,\n MenuSubmenuNode,\n} from \"./types\";\n\n/** A section with more rows than this folds under its label in tiered/command/sheet. */\nexport const INLINE_SECTION_MAX = 3;\n\n/**\n * A section's heading is ONLY the name its actions declare (an approved\n * heading the classic menu already uses: \"Save as\", \"Copy as\", \"History\").\n * A group with no declared name has no heading and is never folded — its rows\n * show inline. The package never coins a heading (chair ruling, ALC-15).\n */\nexport function sectionLabel(section: MenuSection): string | null {\n return section.label ?? null;\n}\n\nfunction isLeaf(node: MenuNode): node is MenuLeafNode {\n return node.kind === \"item\" || node.kind === \"checkbox\" || node.kind === \"link\";\n}\n\n/** Every actionable id in a node list, depth-first. A lazy submenu counts as one leaf. */\nfunction collect(nodes: readonly MenuNode[], out: string[]): void {\n for (const n of nodes) {\n if (isLeaf(n)) out.push(n.id);\n else if (n.kind === \"submenu\") {\n if (n.lazy) out.push(n.id);\n else collect(n.children, out);\n }\n }\n}\n\ntype Arranged =\n | MenuModel\n | ArrangedBar\n | ArrangedContext\n | ArrangedSheet\n | ArrangedPalette\n | ArrangedSelectionToolbar\n | MenuSection[];\n\n/** Proof obligation for every layout: its leaf set equals the model's (sorted, de-duplicated). */\nexport function leafIds(arranged: Arranged): readonly string[] {\n const out: string[] = [];\n if (Array.isArray(arranged)) {\n for (const s of arranged) collect(s.nodes, out);\n } else if (\"leaves\" in arranged) {\n for (const l of arranged.leaves) out.push(l.node.id);\n } else if (\"primary\" in arranged && \"overflow\" in arranged) {\n collect(arranged.primary, out);\n for (const s of arranged.overflow) collect(s.nodes, out);\n } else if (\"root\" in arranged) {\n collect(arranged.strip, out);\n collect(arranged.root, out);\n } else if (\"more\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.more) collect(s.nodes, out);\n } else if (\"filterable\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.sections) collect(s.nodes, out);\n } else {\n for (const s of arranged.sections) collect(s.nodes, out);\n }\n return [...new Set(out)].sort();\n}\n\n/** Only a NAMED section folds; callers check `section.label` first. */\nfunction fold(section: MenuSection & { label: string }): MenuSubmenuNode {\n return {\n kind: \"submenu\",\n id: `${section.id}:fold`,\n label: section.label,\n ...(section.icon !== undefined ? { icon: section.icon } : {}),\n children: section.nodes,\n };\n}\n\nfunction rowCount(nodes: readonly MenuNode[]): number {\n return nodes.filter((n) => n.kind !== \"separator\" && n.kind !== \"label\").length;\n}\n\nfunction stripOf(model: MenuModel): MenuLeafNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter(isLeaf) : [];\n}\n\nfunction clipboardRest(model: MenuModel): MenuNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter((n) => !isLeaf(n) && n.kind === \"submenu\") : [];\n}\n\nfunction placementOf(node: MenuNode): \"primary\" | \"overflow\" | \"both\" {\n return \"placement\" in node && node.placement ? node.placement : \"overflow\";\n}\n\n/** The historical flat column: every section top-level. */\nfunction classic(model: MenuModel): ArrangedContext {\n return { strip: [], sections: model.sections, filterable: false };\n}\n\n/**\n * Tiered / command: the universal verbs as an icon strip; every other row by\n * its own name; the clicked target's (primary) section first, inline, heading\n * kept; a long non-primary section folds under ITS OWN label (never a coined\n * heading); History is the one approved grouping and already a group.\n */\nfunction tiered(model: MenuModel, filterable: boolean): ArrangedContext {\n const strip = stripOf(model);\n const hierarchical = model.sections.some((s) => s.primary);\n const sections: MenuSection[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n if (s.group === \"clipboard\" && !s.primary) {\n if (rest.length) sections.push({ ...s, nodes: rest });\n continue;\n }\n if (s.primary) {\n sections.push(s);\n continue;\n }\n if (!s.label || s.group === \"surface-info\" || rowCount(s.nodes) <= INLINE_SECTION_MAX) {\n if (hierarchical) sections.push(s);\n else {\n const { label: _label, ...unlabelled } = s;\n sections.push(unlabelled);\n }\n continue;\n }\n sections.push({ id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] });\n }\n return { strip, sections, filterable };\n}\n\nexport function context(model: MenuModel, arrangement: ContextArrangement): ArrangedContext {\n if (arrangement === \"classic\") return classic(model);\n return tiered(model, arrangement === \"command\");\n}\n\n/**\n * A long NAMED section folds under its own name (\"Save as ▸\", \"Copy as ▸\");\n * primary sections and unnamed groups stay inline. Folding moves rows, never\n * renames or drops them, and never under a coined heading.\n */\nfunction foldNamed(sections: readonly MenuSection[]): MenuSection[] {\n return sections.map((s) =>\n s.label && !s.primary && rowCount(s.nodes) > INLINE_SECTION_MAX ? { id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] } : s,\n );\n}\n\n/** ⋯ overflow: every section in classic order; long named sections fold under their own name. */\nexport function overflow(model: MenuModel): MenuSection[] {\n return foldNamed(model.sections);\n}\n\n/**\n * The action bar: primary buttons inline, EVERYTHING else under ⋯. A \"both\"\n * action is mirrored in both halves (the leaf set is still the model's).\n * `mini` changes presentation only (icon-only primaries), never membership.\n */\nexport function bar(model: MenuModel, _options: { mini?: boolean } = {}): ArrangedBar {\n const primary: MenuNode[] = [];\n const overflowSections: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n if (n.kind === \"separator\" || n.kind === \"label\") {\n rest.push(n);\n continue;\n }\n const p = placementOf(n);\n if (p === \"primary\" || p === \"both\") primary.push(n);\n if (p === \"overflow\" || p === \"both\") rest.push(n);\n }\n if (rowCount(rest) > 0) overflowSections.push({ ...s, nodes: rest });\n }\n return { primary, overflow: foldNamed(overflowSections) };\n}\n\n/** Selection toolbar: the verbs plus primary actions as a strip; the rest under More. */\nexport function selectionToolbar(model: MenuModel): ArrangedSelectionToolbar {\n const strip: MenuNode[] = [];\n const more: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n const inStrip = (s.group === \"clipboard\" && !s.primary && isLeaf(n)) || placementOf(n) !== \"overflow\";\n if (inStrip) strip.push(n);\n else rest.push(n);\n }\n if (rowCount(rest) > 0) more.push({ ...s, nodes: rest });\n }\n return { strip, more };\n}\n\n/**\n * Mobile bottom sheet: the verb strip on top; primary and short sections\n * inline; longer sections become one drill-down row named by the section.\n * Consumes the model directly, so it can never drift from desktop.\n */\nexport function sheet(model: MenuModel): ArrangedSheet {\n const strip = stripOf(model);\n const root: MenuNode[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n const nodes = s.group === \"clipboard\" && !s.primary ? rest : s.nodes;\n if (rowCount(nodes) === 0) continue;\n if (root.length) root.push({ kind: \"separator\", id: `${s.id}:sep` });\n if (s.primary || !s.label || rowCount(nodes) <= INLINE_SECTION_MAX) {\n if (s.label) root.push({ kind: \"label\", id: `${s.id}:label`, label: s.label });\n root.push(...nodes);\n } else {\n root.push(fold({ ...s, label: s.label, nodes }));\n }\n }\n return { strip, root };\n}\n\n/** Command palette: every leaf flattened with its breadcrumb (Linear). */\nexport function palette(model: MenuModel): ArrangedPalette {\n const leaves: ArrangedPalette[\"leaves\"] = [];\n const walk = (nodes: readonly MenuNode[], trail: string[]) => {\n for (const n of nodes) {\n if (isLeaf(n)) leaves.push({ node: n, breadcrumb: trail });\n else if (n.kind === \"submenu\") {\n if (n.lazy) leaves.push({ node: n, breadcrumb: trail });\n else walk(n.children, [...trail, n.label]);\n }\n }\n };\n for (const s of model.sections) walk(s.nodes, s.label ? [s.label] : []);\n return { leaves };\n}\n\n/** Filter the palette by a query (every word must match label or breadcrumb). */\nexport function filterPalette(arranged: ArrangedPalette, query: string): ArrangedPalette {\n const words = query.toLowerCase().split(/\\s+/).filter(Boolean);\n if (!words.length) return arranged;\n return {\n leaves: arranged.leaves.filter((l) => {\n const hay = `${l.node.label} ${l.breadcrumb.join(\" \")}`.toLowerCase();\n return words.every((w) => hay.includes(w));\n }),\n };\n}\n\nexport const layouts = { bar, overflow, context, selectionToolbar, sheet, palette };\n","\"use client\";\n/**\n * The React half of T1e: one hook every renderer uses to resolve the registry\n * at a target, build the model and run a node. Handlers never live in a\n * renderer — they live in providers and run through `runAction`.\n *\n * The context object is shared through globalThis so every per-layout entry\n * (each bundled separately) reads the same provider (module state is banned\n * across dual-loader graphs).\n */\nimport * as React from \"react\";\nimport { runAction, type RunResult } from \"../actions/run\";\nimport type { ProjectionSource } from \"../actions/projection\";\nimport type { Action, ClickTarget, ResolveRestriction, ResolvedAction } from \"../actions/types\";\nimport { actionToNode, buildMenuModel, findNode, withExpandedChildren } from \"../menu/model\";\nimport type { MenuModel, MenuNode } from \"../menu/types\";\nimport { useAlchemyActions } from \"./context\";\n\nexport interface MenuEngineOptions {\n restrict?: ResolveRestriction;\n /** Raw sources for projection (the host's mounted surface / clicked item). */\n source?: ProjectionSource;\n /** Content the menu acts on when nothing is selected (header text). */\n content?: string | null;\n contentFingerprint?: string;\n /** Called after a node ran (close the menu, announce). */\n onRan?: (nodeId: string, result: RunResult) => void;\n /** Resolve only while true (renderers resolve on open). Default true. */\n active?: boolean;\n /**\n * Re-resolve when this changes even if the target object is the same (a\n * host that keeps one target per mount and reads live state through it).\n */\n revision?: string | number;\n}\n\nexport interface MenuEngine {\n model: MenuModel | null;\n resolved: readonly ResolvedAction[];\n run(nodeId: string): Promise<RunResult | null>;\n expand(nodeId: string): Promise<void>;\n /** The host's glyph for a key; `tone` is the action's colour class (iconTone). */\n icon(key: string | undefined, tone?: string): React.ReactNode;\n}\n\nexport function useMenuEngine(target: ClickTarget | null, options: MenuEngineOptions = {}): MenuEngine {\n const { registry, ports } = useAlchemyActions();\n const [resolved, setResolved] = React.useState<readonly ResolvedAction[]>([]);\n const [model, setModel] = React.useState<MenuModel | null>(null);\n const [tick, setTick] = React.useState(0);\n const expanded = React.useRef(new Map<string, Action>());\n const active = options.active ?? true;\n const optionsRef = React.useRef(options);\n optionsRef.current = options;\n\n React.useEffect(() => registry.subscribe(() => setTick((t) => t + 1)), [registry]);\n\n React.useEffect(() => {\n if (!target || !active) return;\n let live = true;\n void registry.resolve(target, optionsRef.current.restrict).then((list) => {\n if (!live) return;\n expanded.current.clear();\n setResolved(list);\n setModel(buildMenuModel(target, list, { ...(ports.i18n ? { i18n: ports.i18n } : {}), content: optionsRef.current.content ?? null }));\n });\n return () => {\n live = false;\n };\n }, [registry, ports, target, active, tick, options.revision]);\n\n // Live toggles (read-aloud, thumbs): re-build when an action's store changes.\n React.useEffect(() => {\n if (!target) return;\n const offs = resolved\n .map((r) => r.action.subscribe?.(() => setTick((t) => t + 1), target))\n .filter((off): off is () => void => typeof off === \"function\");\n return () => offs.forEach((off) => off());\n }, [resolved, target]);\n\n const findAction = React.useCallback(\n (id: string): Action | undefined => resolved.find((r) => r.action.id === id)?.action ?? expanded.current.get(id),\n [resolved],\n );\n\n const run = React.useCallback(\n async (nodeId: string) => {\n if (!target || !model) return null;\n const node = model.sections.map((s) => findNode(s.nodes, nodeId)).find(Boolean) ?? null;\n const action = findAction(node && \"actionId\" in node && node.actionId ? node.actionId : nodeId);\n if (!action) return null;\n const o = optionsRef.current;\n const result = await runAction(action, target, {\n ports,\n ...(o.source ? { source: o.source } : {}),\n ...(o.contentFingerprint ? { contentFingerprint: o.contentFingerprint } : {}),\n });\n o.onRan?.(nodeId, result);\n return result;\n },\n [target, model, findAction, ports],\n );\n\n const expand = React.useCallback(\n async (nodeId: string) => {\n const action = findAction(nodeId);\n if (!target || !action?.expand) return;\n setModel((m) => (m ? withExpandedChildren(m, nodeId, \"loading\") : m));\n try {\n const children = await action.expand(target, new AbortController().signal);\n const nodes: MenuNode[] = children.map((child) => {\n expanded.current.set(child.id, child);\n return actionToNode({ action: child, eligibility: { status: \"available\" } }, target, ports.i18n ? { i18n: ports.i18n } : {});\n });\n setModel((m) => (m ? withExpandedChildren(m, nodeId, nodes) : m));\n } catch (error) {\n ports.diagnostics.capture(error, { area: \"menu\", detail: { nodeId, stage: \"expand\" } });\n setModel((m) => (m ? withExpandedChildren(m, nodeId, []) : m));\n }\n },\n [findAction, target, ports],\n );\n\n const icon = React.useCallback(\n (key: string | undefined, tone?: string): React.ReactNode => {\n if (!key || !ports.icons) return null;\n const Resolved = ports.icons.resolve(key) as React.ComponentType<{ className?: string; \"aria-hidden\"?: boolean }> | null;\n return Resolved ? <Resolved className={`h-4 w-4 shrink-0 ${tone ?? \"\"}`} aria-hidden /> : null;\n },\n [ports.icons],\n );\n\n return { model, resolved, run, expand, icon };\n}\n","/**\n * Sensitivity defaults and resolution (CONTRACT §2.1). Its own module so the\n * lightweight entries (`/actions`, the T0 React host) can project without\n * pulling the declaration registry.\n */\nimport type { DeclaredValue, Sensitivity } from \"./types\";\n\nexport const DEFAULT_SENSITIVITY: Sensitivity = Object.freeze({\n exportable: true,\n classification: \"ordinary\",\n includedByDefault: true,\n});\n\nexport function resolveSensitivity(value: Pick<DeclaredValue, \"sensitivity\">): Sensitivity {\n return {\n exportable: value.sensitivity?.exportable ?? DEFAULT_SENSITIVITY.exportable,\n classification: value.sensitivity?.classification ?? DEFAULT_SENSITIVITY.classification,\n includedByDefault: value.sensitivity?.includedByDefault ?? DEFAULT_SENSITIVITY.includedByDefault,\n };\n}\n","/**\n * PROJECTION BEFORE PROVIDERS (CONTRACT §2.4).\n *\n * The only place a raw read (`MountedSurface.readValues`,\n * `InternalResolvedItem.readValues`) is consumed on behalf of an action.\n * What leaves is projected: a value is kept only when it is DECLARED, its\n * classification is \"ordinary\" and it is exportable. Everything removed is\n * recorded as an omission, so the person and the agent can see what was held\n * back. No caller can relax this.\n */\nimport { resolveSensitivity } from \"../declare/sensitivity\";\nimport type { InternalResolvedItem, MountedSurface } from \"../declare/host\";\nimport type { DeclaredValue, Json, LiveValues, ResolvedSurfaceDeclaration } from \"../declare/types\";\nimport type { ProjectedReads, ReadOmission } from \"./types\";\n\nexport interface ProjectionSource {\n surface: MountedSurface | null;\n declaration: ResolvedSurfaceDeclaration | null;\n item: InternalResolvedItem | null;\n}\n\nfunction toJson(value: unknown): Json | undefined {\n if (value === undefined || typeof value === \"function\" || typeof value === \"symbol\") return undefined;\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") return Number.isFinite(value) ? value : null;\n if (typeof value === \"bigint\") return value.toString();\n if (value instanceof Date) return value.toISOString();\n if (Array.isArray(value)) return value.map((v) => toJson(v) ?? null);\n if (typeof value === \"object\") {\n const out: { [key: string]: Json } = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n const j = toJson(v);\n if (j !== undefined) out[k] = j;\n }\n return out;\n }\n return undefined;\n}\n\n/** Keep declared, ordinary, exportable values; record every removal. */\nexport function projectValues(\n raw: Record<string, unknown>,\n declared: readonly Pick<DeclaredValue, \"name\" | \"sensitivity\">[],\n pathPrefix = \"\",\n): { values: Record<string, Json>; omissions: ReadOmission[] } {\n const byName = new Map(declared.map((d) => [d.name, d]));\n const values: Record<string, Json> = {};\n const omissions: ReadOmission[] = [];\n for (const [name, value] of Object.entries(raw)) {\n const path = pathPrefix ? `${pathPrefix}.${name}` : name;\n const decl = byName.get(name);\n if (!decl) {\n omissions.push({ path, reason: \"filtered\" });\n continue;\n }\n const sensitivity = resolveSensitivity(decl);\n if (sensitivity.classification !== \"ordinary\") {\n omissions.push({ path, reason: \"excluded\", classification: sensitivity.classification });\n continue;\n }\n if (!sensitivity.exportable) {\n omissions.push({ path, reason: \"excluded\" });\n continue;\n }\n const json = toJson(value);\n if (json === undefined) continue;\n values[name] = json;\n }\n return { values, omissions };\n}\n\nexport function createProjectedReads(source: ProjectionSource): ProjectedReads {\n return {\n async values(signal) {\n if (!source.surface || !source.declaration) return { values: {}, omissions: [] };\n const raw = await source.surface.readValues(signal);\n const screenValues = source.declaration.values;\n return projectValues(raw, screenValues);\n },\n async item(signal) {\n const item = source.item;\n if (!item || !source.declaration) return null;\n const type = source.declaration.itemTypes?.find((t) => t.name === item.itemType);\n if (!type) return { values: {}, omissions: [{ path: item.itemType, reason: \"filtered\" }] };\n const raw = await item.readValues(signal);\n return projectValues(raw, type.values, item.itemType);\n },\n async live(signal): Promise<LiveValues> {\n if (!source.surface?.readLive) return {};\n return source.surface.readLive(signal);\n },\n };\n}\n","/**\n * The one run path (T1e). Every layout runs an action through here, so the\n * sign-in-then-resume rule, projection and failure capture live once.\n */\nimport type { TransferOutcome } from \"@ai-matrx/kit/content-transfer\";\nimport type { AlchemyHostPorts } from \"../ports\";\nimport { createProjectedReads, type ProjectionSource } from \"./projection\";\nimport type { Action, ClickTarget } from \"./types\";\n\nexport interface RunActionOptions {\n ports: AlchemyHostPorts;\n /** Raw sources; projected before the action sees them. */\n source?: ProjectionSource;\n /** Stable fingerprint of the content, for sign-in-then-resume. */\n contentFingerprint?: string;\n signal?: AbortSignal;\n}\n\nexport type RunResult =\n | { status: \"ran\"; outcome: TransferOutcome | void }\n | { status: \"auth-pending\" }\n | { status: \"failed\"; error: unknown };\n\nexport async function runAction(action: Action, target: ClickTarget, options: RunActionOptions): Promise<RunResult> {\n const { ports } = options;\n if (action.requiresAuth && !target.auth.authenticated) {\n if (!ports.auth) {\n // Unreachable through resolve (the action is absent without the port); guard direct callers.\n ports.diagnostics.capture(new Error(`requiresAuth action \"${action.id}\" ran signed out with no auth port`), {\n area: \"actions\",\n detail: { actionId: action.id },\n });\n return { status: \"failed\", error: new Error(\"sign-in unavailable\") };\n }\n ports.auth.signInThenResume({ actionId: action.id, contentFingerprint: options.contentFingerprint ?? action.id });\n return { status: \"auth-pending\" };\n }\n const reads = createProjectedReads(options.source ?? { surface: null, declaration: target.declaration, item: null });\n const signal = options.signal ?? new AbortController().signal;\n try {\n const outcome = await action.run(target, { reads, ports, signal });\n return { status: \"ran\", outcome };\n } catch (error) {\n ports.diagnostics.capture(error, { area: \"actions\", detail: { actionId: action.id, stage: \"run\" } });\n const label = typeof action.label === \"string\" ? action.label : action.id;\n ports.notify?.error(`${label} did not finish.`, \"Try again; if it keeps failing, report it from the feedback button.\");\n return { status: \"failed\", error };\n }\n}\n","/**\n * buildMenuModel — WHAT exists at a click target, as one framework-neutral\n * tree (CONTRACT §2.5). Categories GROUP, never gate: eligibility already ran\n * in the registry; this only arranges the resolved set into sections.\n */\nimport type { ActionCategory, ClickTarget, ResolvedAction } from \"../actions/types\";\nimport type { I18nPort } from \"../ports\";\nimport type { MenuGroup, MenuModel, MenuNode, MenuSection, MenuSubmenuNode } from \"./types\";\n\n/** THE category → menu group table (CONTRACT §2.5). */\nexport const CATEGORY_GROUP: Readonly<Record<ActionCategory, MenuGroup>> = {\n clipboard: \"clipboard\",\n copy: \"transfer\",\n export: \"transfer\",\n save: \"document\",\n share: \"document\",\n edit: \"editable\",\n history: \"history\",\n ai: \"ai\",\n ask: \"ai\",\n listen: \"tools\",\n study: \"tools\",\n app: \"tools\",\n feedback: \"quick\",\n creator: \"admin\",\n admin: \"admin\",\n \"surface-info\": \"surface-info\",\n};\n\n/** Classic order of the groups. `surface-info` is engine-built and always last. */\nexport const GROUP_ORDER: readonly MenuGroup[] = [\n \"clipboard\",\n \"editable\",\n \"transfer\",\n \"document\",\n \"history\",\n \"ai\",\n \"tools\",\n \"quick\",\n \"surface\",\n \"admin\",\n \"surface-info\",\n];\n\nconst CATEGORY_ORDER: readonly ActionCategory[] = [\n \"clipboard\",\n \"edit\",\n \"copy\",\n \"export\",\n \"save\",\n \"share\",\n \"history\",\n \"ask\",\n \"ai\",\n \"listen\",\n \"study\",\n \"app\",\n \"feedback\",\n \"creator\",\n \"admin\",\n \"surface-info\",\n];\n\nexport interface BuildMenuModelOptions {\n i18n?: I18nPort;\n /** Content the menu acts on when nothing is selected. */\n content?: string | null;\n}\n\nfunction translate(i18n: I18nPort | undefined, key: string, fallback: string): string {\n if (!i18n) return fallback;\n try {\n return i18n.t(key, fallback);\n } catch {\n return fallback;\n }\n}\n\n/** One resolved action → one model node (item, checkbox, link or lazy submenu). */\nexport function actionToNode(\n resolved: ResolvedAction,\n target: ClickTarget,\n options: BuildMenuModelOptions = {},\n): MenuNode {\n const { action, eligibility } = resolved;\n const rawLabel = typeof action.label === \"function\" ? action.label(target) : action.label;\n const label = translate(options.i18n, action.labelKey ?? action.id, rawLabel);\n const base = {\n id: action.id,\n actionId: action.id,\n ...(action.icon !== undefined ? { icon: action.icon } : {}),\n ...(action.placement !== undefined ? { placement: action.placement } : {}),\n };\n if (action.expand) {\n const node: MenuSubmenuNode = {\n ...base,\n kind: \"submenu\",\n label,\n lazy: true,\n loading: false,\n children: [],\n ...(action.emptyLabel !== undefined ? { emptyLabel: action.emptyLabel } : {}),\n };\n return node;\n }\n if (action.href !== undefined) {\n const href = typeof action.href === \"function\" ? action.href(target) : action.href;\n return { ...base, kind: \"link\", label, href };\n }\n if (action.toggle) {\n return {\n ...base,\n kind: \"checkbox\",\n label,\n checked: action.pressed?.(target) ?? false,\n ...(action.description !== undefined ? { description: action.description } : {}),\n };\n }\n const state = action.stateIcon?.(target) ?? null;\n const pressed = action.pressed?.(target);\n const hint = action.hint !== undefined ? translate(options.i18n, action.hintKey ?? `${action.id}.hint`, action.hint) : undefined;\n return {\n ...base,\n kind: \"item\",\n label,\n ...(action.iconTone !== undefined ? { iconTone: action.iconTone } : {}),\n ...(state ? { stateIcon: state } : {}),\n ...(action.description !== undefined ? { description: action.description } : {}),\n ...(hint !== undefined ? { hint } : {}),\n ...(pressed !== undefined ? { pressed } : {}),\n ...(action.destructive ? { destructive: true } : {}),\n ...(action.preserveSelection ? { preserveSelection: true } : {}),\n ...(eligibility.status === \"unavailable-verb\" ? { unavailable: { sentence: eligibility.sentence } } : {}),\n };\n}\n\nexport function buildMenuModel(\n target: ClickTarget,\n resolved: readonly ResolvedAction[],\n options: BuildMenuModelOptions = {},\n): MenuModel {\n const ordered = resolved\n .map((r, index) => ({ r, index }))\n .sort((a, b) => {\n const ca = CATEGORY_ORDER.indexOf(a.r.action.category);\n const cb = CATEGORY_ORDER.indexOf(b.r.action.category);\n if (ca !== cb) return ca - cb;\n const oa = a.r.action.order ?? 0;\n const ob = b.r.action.order ?? 0;\n if (oa !== ob) return oa - ob;\n return a.index - b.index;\n })\n .map((x) => x.r);\n\n const sections = new Map<string, MenuSection>();\n const roles: Record<string, string> = {};\n // An explicit section sits in the group of its first-registered action and\n // keeps its own row order (order, then registration) across categories.\n const explicit = new Map<string, { group: MenuGroup; rows: { r: ResolvedAction; index: number }[] }>();\n resolved.forEach((r, index) => {\n const sec = r.action.section;\n if (!sec) return;\n const entry = explicit.get(sec.id) ?? { group: CATEGORY_GROUP[r.action.category], rows: [] };\n entry.rows.push({ r, index });\n explicit.set(sec.id, entry);\n });\n const placed = new Set<string>();\n for (const r of ordered) {\n const sec = r.action.section;\n if (sec && placed.has(sec.id)) continue;\n const group = sec ? (explicit.get(sec.id)?.group ?? CATEGORY_GROUP[r.action.category]) : CATEGORY_GROUP[r.action.category];\n const sectionId = sec ? `section:${sec.id}` : group;\n let section = sections.get(sectionId);\n if (!section) {\n section = {\n id: sectionId,\n group,\n nodes: [],\n ...(sec ? { label: translate(options.i18n, sec.labelKey ?? `section.${sec.id}`, sec.label) } : {}),\n ...(sec?.icon !== undefined ? { icon: sec.icon } : {}),\n ...(sec?.primary ? { primary: true } : {}),\n };\n sections.set(sectionId, section);\n }\n const rows = sec\n ? (explicit.get(sec.id)?.rows ?? [])\n .sort((x, y) => (x.r.action.order ?? 0) - (y.r.action.order ?? 0) || x.index - y.index)\n .map((x) => x.r)\n : [r];\n if (sec) placed.add(sec.id);\n for (const row of rows) {\n section.nodes.push(actionToNode(row, target, options));\n if (row.action.verb) roles[row.action.verb] = row.action.id;\n }\n }\n\n const list = [...sections.values()].sort((a, b) => {\n if (Boolean(a.primary) !== Boolean(b.primary)) return a.primary ? -1 : 1;\n return GROUP_ORDER.indexOf(a.group) - GROUP_ORDER.indexOf(b.group);\n });\n\n const selected = target.selection?.text?.trim();\n const content = options.content?.trim();\n const header = selected\n ? { label: \"Selected\" as const, text: target.selection?.text ?? \"\" }\n : content\n ? { label: \"Content\" as const, text: options.content ?? \"\" }\n : null;\n\n return { header, sections: list, roles };\n}\n\n/** Fill a lazy submenu's rows once they load (pure: returns a new model). */\nexport function withExpandedChildren(model: MenuModel, nodeId: string, children: MenuNode[] | \"loading\"): MenuModel {\n const visit = (nodes: MenuNode[]): MenuNode[] =>\n nodes.map((n) => {\n if (n.kind !== \"submenu\") return n;\n if (n.id === nodeId) {\n return children === \"loading\" ? { ...n, loading: true } : { ...n, lazy: false, loading: false, children };\n }\n return { ...n, children: visit(n.children) };\n });\n return { ...model, sections: model.sections.map((s) => ({ ...s, nodes: visit(s.nodes) })) };\n}\n\n/** Find a node anywhere in a tree. */\nexport function findNode(nodes: readonly MenuNode[], id: string): MenuNode | null {\n for (const n of nodes) {\n if (n.id === id) return n;\n if (n.kind === \"submenu\") {\n const hit = findNode(n.children, id);\n if (hit) return hit;\n }\n }\n return null;\n}\n","/**\n * The shared React context (T0-safe: imports only React and types). Shared\n * through globalThis so every per-layout bundle reads the same provider.\n */\nimport * as React from \"react\";\nimport type { ActionRegistry } from \"../actions/types\";\nimport type { AlchemyHostPorts } from \"../ports\";\n\nexport interface AlchemyActionsValue {\n registry: ActionRegistry;\n ports: AlchemyHostPorts;\n}\n\nconst KEY = Symbol.for(\"ai-matrx.alchemy.actions-context\");\ntype Holder = { [KEY]?: React.Context<AlchemyActionsValue | null> };\nexport const AlchemyActionsContext: React.Context<AlchemyActionsValue | null> =\n ((globalThis as Holder)[KEY] ??= React.createContext<AlchemyActionsValue | null>(null));\n\nexport function useAlchemyActions(): AlchemyActionsValue {\n const value = React.useContext(AlchemyActionsContext);\n if (!value) throw new Error(\"Alchemy actions: render inside <AlchemyActionsProvider> (@ai-matrx/alchemy/react/host).\");\n return value;\n}\n","\"use client\";\n/**\n * Drawing model nodes inside a Radix dropdown (menu / overflow / bar / selection).\n * Pure presentation: every choice goes back to the engine by node id.\n */\nimport * as React from \"react\";\nimport {\n DropdownMenuCheckboxItem,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@ai-matrx/design-system\";\nimport type { MenuEngine } from \"./engine\";\nimport { sectionLabel } from \"../menu/layouts\";\nimport type { MenuLeafNode, MenuNode, MenuSection } from \"../menu/types\";\n\nexport function NodeList({ nodes, engine }: { nodes: readonly MenuNode[]; engine: MenuEngine }): React.ReactElement {\n return (\n <>\n {nodes.map((node) => (\n <MenuNodeView key={node.id} node={node} engine={engine} />\n ))}\n </>\n );\n}\n\nexport function SectionList({\n sections,\n engine,\n}: {\n sections: readonly MenuSection[];\n engine: MenuEngine;\n}): React.ReactElement {\n return (\n <>\n {sections.map((section, index) => (\n <React.Fragment key={section.id}>\n {index > 0 ? <DropdownMenuSeparator /> : null}\n {sectionLabel(section) ? (\n <DropdownMenuLabel className=\"text-xs font-medium text-muted-foreground\">{sectionLabel(section)}</DropdownMenuLabel>\n ) : null}\n <NodeList nodes={section.nodes} engine={engine} />\n </React.Fragment>\n ))}\n </>\n );\n}\n\nfunction iconOf(node: MenuNode, engine: MenuEngine): React.ReactNode {\n if (node.kind === \"item\" && node.stateIcon) {\n const glyph = engine.icon(node.stateIcon.icon);\n return node.stateIcon.spin ? <span className=\"inline-flex animate-spin\">{glyph}</span> : glyph;\n }\n if (!(\"icon\" in node)) return null;\n return engine.icon(node.icon, node.kind === \"item\" ? node.iconTone : undefined);\n}\n\nexport function MenuNodeView({ node, engine }: { node: MenuNode; engine: MenuEngine }): React.ReactElement | null {\n switch (node.kind) {\n case \"separator\":\n return <DropdownMenuSeparator />;\n case \"label\":\n return <DropdownMenuLabel className=\"text-xs font-medium text-muted-foreground\">{node.label}</DropdownMenuLabel>;\n case \"submenu\":\n return (\n <DropdownMenuSub\n onOpenChange={(open) => {\n if (open && node.lazy && !node.loading) void engine.expand(node.id);\n }}\n >\n <DropdownMenuSubTrigger data-alchemy-node={node.id} className=\"gap-2\">\n {iconOf(node, engine)}\n <span className=\"truncate\">{node.label}</span>\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"max-h-[var(--radix-dropdown-menu-content-available-height)] overflow-y-auto\">\n {node.loading ? (\n <DropdownMenuLabel className=\"text-xs text-muted-foreground\">Loading…</DropdownMenuLabel>\n ) : node.children.length === 0 && !node.lazy ? (\n <DropdownMenuLabel className=\"text-xs text-muted-foreground\">{node.emptyLabel ?? \"Nothing here yet\"}</DropdownMenuLabel>\n ) : (\n <NodeList nodes={node.children} engine={engine} />\n )}\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n case \"checkbox\":\n return (\n <DropdownMenuCheckboxItem\n data-alchemy-node={node.id}\n checked={node.checked}\n onSelect={() => void engine.run(node.id)}\n className=\"gap-2\"\n >\n {iconOf(node, engine)}\n <span className=\"truncate\">{node.label}</span>\n </DropdownMenuCheckboxItem>\n );\n case \"link\":\n return (\n <DropdownMenuItem asChild data-alchemy-node={node.id}>\n <a href={node.href} target={node.target} className=\"gap-2\">\n {iconOf(node, engine)}\n <span className=\"truncate\">{node.label}</span>\n </a>\n </DropdownMenuItem>\n );\n case \"item\":\n return <LeafItem node={node} engine={engine} />;\n }\n}\n\nfunction LeafItem({ node, engine }: { node: Extract<MenuLeafNode, { kind: \"item\" }>; engine: MenuEngine }): React.ReactElement {\n const row = (\n <DropdownMenuItem\n data-alchemy-node={node.id}\n aria-disabled={node.unavailable ? true : undefined}\n aria-pressed={node.pressed}\n onSelect={(event) => {\n if (node.unavailable) {\n event.preventDefault();\n return;\n }\n void engine.run(node.id);\n }}\n className={`gap-2 ${node.unavailable ? \"opacity-50\" : \"\"} ${node.destructive ? \"text-destructive\" : \"\"}`}\n >\n {iconOf(node, engine)}\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"truncate\">{node.label}</span>\n {node.description ? <span className=\"truncate text-xs text-muted-foreground\">{node.description}</span> : null}\n </span>\n {node.hint ? <span className=\"ml-auto text-xs text-muted-foreground\">{node.hint}</span> : null}\n </DropdownMenuItem>\n );\n if (!node.unavailable) return row;\n return (\n <Tooltip>\n <TooltipTrigger asChild>{row}</TooltipTrigger>\n <TooltipContent>{node.unavailable.sentence}</TooltipContent>\n </Tooltip>\n );\n}\n\n/** An icon button for a strip / bar leaf (greyed verb carries its sentence). */\nexport function LeafButton({\n node,\n engine,\n showLabel,\n}: {\n node: MenuNode;\n engine: MenuEngine;\n showLabel: boolean;\n}): React.ReactElement | null {\n if (node.kind !== \"item\" && node.kind !== \"checkbox\" && node.kind !== \"link\") return null;\n const unavailable = node.kind === \"item\" ? node.unavailable : undefined;\n const pressed = node.kind === \"item\" ? node.pressed : node.kind === \"checkbox\" ? node.checked : undefined;\n const glyph = iconOf(node, engine);\n const button = (\n <button\n type=\"button\"\n data-alchemy-node={node.id}\n aria-label={node.label}\n aria-disabled={unavailable ? true : undefined}\n aria-pressed={pressed}\n onMouseDown={(e) => {\n if (node.kind === \"item\" && node.preserveSelection) e.preventDefault();\n }}\n onClick={() => {\n if (unavailable) return;\n if (node.kind === \"link\") {\n window.location.assign(node.href);\n return;\n }\n void engine.run(node.id);\n }}\n className={`inline-flex h-7 min-w-7 items-center justify-center gap-1.5 rounded-md px-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-foreground ${\n unavailable ? \"cursor-default opacity-50 hover:bg-transparent\" : \"\"\n } ${pressed ? \"text-foreground\" : \"\"}`}\n >\n {glyph}\n {showLabel || !glyph ? <span>{node.label}</span> : null}\n </button>\n );\n return (\n <Tooltip>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n <TooltipContent>{unavailable ? unavailable.sentence : node.label}</TooltipContent>\n </Tooltip>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,IAAAA,SAAuB;AACvB,IAAAC,wBAQO;;;ACWA,IAAM,qBAAqB;AAQ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AW,MACtC;AAAA,cAAC;AAAA;AAAA,gBAEC,qBAAmB,KAAK;AAAA,gBACxB,UAAU,MAAM;AACd,sBAAI,KAAK,SAAS,UAAW,MAAK,OAAO,OAAO,KAAK,EAAE;AAAA,sBAClD,MAAK,OAAO,IAAI,KAAK,EAAE;AAAA,gBAC9B;AAAA,gBACA,WAAU;AAAA,gBAEV;AAAA,+DAAC,UAAM,eAAK,OAAM;AAAA,kBAClB,6CAAC,UAAK,WAAU,iCAAiC,qBAAW,KAAK,UAAK,GAAE;AAAA;AAAA;AAAA,cATnE,KAAK;AAAA,YAUZ,CACD,IAED,8CAAC,SAAI,WAAU,6CAA4C;AAAA;AAAA,cAAoB;AAAA,cAAM;AAAA,eAAE,IAGzF,6CAAC,eAAY,UAAU,SAAS,UAAU,QAAgB;AAAA,aAE9D;AAAA,WAEJ;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":["React","import_design_system","React","React","import_jsx_runtime","import_jsx_runtime"]}
@@ -0,0 +1,370 @@
1
+ import * as React from 'react';
2
+ import { TransferOutcome } from '@ai-matrx/kit/content-transfer';
3
+
4
+ type ContextArrangement = "classic" | "tiered" | "command";
5
+ type Density = "comfortable" | "compact";
6
+
7
+ /**
8
+ * Matrx Alchemy — Declare types (CONTRACT §2.1).
9
+ *
10
+ * A declaration is plain JSON data (chair ruling N2): no functions, no classes,
11
+ * no React. Runtime behaviour lives in `MountedSurface` (`/declare/host`) and in
12
+ * handler registrations, never here. Zero React, zero `@ai-matrx/agents`.
13
+ */
14
+ type Json = null | boolean | number | string | Json[] | {
15
+ [key: string]: Json;
16
+ };
17
+ /** Unchanged from `ui_surface_value_type_chk`. */
18
+ type ValueType = "string" | "number" | "boolean" | "object" | "array" | "document";
19
+ type Classification = "ordinary" | "secret" | "credential";
20
+ /** Persisted (CONTRACT §2.7). Projection enforces it before any value leaves. */
21
+ interface Sensitivity {
22
+ /** false = never leaves through Operate. Default true. */
23
+ exportable: boolean;
24
+ /** secret/credential are always excluded; no caller can relax this. Default "ordinary". */
25
+ classification: Classification;
26
+ /** Pre-checked in the preparation workspace. Default true. */
27
+ includedByDefault: boolean;
28
+ }
29
+ interface ValueGroup {
30
+ key: string;
31
+ label: string;
32
+ sortOrder: number;
33
+ description?: string;
34
+ }
35
+ /** The four runtime slots a capture fills (absorbs page-capture). */
36
+ type LiveSlot = "selection" | "on-demand" | "errors" | "requests";
37
+ interface DeclaredValue {
38
+ name: string;
39
+ label: string;
40
+ description: string;
41
+ valueType: ValueType;
42
+ /** Registered content-ir kind key (DB: kind_key). */
43
+ valueKind?: string;
44
+ alwaysAvailable: boolean;
45
+ typicalCharCount: number;
46
+ autoContext?: boolean;
47
+ group?: string;
48
+ sortOrder?: number;
49
+ sensitivity?: Partial<Sensitivity>;
50
+ /** Filled at capture time from a live slot instead of the scope. */
51
+ liveSlot?: LiveSlot;
52
+ /** "request" values drop out of "Only the data". Default "data". */
53
+ role?: "data" | "request";
54
+ }
55
+ /** Where a write lands. "stream" = applied live, op by op, into an editable text. */
56
+ type WriteMode = "draft" | "entity" | "ui" | "stream";
57
+ /** Who may apply WITHOUT a click. "queued" = filed for an organization's review. */
58
+ type ApplyPolicy = "manual" | "ask" | "auto" | "queued";
59
+ /** The WidgetHandle text op set, unchanged in meaning. */
60
+ type StreamOp = "replace" | "insert_before" | "insert_after" | "prepend" | "append" | "patch";
61
+ interface WriteTarget {
62
+ name: string;
63
+ label: string;
64
+ description: string;
65
+ valueType: ValueType;
66
+ valueKind?: string;
67
+ /** Read twin (evidence loop). Required when patchable or mode === "stream". */
68
+ updatesValue?: string;
69
+ patchable?: boolean;
70
+ approvalComparison?: "text-replacement";
71
+ mode: WriteMode;
72
+ /** Required iff mode === "stream". */
73
+ streamOps?: readonly StreamOp[];
74
+ /** Default "manual". Binding overrides may only tighten. */
75
+ applyPolicy?: ApplyPolicy;
76
+ destination?: boolean;
77
+ /** Present when the target writes into an item rather than the screen. */
78
+ itemType?: string;
79
+ group?: string;
80
+ sortOrder?: number;
81
+ }
82
+ /** One kind of thing inside a screen (a row, a message, a code block, a card). */
83
+ interface ItemType {
84
+ name: string;
85
+ label: string;
86
+ description: string;
87
+ /** Value names that together identify one item. */
88
+ identity: readonly string[];
89
+ levels?: readonly string[];
90
+ entityType?: string;
91
+ values: readonly DeclaredValue[];
92
+ writeTargets?: readonly WriteTarget[];
93
+ }
94
+ type Readiness = "verified" | "partial" | "stub";
95
+ /** `ui_surface_execution_mode_check`, unchanged. */
96
+ type ExecutionMode = "python-stream" | "nextjs-stream" | "browser-realtime" | "local-runtime";
97
+ interface ConfigNamespaceDeclaration {
98
+ namespace: string;
99
+ label: string;
100
+ description: string;
101
+ }
102
+ interface EvidenceSourceDeclaration {
103
+ kind: "processed_document";
104
+ idValue: string;
105
+ fileIdValue?: string;
106
+ labelValue?: string;
107
+ representation?: "clean" | "raw";
108
+ }
109
+ /**
110
+ * One screen's declaration. Owning packages add fields (agent roles, client
111
+ * tools) as EXTENSION SLOTS — by interface extension or declaration merging —
112
+ * and register a `DeclarationExtension` so validation and the sync cover them.
113
+ */
114
+ interface SurfaceDeclaration {
115
+ surfaceName: string;
116
+ /** REQUIRED. `ui_surface.client_name`; must equal the surfaceName prefix. */
117
+ client: string;
118
+ /** REQUIRED. `ui_surface.execution_mode`. */
119
+ executionMode: ExecutionMode;
120
+ /** REQUIRED. `ui_surface.description` ("" only where the live row is empty). */
121
+ description: string;
122
+ label: string;
123
+ readiness: Readiness;
124
+ readinessNote?: string;
125
+ urlPattern?: string;
126
+ inheritsFrom?: string;
127
+ intro?: string;
128
+ overlayId?: string;
129
+ values: readonly DeclaredValue[];
130
+ groups?: readonly ValueGroup[];
131
+ writeTargets?: readonly WriteTarget[];
132
+ itemTypes?: readonly ItemType[];
133
+ liveSlots?: readonly LiveSlot[];
134
+ configNamespaces?: readonly ConfigNamespaceDeclaration[];
135
+ evidenceSources?: readonly EvidenceSourceDeclaration[];
136
+ skipBaselineValues?: boolean;
137
+ }
138
+ type ValueProvenance = {
139
+ kind: "own";
140
+ } | {
141
+ kind: "inherited";
142
+ from: string;
143
+ } | {
144
+ kind: "baseline";
145
+ };
146
+ type ResolvedValue = DeclaredValue & {
147
+ provenance: ValueProvenance;
148
+ groupKey: string;
149
+ /** Defaults filled. */
150
+ resolvedSensitivity: Sensitivity;
151
+ };
152
+ interface ResolvedSurfaceDeclaration extends SurfaceDeclaration {
153
+ contentHash: string;
154
+ values: readonly ResolvedValue[];
155
+ groups: readonly ValueGroup[];
156
+ }
157
+ /**
158
+ * ITEM KEYS. A value or write target is identified by (surfaceName, itemType ?? "", name).
159
+ * The qualified key "<itemType>.<name>" names an item value; a bare name is a screen value.
160
+ */
161
+ type QualifiedValueKey = string;
162
+ /** Live slot payloads (page-capture's shapes, kept). */
163
+ interface LiveValues {
164
+ selection?: {
165
+ choices: Record<string, Json>;
166
+ text: string | null;
167
+ };
168
+ "on-demand"?: readonly OnDemandSection[];
169
+ errors?: readonly string[];
170
+ requests?: readonly RecentRequest[];
171
+ }
172
+ interface OnDemandSection {
173
+ id: string;
174
+ title: string;
175
+ description?: string;
176
+ role: "data" | "request";
177
+ brief?: Json;
178
+ load(signal: AbortSignal): Promise<Json>;
179
+ }
180
+ interface RecentRequest {
181
+ method: string;
182
+ path: string;
183
+ status: string;
184
+ httpStatus?: number;
185
+ durationMs?: number;
186
+ requestId?: string;
187
+ client?: string;
188
+ requestBody?: Json;
189
+ requestBodyNote?: string;
190
+ errorSentence?: string;
191
+ timestamp: number;
192
+ }
193
+ /** RAW-FREE. What leaves the package about a clicked item. */
194
+ interface ResolvedItem {
195
+ itemType: string;
196
+ identity: Record<string, string>;
197
+ level?: string;
198
+ readOnly: boolean;
199
+ }
200
+
201
+ /**
202
+ * The click target (CONTRACT §2.4) in its own module: `/ports` references it,
203
+ * and `/ports` must stay free of every other package (types only).
204
+ */
205
+
206
+ /** The transfer Payload's kinds (`actions/types.ts` asserts equality at compile time). */
207
+ type PayloadKind = "text" | "markdown" | "json" | "rows" | "registered";
208
+ /** What eligibility is computed from: everything declared at the click target. */
209
+ interface ClickTarget {
210
+ surface: {
211
+ instanceId: string;
212
+ surfaceName: string;
213
+ } | null;
214
+ /** The resolved declaration (inheritance applied). Eligibility decides by KEY existence over it. */
215
+ declaration: ResolvedSurfaceDeclaration | null;
216
+ /** Declared value keys with a read path here (screen names + qualified item keys). Key existence, not population. */
217
+ valueKeys: ReadonlySet<QualifiedValueKey>;
218
+ /** Scope chain, most general first: ["global", "<domain>", "<surfaceName>"]. */
219
+ scopeChain: readonly string[];
220
+ /** The surface's explicit exclusions (the one override). */
221
+ excludedActionIds: ReadonlySet<string>;
222
+ item: ResolvedItem | null;
223
+ level: string | null;
224
+ /** Offsets + the live range handle, editable or not. */
225
+ selection: {
226
+ text: string;
227
+ type: "editable" | "non-editable";
228
+ start: number;
229
+ end: number;
230
+ /** Opaque host handle (DOM Range / element) used to restore or stream into the selection. */
231
+ handle?: unknown;
232
+ } | null;
233
+ /** Payload kinds a capture of this target would produce (from declared value types/kinds). */
234
+ payloadKinds: readonly PayloadKind[];
235
+ /** Declared targets writable on this target right now. */
236
+ writable: readonly WriteTarget[];
237
+ readOnly: boolean;
238
+ /** True when any declared value here is secret/credential or non-exportable. */
239
+ restricted: boolean;
240
+ organizationId: string | null;
241
+ auth: {
242
+ authenticated: boolean;
243
+ admin: boolean;
244
+ creator: boolean;
245
+ };
246
+ /**
247
+ * Host-owned context a provider reads to act (the rich-document source, the
248
+ * editable field's callbacks). Opaque to the package; never crosses into the
249
+ * model. Providers that need it narrow it themselves.
250
+ */
251
+ host?: unknown;
252
+ }
253
+
254
+ /**
255
+ * Matrx Alchemy — Actions types (CONTRACT §2.4).
256
+ *
257
+ * One registry of everything a person can do to a thing. Providers plug in;
258
+ * eligibility is computed from what is declared at the click target; duplicate
259
+ * ids are refused; an action that does not apply is ABSENT (chair ruling R1).
260
+ *
261
+ * Framework-neutral: zero React, zero `@ai-matrx/agents`. Icons are string KEYS
262
+ * resolved by the host's `IconResolverPort`; labels go through `I18nPort`.
263
+ */
264
+
265
+ /** rich-document's ActionCategory, unchanged, plus the three the context menu groups by. */
266
+ type ActionCategory = "feedback" | "copy" | "export" | "save" | "edit" | "share" | "creator" | "app" | "listen" | "study" | "ask" | "ai" | "admin" | "clipboard" | "history" | "surface-info";
267
+ interface ResolveRestriction {
268
+ exclude?: readonly string[];
269
+ categories?: readonly ActionCategory[];
270
+ }
271
+
272
+ /**
273
+ * `@ai-matrx/alchemy/declare/host` — HOST-BINDING types only (CONTRACT §2.1, §2.6).
274
+ * Never imported by providers (`/declare`, `/actions`, `/menu`, `/operate` see only
275
+ * the raw-free `ResolvedItem`). Types only: no runtime code.
276
+ */
277
+
278
+ interface ItemAnchor {
279
+ /** The host element the person clicked. */
280
+ element: unknown;
281
+ level?: string;
282
+ }
283
+ /** Raw item reads: consumed only by projection and the write handler that owns the target. */
284
+ interface InternalResolvedItem extends ResolvedItem {
285
+ readValues(signal: AbortSignal): Promise<Record<string, unknown>>;
286
+ }
287
+ /** A mounted instance of a declared surface. Structural handle, never a global name lookup. */
288
+ interface MountedSurface {
289
+ instanceId: string;
290
+ surfaceName: string;
291
+ isMounted(): boolean;
292
+ /** Same revision before and after a read, or capture refuses with "surface-changed". */
293
+ getRevision?(): string;
294
+ unsavedChanges?(): boolean;
295
+ readValues(signal: AbortSignal): Promise<Record<string, unknown>>;
296
+ readLive?(signal: AbortSignal): Promise<LiveValues>;
297
+ resolveItem?(anchor: ItemAnchor): InternalResolvedItem | null;
298
+ }
299
+
300
+ interface ProjectionSource {
301
+ surface: MountedSurface | null;
302
+ declaration: ResolvedSurfaceDeclaration | null;
303
+ item: InternalResolvedItem | null;
304
+ }
305
+
306
+ /**
307
+ * The one run path (T1e). Every layout runs an action through here, so the
308
+ * sign-in-then-resume rule, projection and failure capture live once.
309
+ */
310
+
311
+ type RunResult = {
312
+ status: "ran";
313
+ outcome: TransferOutcome | void;
314
+ } | {
315
+ status: "auth-pending";
316
+ } | {
317
+ status: "failed";
318
+ error: unknown;
319
+ };
320
+
321
+ /**
322
+ * The React half of T1e: one hook every renderer uses to resolve the registry
323
+ * at a target, build the model and run a node. Handlers never live in a
324
+ * renderer — they live in providers and run through `runAction`.
325
+ *
326
+ * The context object is shared through globalThis so every per-layout entry
327
+ * (each bundled separately) reads the same provider (module state is banned
328
+ * across dual-loader graphs).
329
+ */
330
+
331
+ interface MenuEngineOptions {
332
+ restrict?: ResolveRestriction;
333
+ /** Raw sources for projection (the host's mounted surface / clicked item). */
334
+ source?: ProjectionSource;
335
+ /** Content the menu acts on when nothing is selected (header text). */
336
+ content?: string | null;
337
+ contentFingerprint?: string;
338
+ /** Called after a node ran (close the menu, announce). */
339
+ onRan?: (nodeId: string, result: RunResult) => void;
340
+ /** Resolve only while true (renderers resolve on open). Default true. */
341
+ active?: boolean;
342
+ /**
343
+ * Re-resolve when this changes even if the target object is the same (a
344
+ * host that keeps one target per mount and reads live state through it).
345
+ */
346
+ revision?: string | number;
347
+ }
348
+
349
+ /**
350
+ * `@ai-matrx/alchemy/react/menu` — the right-click (context) layout, T1.
351
+ * Reached only through the T0 shell's dynamic import (`/react/host`); it
352
+ * draws `context(model, arrangement)` at the pointer. classic · tiered ·
353
+ * command (type-to-filter over every leaf with its breadcrumb).
354
+ */
355
+
356
+ interface ContextMenuPanelProps extends MenuEngineOptions {
357
+ target: ClickTarget;
358
+ /** Viewport coordinates of the gesture. */
359
+ point: {
360
+ x: number;
361
+ y: number;
362
+ };
363
+ open: boolean;
364
+ onOpenChange(open: boolean): void;
365
+ arrangement?: ContextArrangement;
366
+ density?: Density;
367
+ }
368
+ declare function ContextMenuPanel({ target, point, open, onOpenChange, arrangement, density, ...options }: ContextMenuPanelProps): React.ReactElement;
369
+
370
+ export { ContextMenuPanel, type ContextMenuPanelProps };