@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.
- package/CHANGELOG.md +58 -0
- package/dist/actions.cjs +374 -0
- package/dist/actions.cjs.map +1 -0
- package/dist/actions.d.cts +773 -0
- package/dist/actions.d.ts +773 -0
- package/dist/actions.js +351 -0
- package/dist/actions.js.map +1 -0
- package/dist/checks.cjs +31 -2
- package/dist/checks.cjs.map +1 -1
- package/dist/checks.d.cts +24 -1
- package/dist/checks.d.ts +24 -1
- package/dist/checks.js +31 -2
- package/dist/checks.js.map +1 -1
- package/dist/core.cjs +1757 -2
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +595 -1
- package/dist/core.d.ts +595 -1
- package/dist/core.js +1749 -2
- package/dist/core.js.map +1 -1
- package/dist/declare.cjs +12 -10
- package/dist/declare.cjs.map +1 -1
- package/dist/declare.d.cts +18 -2
- package/dist/declare.d.ts +18 -2
- package/dist/declare.js +12 -10
- package/dist/declare.js.map +1 -1
- package/dist/index.cjs +1757 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +595 -1
- package/dist/index.d.ts +595 -1
- package/dist/index.js +1749 -2
- package/dist/index.js.map +1 -1
- package/dist/menu.cjs +436 -0
- package/dist/menu.cjs.map +1 -0
- package/dist/menu.d.cts +834 -0
- package/dist/menu.d.ts +834 -0
- package/dist/menu.js +413 -0
- package/dist/menu.js.map +1 -0
- package/dist/operate-document.cjs +163 -0
- package/dist/operate-document.cjs.map +1 -0
- package/dist/operate-document.d.cts +132 -0
- package/dist/operate-document.d.ts +132 -0
- package/dist/operate-document.js +130 -0
- package/dist/operate-document.js.map +1 -0
- package/dist/operate-rich-html.cjs +129 -0
- package/dist/operate-rich-html.cjs.map +1 -0
- package/dist/operate-rich-html.d.cts +136 -0
- package/dist/operate-rich-html.d.ts +136 -0
- package/dist/operate-rich-html.js +96 -0
- package/dist/operate-rich-html.js.map +1 -0
- package/dist/operate-server.cjs +157 -0
- package/dist/operate-server.cjs.map +1 -0
- package/dist/operate-server.d.cts +183 -0
- package/dist/operate-server.d.ts +183 -0
- package/dist/operate-server.js +134 -0
- package/dist/operate-server.js.map +1 -0
- package/dist/operate-xlsx.cjs +248 -0
- package/dist/operate-xlsx.cjs.map +1 -0
- package/dist/operate-xlsx.d.cts +129 -0
- package/dist/operate-xlsx.d.ts +129 -0
- package/dist/operate-xlsx.js +215 -0
- package/dist/operate-xlsx.js.map +1 -0
- package/dist/operate.cjs +1774 -0
- package/dist/operate.cjs.map +1 -0
- package/dist/operate.d.cts +595 -0
- package/dist/operate.d.ts +595 -0
- package/dist/operate.js +1750 -0
- package/dist/operate.js.map +1 -0
- package/dist/ports.cjs.map +1 -1
- package/dist/ports.d.cts +361 -3
- package/dist/ports.d.ts +361 -3
- package/dist/react-bar.cjs +686 -0
- package/dist/react-bar.cjs.map +1 -0
- package/dist/react-bar.d.cts +379 -0
- package/dist/react-bar.d.ts +379 -0
- package/dist/react-bar.js +665 -0
- package/dist/react-bar.js.map +1 -0
- package/dist/react-host.cjs +301 -0
- package/dist/react-host.cjs.map +1 -0
- package/dist/react-host.d.cts +820 -0
- package/dist/react-host.d.ts +820 -0
- package/dist/react-host.js +269 -0
- package/dist/react-host.js.map +1 -0
- package/dist/react-menu.cjs +735 -0
- package/dist/react-menu.cjs.map +1 -0
- package/dist/react-menu.d.cts +370 -0
- package/dist/react-menu.d.ts +370 -0
- package/dist/react-menu.js +722 -0
- package/dist/react-menu.js.map +1 -0
- package/dist/react-overflow.cjs +592 -0
- package/dist/react-overflow.cjs.map +1 -0
- package/dist/react-overflow.d.cts +817 -0
- package/dist/react-overflow.d.ts +817 -0
- package/dist/react-overflow.js +571 -0
- package/dist/react-overflow.js.map +1 -0
- package/dist/react-palette.cjs +489 -0
- package/dist/react-palette.cjs.map +1 -0
- package/dist/react-palette.d.cts +359 -0
- package/dist/react-palette.d.ts +359 -0
- package/dist/react-palette.js +457 -0
- package/dist/react-palette.js.map +1 -0
- package/dist/react-selection.cjs +617 -0
- package/dist/react-selection.cjs.map +1 -0
- package/dist/react-selection.d.cts +357 -0
- package/dist/react-selection.d.ts +357 -0
- package/dist/react-selection.js +596 -0
- package/dist/react-selection.js.map +1 -0
- package/dist/react-sheet.cjs +616 -0
- package/dist/react-sheet.cjs.map +1 -0
- package/dist/react-sheet.d.cts +361 -0
- package/dist/react-sheet.d.ts +361 -0
- package/dist/react-sheet.js +595 -0
- package/dist/react-sheet.js.map +1 -0
- package/package.json +148 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react-palette.ts","../src/react/palette.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"],"sourcesContent":["/** `@ai-matrx/alchemy/react/palette` — the command palette layout. */\nexport { ActionPalette, type ActionPaletteProps } from \"./react/palette\";\n","\"use client\";\n/**\n * `@ai-matrx/alchemy/react/palette` — the command palette layout (Linear):\n * every leaf of the one model, flattened with its breadcrumb, type to filter.\n */\nimport * as React from \"react\";\nimport { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from \"@ai-matrx/design-system\";\nimport { palette } from \"../menu/layouts\";\nimport type { ClickTarget } from \"../actions/types\";\nimport { useMenuEngine, type MenuEngineOptions } from \"./engine\";\n\nexport interface ActionPaletteProps extends MenuEngineOptions {\n target: ClickTarget;\n open: boolean;\n onOpenChange(open: boolean): void;\n placeholder?: string;\n}\n\nexport function ActionPalette({ target, open, onOpenChange, placeholder = \"Search actions…\", ...options }: ActionPaletteProps): React.ReactElement {\n const engine = useMenuEngine(target, {\n ...options,\n active: open,\n onRan: (id, r) => {\n options.onRan?.(id, r);\n onOpenChange(false);\n },\n });\n const arranged = engine.model ? palette(engine.model) : { leaves: [] };\n return (\n <CommandDialog open={open} onOpenChange={onOpenChange}>\n <CommandInput placeholder={placeholder} />\n <CommandList data-alchemy-layout=\"palette\">\n <CommandEmpty>No action matches.</CommandEmpty>\n <CommandGroup>\n {arranged.leaves.map(({ node, breadcrumb }) => {\n const unavailable = node.kind === \"item\" ? node.unavailable : undefined;\n return (\n <CommandItem\n key={node.id}\n value={`${node.label} ${breadcrumb.join(\" \")} ${node.id}`}\n data-alchemy-node={node.id}\n disabled={Boolean(unavailable)}\n onSelect={() => {\n if (node.kind === \"submenu\") void engine.expand(node.id);\n else if (node.kind === \"link\") window.location.assign(node.href);\n else void engine.run(node.id);\n }}\n className=\"gap-2\"\n >\n {\"icon\" in node ? engine.icon(node.icon) : null}\n <span className=\"flex-1 truncate\">{node.label}</span>\n <span className=\"text-xs text-muted-foreground\">{unavailable ? unavailable.sentence : breadcrumb.join(\" › \")}</span>\n </CommandItem>\n );\n })}\n </CommandGroup>\n </CommandList>\n </CommandDialog>\n );\n}\n\nexport default ActionPalette;\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,2BAAkG;;;ACiClG,SAAS,OAAO,MAAsC;AACpD,SAAO,KAAK,SAAS,UAAU,KAAK,SAAS,cAAc,KAAK,SAAS;AAC3E;AAuMO,SAAS,QAAQ,OAAmC;AACzD,QAAM,SAAoC,CAAC;AAC3C,QAAM,OAAO,CAAC,OAA4B,UAAoB;AAC5D,eAAW,KAAK,OAAO;AACrB,UAAI,OAAO,CAAC,EAAG,QAAO,KAAK,EAAE,MAAM,GAAG,YAAY,MAAM,CAAC;AAAA,eAChD,EAAE,SAAS,WAAW;AAC7B,YAAI,EAAE,KAAM,QAAO,KAAK,EAAE,MAAM,GAAG,YAAY,MAAM,CAAC;AAAA,YACjD,MAAK,EAAE,UAAU,CAAC,GAAG,OAAO,EAAE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runtime"]}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TransferOutcome } from '@ai-matrx/kit/content-transfer';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Matrx Alchemy — Declare types (CONTRACT §2.1).
|
|
6
|
+
*
|
|
7
|
+
* A declaration is plain JSON data (chair ruling N2): no functions, no classes,
|
|
8
|
+
* no React. Runtime behaviour lives in `MountedSurface` (`/declare/host`) and in
|
|
9
|
+
* handler registrations, never here. Zero React, zero `@ai-matrx/agents`.
|
|
10
|
+
*/
|
|
11
|
+
type Json = null | boolean | number | string | Json[] | {
|
|
12
|
+
[key: string]: Json;
|
|
13
|
+
};
|
|
14
|
+
/** Unchanged from `ui_surface_value_type_chk`. */
|
|
15
|
+
type ValueType = "string" | "number" | "boolean" | "object" | "array" | "document";
|
|
16
|
+
type Classification = "ordinary" | "secret" | "credential";
|
|
17
|
+
/** Persisted (CONTRACT §2.7). Projection enforces it before any value leaves. */
|
|
18
|
+
interface Sensitivity {
|
|
19
|
+
/** false = never leaves through Operate. Default true. */
|
|
20
|
+
exportable: boolean;
|
|
21
|
+
/** secret/credential are always excluded; no caller can relax this. Default "ordinary". */
|
|
22
|
+
classification: Classification;
|
|
23
|
+
/** Pre-checked in the preparation workspace. Default true. */
|
|
24
|
+
includedByDefault: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface ValueGroup {
|
|
27
|
+
key: string;
|
|
28
|
+
label: string;
|
|
29
|
+
sortOrder: number;
|
|
30
|
+
description?: string;
|
|
31
|
+
}
|
|
32
|
+
/** The four runtime slots a capture fills (absorbs page-capture). */
|
|
33
|
+
type LiveSlot = "selection" | "on-demand" | "errors" | "requests";
|
|
34
|
+
interface DeclaredValue {
|
|
35
|
+
name: string;
|
|
36
|
+
label: string;
|
|
37
|
+
description: string;
|
|
38
|
+
valueType: ValueType;
|
|
39
|
+
/** Registered content-ir kind key (DB: kind_key). */
|
|
40
|
+
valueKind?: string;
|
|
41
|
+
alwaysAvailable: boolean;
|
|
42
|
+
typicalCharCount: number;
|
|
43
|
+
autoContext?: boolean;
|
|
44
|
+
group?: string;
|
|
45
|
+
sortOrder?: number;
|
|
46
|
+
sensitivity?: Partial<Sensitivity>;
|
|
47
|
+
/** Filled at capture time from a live slot instead of the scope. */
|
|
48
|
+
liveSlot?: LiveSlot;
|
|
49
|
+
/** "request" values drop out of "Only the data". Default "data". */
|
|
50
|
+
role?: "data" | "request";
|
|
51
|
+
}
|
|
52
|
+
/** Where a write lands. "stream" = applied live, op by op, into an editable text. */
|
|
53
|
+
type WriteMode = "draft" | "entity" | "ui" | "stream";
|
|
54
|
+
/** Who may apply WITHOUT a click. "queued" = filed for an organization's review. */
|
|
55
|
+
type ApplyPolicy = "manual" | "ask" | "auto" | "queued";
|
|
56
|
+
/** The WidgetHandle text op set, unchanged in meaning. */
|
|
57
|
+
type StreamOp = "replace" | "insert_before" | "insert_after" | "prepend" | "append" | "patch";
|
|
58
|
+
interface WriteTarget {
|
|
59
|
+
name: string;
|
|
60
|
+
label: string;
|
|
61
|
+
description: string;
|
|
62
|
+
valueType: ValueType;
|
|
63
|
+
valueKind?: string;
|
|
64
|
+
/** Read twin (evidence loop). Required when patchable or mode === "stream". */
|
|
65
|
+
updatesValue?: string;
|
|
66
|
+
patchable?: boolean;
|
|
67
|
+
approvalComparison?: "text-replacement";
|
|
68
|
+
mode: WriteMode;
|
|
69
|
+
/** Required iff mode === "stream". */
|
|
70
|
+
streamOps?: readonly StreamOp[];
|
|
71
|
+
/** Default "manual". Binding overrides may only tighten. */
|
|
72
|
+
applyPolicy?: ApplyPolicy;
|
|
73
|
+
destination?: boolean;
|
|
74
|
+
/** Present when the target writes into an item rather than the screen. */
|
|
75
|
+
itemType?: string;
|
|
76
|
+
group?: string;
|
|
77
|
+
sortOrder?: number;
|
|
78
|
+
}
|
|
79
|
+
/** One kind of thing inside a screen (a row, a message, a code block, a card). */
|
|
80
|
+
interface ItemType {
|
|
81
|
+
name: string;
|
|
82
|
+
label: string;
|
|
83
|
+
description: string;
|
|
84
|
+
/** Value names that together identify one item. */
|
|
85
|
+
identity: readonly string[];
|
|
86
|
+
levels?: readonly string[];
|
|
87
|
+
entityType?: string;
|
|
88
|
+
values: readonly DeclaredValue[];
|
|
89
|
+
writeTargets?: readonly WriteTarget[];
|
|
90
|
+
}
|
|
91
|
+
type Readiness = "verified" | "partial" | "stub";
|
|
92
|
+
/** `ui_surface_execution_mode_check`, unchanged. */
|
|
93
|
+
type ExecutionMode = "python-stream" | "nextjs-stream" | "browser-realtime" | "local-runtime";
|
|
94
|
+
interface ConfigNamespaceDeclaration {
|
|
95
|
+
namespace: string;
|
|
96
|
+
label: string;
|
|
97
|
+
description: string;
|
|
98
|
+
}
|
|
99
|
+
interface EvidenceSourceDeclaration {
|
|
100
|
+
kind: "processed_document";
|
|
101
|
+
idValue: string;
|
|
102
|
+
fileIdValue?: string;
|
|
103
|
+
labelValue?: string;
|
|
104
|
+
representation?: "clean" | "raw";
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* One screen's declaration. Owning packages add fields (agent roles, client
|
|
108
|
+
* tools) as EXTENSION SLOTS — by interface extension or declaration merging —
|
|
109
|
+
* and register a `DeclarationExtension` so validation and the sync cover them.
|
|
110
|
+
*/
|
|
111
|
+
interface SurfaceDeclaration {
|
|
112
|
+
surfaceName: string;
|
|
113
|
+
/** REQUIRED. `ui_surface.client_name`; must equal the surfaceName prefix. */
|
|
114
|
+
client: string;
|
|
115
|
+
/** REQUIRED. `ui_surface.execution_mode`. */
|
|
116
|
+
executionMode: ExecutionMode;
|
|
117
|
+
/** REQUIRED. `ui_surface.description` ("" only where the live row is empty). */
|
|
118
|
+
description: string;
|
|
119
|
+
label: string;
|
|
120
|
+
readiness: Readiness;
|
|
121
|
+
readinessNote?: string;
|
|
122
|
+
urlPattern?: string;
|
|
123
|
+
inheritsFrom?: string;
|
|
124
|
+
intro?: string;
|
|
125
|
+
overlayId?: string;
|
|
126
|
+
values: readonly DeclaredValue[];
|
|
127
|
+
groups?: readonly ValueGroup[];
|
|
128
|
+
writeTargets?: readonly WriteTarget[];
|
|
129
|
+
itemTypes?: readonly ItemType[];
|
|
130
|
+
liveSlots?: readonly LiveSlot[];
|
|
131
|
+
configNamespaces?: readonly ConfigNamespaceDeclaration[];
|
|
132
|
+
evidenceSources?: readonly EvidenceSourceDeclaration[];
|
|
133
|
+
skipBaselineValues?: boolean;
|
|
134
|
+
}
|
|
135
|
+
type ValueProvenance = {
|
|
136
|
+
kind: "own";
|
|
137
|
+
} | {
|
|
138
|
+
kind: "inherited";
|
|
139
|
+
from: string;
|
|
140
|
+
} | {
|
|
141
|
+
kind: "baseline";
|
|
142
|
+
};
|
|
143
|
+
type ResolvedValue = DeclaredValue & {
|
|
144
|
+
provenance: ValueProvenance;
|
|
145
|
+
groupKey: string;
|
|
146
|
+
/** Defaults filled. */
|
|
147
|
+
resolvedSensitivity: Sensitivity;
|
|
148
|
+
};
|
|
149
|
+
interface ResolvedSurfaceDeclaration extends SurfaceDeclaration {
|
|
150
|
+
contentHash: string;
|
|
151
|
+
values: readonly ResolvedValue[];
|
|
152
|
+
groups: readonly ValueGroup[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* ITEM KEYS. A value or write target is identified by (surfaceName, itemType ?? "", name).
|
|
156
|
+
* The qualified key "<itemType>.<name>" names an item value; a bare name is a screen value.
|
|
157
|
+
*/
|
|
158
|
+
type QualifiedValueKey = string;
|
|
159
|
+
/** Live slot payloads (page-capture's shapes, kept). */
|
|
160
|
+
interface LiveValues {
|
|
161
|
+
selection?: {
|
|
162
|
+
choices: Record<string, Json>;
|
|
163
|
+
text: string | null;
|
|
164
|
+
};
|
|
165
|
+
"on-demand"?: readonly OnDemandSection[];
|
|
166
|
+
errors?: readonly string[];
|
|
167
|
+
requests?: readonly RecentRequest[];
|
|
168
|
+
}
|
|
169
|
+
interface OnDemandSection {
|
|
170
|
+
id: string;
|
|
171
|
+
title: string;
|
|
172
|
+
description?: string;
|
|
173
|
+
role: "data" | "request";
|
|
174
|
+
brief?: Json;
|
|
175
|
+
load(signal: AbortSignal): Promise<Json>;
|
|
176
|
+
}
|
|
177
|
+
interface RecentRequest {
|
|
178
|
+
method: string;
|
|
179
|
+
path: string;
|
|
180
|
+
status: string;
|
|
181
|
+
httpStatus?: number;
|
|
182
|
+
durationMs?: number;
|
|
183
|
+
requestId?: string;
|
|
184
|
+
client?: string;
|
|
185
|
+
requestBody?: Json;
|
|
186
|
+
requestBodyNote?: string;
|
|
187
|
+
errorSentence?: string;
|
|
188
|
+
timestamp: number;
|
|
189
|
+
}
|
|
190
|
+
/** RAW-FREE. What leaves the package about a clicked item. */
|
|
191
|
+
interface ResolvedItem {
|
|
192
|
+
itemType: string;
|
|
193
|
+
identity: Record<string, string>;
|
|
194
|
+
level?: string;
|
|
195
|
+
readOnly: boolean;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The click target (CONTRACT §2.4) in its own module: `/ports` references it,
|
|
200
|
+
* and `/ports` must stay free of every other package (types only).
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
/** The transfer Payload's kinds (`actions/types.ts` asserts equality at compile time). */
|
|
204
|
+
type PayloadKind = "text" | "markdown" | "json" | "rows" | "registered";
|
|
205
|
+
/** What eligibility is computed from: everything declared at the click target. */
|
|
206
|
+
interface ClickTarget {
|
|
207
|
+
surface: {
|
|
208
|
+
instanceId: string;
|
|
209
|
+
surfaceName: string;
|
|
210
|
+
} | null;
|
|
211
|
+
/** The resolved declaration (inheritance applied). Eligibility decides by KEY existence over it. */
|
|
212
|
+
declaration: ResolvedSurfaceDeclaration | null;
|
|
213
|
+
/** Declared value keys with a read path here (screen names + qualified item keys). Key existence, not population. */
|
|
214
|
+
valueKeys: ReadonlySet<QualifiedValueKey>;
|
|
215
|
+
/** Scope chain, most general first: ["global", "<domain>", "<surfaceName>"]. */
|
|
216
|
+
scopeChain: readonly string[];
|
|
217
|
+
/** The surface's explicit exclusions (the one override). */
|
|
218
|
+
excludedActionIds: ReadonlySet<string>;
|
|
219
|
+
item: ResolvedItem | null;
|
|
220
|
+
level: string | null;
|
|
221
|
+
/** Offsets + the live range handle, editable or not. */
|
|
222
|
+
selection: {
|
|
223
|
+
text: string;
|
|
224
|
+
type: "editable" | "non-editable";
|
|
225
|
+
start: number;
|
|
226
|
+
end: number;
|
|
227
|
+
/** Opaque host handle (DOM Range / element) used to restore or stream into the selection. */
|
|
228
|
+
handle?: unknown;
|
|
229
|
+
} | null;
|
|
230
|
+
/** Payload kinds a capture of this target would produce (from declared value types/kinds). */
|
|
231
|
+
payloadKinds: readonly PayloadKind[];
|
|
232
|
+
/** Declared targets writable on this target right now. */
|
|
233
|
+
writable: readonly WriteTarget[];
|
|
234
|
+
readOnly: boolean;
|
|
235
|
+
/** True when any declared value here is secret/credential or non-exportable. */
|
|
236
|
+
restricted: boolean;
|
|
237
|
+
organizationId: string | null;
|
|
238
|
+
auth: {
|
|
239
|
+
authenticated: boolean;
|
|
240
|
+
admin: boolean;
|
|
241
|
+
creator: boolean;
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Host-owned context a provider reads to act (the rich-document source, the
|
|
245
|
+
* editable field's callbacks). Opaque to the package; never crosses into the
|
|
246
|
+
* model. Providers that need it narrow it themselves.
|
|
247
|
+
*/
|
|
248
|
+
host?: unknown;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Matrx Alchemy — Actions types (CONTRACT §2.4).
|
|
253
|
+
*
|
|
254
|
+
* One registry of everything a person can do to a thing. Providers plug in;
|
|
255
|
+
* eligibility is computed from what is declared at the click target; duplicate
|
|
256
|
+
* ids are refused; an action that does not apply is ABSENT (chair ruling R1).
|
|
257
|
+
*
|
|
258
|
+
* Framework-neutral: zero React, zero `@ai-matrx/agents`. Icons are string KEYS
|
|
259
|
+
* resolved by the host's `IconResolverPort`; labels go through `I18nPort`.
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
/** rich-document's ActionCategory, unchanged, plus the three the context menu groups by. */
|
|
263
|
+
type ActionCategory = "feedback" | "copy" | "export" | "save" | "edit" | "share" | "creator" | "app" | "listen" | "study" | "ask" | "ai" | "admin" | "clipboard" | "history" | "surface-info";
|
|
264
|
+
interface ResolveRestriction {
|
|
265
|
+
exclude?: readonly string[];
|
|
266
|
+
categories?: readonly ActionCategory[];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* `@ai-matrx/alchemy/declare/host` — HOST-BINDING types only (CONTRACT §2.1, §2.6).
|
|
271
|
+
* Never imported by providers (`/declare`, `/actions`, `/menu`, `/operate` see only
|
|
272
|
+
* the raw-free `ResolvedItem`). Types only: no runtime code.
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
interface ItemAnchor {
|
|
276
|
+
/** The host element the person clicked. */
|
|
277
|
+
element: unknown;
|
|
278
|
+
level?: string;
|
|
279
|
+
}
|
|
280
|
+
/** Raw item reads: consumed only by projection and the write handler that owns the target. */
|
|
281
|
+
interface InternalResolvedItem extends ResolvedItem {
|
|
282
|
+
readValues(signal: AbortSignal): Promise<Record<string, unknown>>;
|
|
283
|
+
}
|
|
284
|
+
/** A mounted instance of a declared surface. Structural handle, never a global name lookup. */
|
|
285
|
+
interface MountedSurface {
|
|
286
|
+
instanceId: string;
|
|
287
|
+
surfaceName: string;
|
|
288
|
+
isMounted(): boolean;
|
|
289
|
+
/** Same revision before and after a read, or capture refuses with "surface-changed". */
|
|
290
|
+
getRevision?(): string;
|
|
291
|
+
unsavedChanges?(): boolean;
|
|
292
|
+
readValues(signal: AbortSignal): Promise<Record<string, unknown>>;
|
|
293
|
+
readLive?(signal: AbortSignal): Promise<LiveValues>;
|
|
294
|
+
resolveItem?(anchor: ItemAnchor): InternalResolvedItem | null;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
interface ProjectionSource {
|
|
298
|
+
surface: MountedSurface | null;
|
|
299
|
+
declaration: ResolvedSurfaceDeclaration | null;
|
|
300
|
+
item: InternalResolvedItem | null;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* The one run path (T1e). Every layout runs an action through here, so the
|
|
305
|
+
* sign-in-then-resume rule, projection and failure capture live once.
|
|
306
|
+
*/
|
|
307
|
+
|
|
308
|
+
type RunResult = {
|
|
309
|
+
status: "ran";
|
|
310
|
+
outcome: TransferOutcome | void;
|
|
311
|
+
} | {
|
|
312
|
+
status: "auth-pending";
|
|
313
|
+
} | {
|
|
314
|
+
status: "failed";
|
|
315
|
+
error: unknown;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* The React half of T1e: one hook every renderer uses to resolve the registry
|
|
320
|
+
* at a target, build the model and run a node. Handlers never live in a
|
|
321
|
+
* renderer — they live in providers and run through `runAction`.
|
|
322
|
+
*
|
|
323
|
+
* The context object is shared through globalThis so every per-layout entry
|
|
324
|
+
* (each bundled separately) reads the same provider (module state is banned
|
|
325
|
+
* across dual-loader graphs).
|
|
326
|
+
*/
|
|
327
|
+
|
|
328
|
+
interface MenuEngineOptions {
|
|
329
|
+
restrict?: ResolveRestriction;
|
|
330
|
+
/** Raw sources for projection (the host's mounted surface / clicked item). */
|
|
331
|
+
source?: ProjectionSource;
|
|
332
|
+
/** Content the menu acts on when nothing is selected (header text). */
|
|
333
|
+
content?: string | null;
|
|
334
|
+
contentFingerprint?: string;
|
|
335
|
+
/** Called after a node ran (close the menu, announce). */
|
|
336
|
+
onRan?: (nodeId: string, result: RunResult) => void;
|
|
337
|
+
/** Resolve only while true (renderers resolve on open). Default true. */
|
|
338
|
+
active?: boolean;
|
|
339
|
+
/**
|
|
340
|
+
* Re-resolve when this changes even if the target object is the same (a
|
|
341
|
+
* host that keeps one target per mount and reads live state through it).
|
|
342
|
+
*/
|
|
343
|
+
revision?: string | number;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* `@ai-matrx/alchemy/react/palette` — the command palette layout (Linear):
|
|
348
|
+
* every leaf of the one model, flattened with its breadcrumb, type to filter.
|
|
349
|
+
*/
|
|
350
|
+
|
|
351
|
+
interface ActionPaletteProps extends MenuEngineOptions {
|
|
352
|
+
target: ClickTarget;
|
|
353
|
+
open: boolean;
|
|
354
|
+
onOpenChange(open: boolean): void;
|
|
355
|
+
placeholder?: string;
|
|
356
|
+
}
|
|
357
|
+
declare function ActionPalette({ target, open, onOpenChange, placeholder, ...options }: ActionPaletteProps): React.ReactElement;
|
|
358
|
+
|
|
359
|
+
export { ActionPalette, type ActionPaletteProps };
|