@particle-academy/fancy-flow 0.66.0 → 0.66.1
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/dist/chunk-27RZJAE2.js +2586 -0
- package/dist/chunk-27RZJAE2.js.map +1 -0
- package/dist/{chunk-FNYLKSFJ.js → chunk-2QTEELJE.js} +4 -3
- package/dist/chunk-2QTEELJE.js.map +1 -0
- package/dist/{chunk-MTONBM53.js → chunk-6AYC3BWI.js} +4 -4
- package/dist/{chunk-MTONBM53.js.map → chunk-6AYC3BWI.js.map} +1 -1
- package/dist/{chunk-IEYCNFXZ.js → chunk-6TH646CS.js} +127 -5
- package/dist/chunk-6TH646CS.js.map +1 -0
- package/dist/{chunk-UCCTXJXL.js → chunk-BUNFPBTF.js} +5 -4
- package/dist/chunk-BUNFPBTF.js.map +1 -0
- package/dist/{chunk-B7HKJJVV.js → chunk-FV3D366L.js} +3 -3
- package/dist/{chunk-B7HKJJVV.js.map → chunk-FV3D366L.js.map} +1 -1
- package/dist/{chunk-HQGOFGAL.js → chunk-OWENS2H5.js} +64 -2754
- package/dist/chunk-OWENS2H5.js.map +1 -0
- package/dist/{chunk-PNHZHEWE.js → chunk-RE3XNVSB.js} +3 -3
- package/dist/{chunk-PNHZHEWE.js.map → chunk-RE3XNVSB.js.map} +1 -1
- package/dist/durable.cjs +153 -9213
- package/dist/durable.cjs.map +1 -1
- package/dist/durable.js +1 -2
- package/dist/durable.js.map +1 -1
- package/dist/engine.cjs +103 -9165
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.js +4 -5
- package/dist/engine.js.map +1 -1
- package/dist/index.cjs +11135 -11121
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -13
- package/dist/index.js.map +1 -1
- package/dist/registry/index.d.cts +15 -3
- package/dist/registry/index.d.ts +15 -3
- package/dist/registry.cjs +11166 -11153
- package/dist/registry.cjs.map +1 -1
- package/dist/registry.js +4 -3
- package/dist/runtime.cjs +10772 -10924
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +4 -4
- package/dist/schema.cjs +85 -9147
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.js +3 -4
- package/dist/screens.cjs +7 -52
- package/dist/screens.cjs.map +1 -1
- package/dist/screens.js +6 -5
- package/dist/screens.js.map +1 -1
- package/dist/ux.cjs +89 -9147
- package/dist/ux.cjs.map +1 -1
- package/dist/ux.js +1 -2
- package/dist/ux.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-FNYLKSFJ.js.map +0 -1
- package/dist/chunk-HQGOFGAL.js.map +0 -1
- package/dist/chunk-IEYCNFXZ.js.map +0 -1
- package/dist/chunk-UCCTXJXL.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { applyNodeChanges, applyEdgeChanges, addEdge } from './chunk-OWENS2H5.js';
|
|
2
|
+
import { runFlow, getNodeKind } from './chunk-27RZJAE2.js';
|
|
2
3
|
import { useState, useRef, useCallback, useMemo } from 'react';
|
|
3
4
|
|
|
4
5
|
function useFlowRun({ maxFeed = 200 } = {}) {
|
|
@@ -234,5 +235,5 @@ function useFlowHistory(flow) {
|
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
export { applyOutputsToNodes, applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState };
|
|
237
|
-
//# sourceMappingURL=chunk-
|
|
238
|
-
//# sourceMappingURL=chunk-
|
|
238
|
+
//# sourceMappingURL=chunk-2QTEELJE.js.map
|
|
239
|
+
//# sourceMappingURL=chunk-2QTEELJE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/use-flow-run.ts","../src/runtime/use-flow-state.ts","../src/runtime/history.ts","../src/runtime/use-flow-history.ts"],"names":["useState","useCallback","useRef"],"mappings":";;;;AA8DO,SAAS,WAAW,EAAE,OAAA,GAAU,GAAA,EAAI,GAAuB,EAAC,EAAqB;AACtF,EAAA,MAAM,CA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;AAAA,IACA,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAAA,IACzB,OAAA,EAAS,QAAQ,OAAA,EAAQ;AAAA,IACzB,OAAA;AAAA,IACA,eAAA,EAAiB;AAAA,GACnB;AACF","file":"chunk-2QTEELJE.js","sourcesContent":["import { useCallback, useRef, useState } from \"react\";\nimport { runFlow, type RunOptions, type RunResult } from \"./run-flow\";\nimport { getNodeKind } from \"../registry/registry\";\nimport type {\n ExecutorRegistry,\n FlowGraph,\n NodeRunStatus,\n RunEvent,\n} from \"../types\";\n\nexport type FlowRunFeedEntry = {\n id: string;\n at: number;\n /**\n * `message` is a node's own human-facing announcement (`startingMsg` /\n * `stoppingMsg`), kept distinct from `status` and `info` so a progress UI can\n * show ONLY the narration. Folded in with diagnostics it would be unfindable,\n * which is the same as not having it.\n */\n level: \"info\" | \"warn\" | \"error\" | \"status\" | \"message\";\n text: string;\n nodeId?: string;\n detail?: unknown;\n};\n\nexport type UseFlowRunReturn = {\n /** Status keyed by nodeId — drive the UI overlay from this. */\n statuses: Record<string, NodeRunStatus>;\n /** Per-node status text (e.g. error message). */\n statusText: Record<string, string | undefined>;\n /** Latest computed output value per node (for reactive kinds). */\n outputs: Record<string, unknown>;\n /**\n * Latest status message per nodeId, from the node's own `startingMsg` /\n * `stoppingMsg`. Undefined for the nodes that declared none, which is most\n * of them by design.\n */\n nodeMessages: Record<string, string | undefined>;\n /** Live event log (capped to last N). */\n feed: FlowRunFeedEntry[];\n /** Whether a run is currently in progress. */\n running: boolean;\n /** Last run result, or null. */\n lastResult: RunResult | null;\n /** Kick off a run with the provided graph + executors. */\n run: (graph: FlowGraph, executors: ExecutorRegistry, options?: RunOptions) => Promise<RunResult>;\n /** Cancel the current run (if any). */\n cancel: () => void;\n /** Reset all runtime state (statuses, feed, lastResult). */\n reset: () => void;\n};\n\nexport type UseFlowRunOptions = {\n /** Cap the in-memory feed to this many entries. Default 200. */\n maxFeed?: number;\n};\n\n/**\n * useFlowRun — drives `runFlow` + maintains observability state. Pair with\n * `applyStatusesToNodes` (below) before passing nodes to `<FlowCanvas>` so\n * the per-node status badge renders.\n */\nexport function useFlowRun({ maxFeed = 200 }: UseFlowRunOptions = {}): UseFlowRunReturn {\n const [statuses, setStatuses] = useState<Record<string, NodeRunStatus>>({});\n const [statusText, setStatusText] = useState<Record<string, string | undefined>>({});\n const [nodeMessages, setNodeMessages] = useState<Record<string, string | undefined>>({});\n const [outputs, setOutputs] = useState<Record<string, unknown>>({});\n const [feed, setFeed] = useState<FlowRunFeedEntry[]>([]);\n const [running, setRunning] = useState(false);\n const [lastResult, setLastResult] = useState<RunResult | null>(null);\n const abortRef = useRef<AbortController | null>(null);\n\n const handleEvent = useCallback(\n (e: RunEvent) => {\n switch (e.type) {\n case \"node-status\":\n setStatuses((s) => ({ ...s, [e.nodeId]: e.status }));\n setStatusText((t) => ({ ...t, [e.nodeId]: e.text }));\n appendFeed({ level: \"status\", text: `${e.nodeId} → ${e.status}${e.text ? ` (${e.text})` : \"\"}`, nodeId: e.nodeId });\n break;\n case \"node-message\":\n setNodeMessages((m) => ({ ...m, [e.nodeId]: e.message }));\n appendFeed({ level: \"message\", text: e.message, nodeId: e.nodeId });\n break;\n case \"node-output\":\n setOutputs((o) => ({ ...o, [e.nodeId]: e.value }));\n appendFeed({ level: \"info\", text: `${e.nodeId}.${e.portId} = ${preview(e.value)}`, nodeId: e.nodeId, detail: e.value });\n break;\n case \"log\":\n appendFeed({ level: e.level, text: e.message, nodeId: e.nodeId, detail: e.detail });\n break;\n case \"run-start\":\n appendFeed({ level: \"info\", text: \"▶ run started\" });\n break;\n case \"run-end\":\n appendFeed({ level: e.ok ? \"info\" : \"error\", text: e.ok ? \"✓ run complete\" : \"✗ run failed\" });\n break;\n case \"run-error\":\n appendFeed({ level: \"error\", text: e.error });\n break;\n }\n function appendFeed(partial: Omit<FlowRunFeedEntry, \"id\" | \"at\">) {\n setFeed((f) => {\n const entry: FlowRunFeedEntry = { id: `${Date.now()}_${f.length}`, at: Date.now(), ...partial };\n const next = [...f, entry];\n return next.length > maxFeed ? next.slice(next.length - maxFeed) : next;\n });\n }\n },\n [maxFeed],\n );\n\n const run = useCallback(\n async (graph: FlowGraph, executors: ExecutorRegistry, options: RunOptions = {}) => {\n if (running) {\n return { ok: false, outputs: {}, error: \"another run is already in progress\" } satisfies RunResult;\n }\n const controller = new AbortController();\n abortRef.current = controller;\n // Reset previous statuses for the nodes we're about to run.\n const idleStatuses: Record<string, NodeRunStatus> = {};\n for (const n of graph.nodes) idleStatuses[n.id] = \"idle\";\n setStatuses(idleStatuses);\n setStatusText({});\n setOutputs({});\n setRunning(true);\n try {\n const result = await runFlow(graph, executors, handleEvent, { ...options, signal: controller.signal });\n setLastResult(result);\n return result;\n } finally {\n setRunning(false);\n abortRef.current = null;\n }\n },\n [handleEvent, running],\n );\n\n const cancel = useCallback(() => abortRef.current?.abort(), []);\n\n const reset = useCallback(() => {\n setStatuses({});\n setStatusText({});\n setOutputs({});\n setFeed([]);\n setLastResult(null);\n }, []);\n\n return { statuses, statusText, nodeMessages, outputs, feed, running, lastResult, run, cancel, reset };\n}\n\n/**\n * Write each reactive kind's latest run output into its `data.output`, so its\n * card can render the computed value live. Non-reactive kinds are returned\n * untouched. Pair with `applyStatusesToNodes` before rendering.\n */\nexport function applyOutputsToNodes<TNode extends { id: string; type?: string; data: any }>(\n nodes: TNode[],\n outputs: Record<string, unknown>,\n): TNode[] {\n return nodes.map((n) => {\n const kind = getNodeKind((n.data as any)?.kind ?? n.type ?? \"\");\n if (!kind?.reactive || !(n.id in outputs)) return n;\n return { ...n, data: { ...n.data, output: outputs[n.id] } };\n });\n}\n\n/** Merge runtime statuses into nodes for rendering. */\nexport function applyStatusesToNodes<TNode extends { id: string; data: any }>(\n nodes: TNode[],\n statuses: Record<string, NodeRunStatus>,\n statusText: Record<string, string | undefined>,\n): TNode[] {\n return nodes.map((n) => ({\n ...n,\n data: {\n ...n.data,\n status: statuses[n.id] ?? n.data?.status ?? \"idle\",\n statusText: statusText[n.id] ?? n.data?.statusText,\n },\n }));\n}\n\nfunction preview(v: unknown): string {\n try {\n const s = JSON.stringify(v);\n return s && s.length > 60 ? s.slice(0, 57) + \"…\" : (s ?? String(v));\n } catch {\n return String(v);\n }\n}\n","import { useCallback, useState } from \"react\";\nimport {\n addEdge,\n applyEdgeChanges,\n applyNodeChanges,\n type Connection,\n type Edge,\n type EdgeChange,\n type NodeChange,\n} from \"@xyflow/react\";\nimport type { FlowEdge, FlowGraph, FlowNode } from \"../types\";\n\nexport type UseFlowStateReturn = {\n nodes: FlowNode[];\n edges: FlowEdge[];\n setNodes: React.Dispatch<React.SetStateAction<FlowNode[]>>;\n setEdges: React.Dispatch<React.SetStateAction<FlowEdge[]>>;\n /**\n * Replace nodes AND edges atomically in a single commit. Use this for any op\n * that touches both (delete-with-edge-prune, undo/redo restore, setGraph):\n * calling `setNodes` then `setEdges` is NOT atomic in controlled mode (each\n * closes over a stale `value`), so the second write clobbers the first.\n */\n setGraph: (graph: FlowGraph) => void;\n onNodesChange: (changes: NodeChange[]) => void;\n onEdgesChange: (changes: EdgeChange[]) => void;\n onConnect: (connection: Connection) => void;\n /** Snapshot the current graph (suitable for serialization). */\n toGraph: () => FlowGraph;\n};\n\n/**\n * useFlowState — React Flow's standard controlled-state plumbing in one hook.\n * Spread into <FlowCanvas>.\n */\nexport function useFlowState(initial: FlowGraph): UseFlowStateReturn {\n const [nodes, setNodes] = useState<FlowNode[]>(initial.nodes);\n const [edges, setEdges] = useState<FlowEdge[]>(initial.edges);\n\n const onNodesChange = useCallback((changes: NodeChange[]) => {\n setNodes((ns) => applyNodeChanges(changes, ns) as FlowNode[]);\n }, []);\n const onEdgesChange = useCallback((changes: EdgeChange[]) => {\n setEdges((es) => applyEdgeChanges(changes, es));\n }, []);\n const onConnect = useCallback((connection: Connection) => {\n setEdges((es) => addEdge(connection, es) as Edge[]);\n }, []);\n\n const setGraph = useCallback((graph: FlowGraph) => {\n // Two useState writes in one event are batched, so this IS atomic here.\n setNodes(graph.nodes);\n setEdges(graph.edges);\n }, []);\n\n const toGraph = useCallback(() => ({ nodes, edges }), [nodes, edges]);\n\n return { nodes, edges, setNodes, setEdges, setGraph, onNodesChange, onEdgesChange, onConnect, toGraph };\n}\n","import type { FlowGraph } from \"../types\";\n\n/**\n * Undo/redo history — a pure, React-free snapshot controller. The editor pushes\n * a graph snapshot BEFORE each committing mutation; `undo`/`redo` swap snapshots\n * between the past/future stacks. Kept free of React so it can be unit-tested\n * and reused by any host (or a headless driver).\n *\n * Coalescing (collapsing a burst of setState calls from one logical op into a\n * single undo step) is the caller's job — see `useFlowHistory`.\n */\nexport type HistoryController = {\n /** Record `graph` as an undo point. Clears the redo stack (new branch). */\n push: (graph: FlowGraph) => void;\n /** Pop the last undo point; `current` is pushed onto the redo stack. */\n undo: (current: FlowGraph) => FlowGraph | null;\n /** Pop the last redo point; `current` is pushed back onto the undo stack. */\n redo: (current: FlowGraph) => FlowGraph | null;\n canUndo: () => boolean;\n canRedo: () => boolean;\n clear: () => void;\n /** Test/inspection helper — sizes of the two stacks. */\n size: () => { past: number; future: number };\n};\n\nexport function createHistory(limit = 100): HistoryController {\n let past: FlowGraph[] = [];\n let future: FlowGraph[] = [];\n\n return {\n push(graph) {\n past.push(graph);\n if (past.length > limit) past.shift();\n future = [];\n },\n undo(current) {\n const prev = past.pop();\n if (prev === undefined) return null;\n future.push(current);\n return prev;\n },\n redo(current) {\n const next = future.pop();\n if (next === undefined) return null;\n past.push(current);\n return next;\n },\n canUndo: () => past.length > 0,\n canRedo: () => future.length > 0,\n clear() {\n past = [];\n future = [];\n },\n size: () => ({ past: past.length, future: future.length }),\n };\n}\n","import { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { EdgeChange, NodeChange } from \"@xyflow/react\";\nimport type { FlowGraph } from \"../types\";\nimport { createHistory } from \"./history\";\nimport type { UseFlowStateReturn } from \"./use-flow-state\";\n\nexport type UseFlowHistoryReturn = {\n /** The flow sink wrapped so committing mutations snapshot for undo first. */\n flow: UseFlowStateReturn;\n undo: () => void;\n redo: () => void;\n canUndo: boolean;\n canRedo: boolean;\n /** Snapshot the current graph as an undo point (before a programmatic edit). */\n capture: () => void;\n /** Wire to `<FlowCanvas onNodeDragStart>` — snapshots the pre-drag graph. */\n onNodeDragStart: () => void;\n};\n\n/**\n * useFlowHistory — the commit/undo pipeline. Wraps a flow sink (the uncontrolled\n * `useFlowState` hook OR the controlled adapter) so every *committing* mutation\n * records a snapshot first, giving undo/redo without the editor threading\n * history through each call site. This is the single interception point the\n * two-sink architecture otherwise lacks.\n *\n * Granularity: a burst of setState calls from one logical op (e.g. a\n * delete = setNodes+setEdges) is coalesced into ONE undo step; transient\n * interactive changes (drag-move, dimension-measure, selection) are NOT captured\n * — a drag is captured once at `onNodeDragStart` instead.\n */\nexport function useFlowHistory(flow: UseFlowStateReturn): UseFlowHistoryReturn {\n const history = useRef(createHistory()).current;\n const restoring = useRef(false);\n const coalesced = useRef(false);\n const [, bump] = useState(0);\n const rerender = useCallback(() => bump((n) => n + 1), []);\n\n // Latest graph via a ref, so capture never reads a stale snapshot.\n const graphRef = useRef<FlowGraph>({ nodes: flow.nodes, edges: flow.edges });\n graphRef.current = { nodes: flow.nodes, edges: flow.edges };\n\n const capture = useCallback(() => {\n if (restoring.current || coalesced.current) return;\n coalesced.current = true;\n queueMicrotask(() => {\n coalesced.current = false;\n });\n history.push(graphRef.current);\n rerender();\n }, [history, rerender]);\n\n const restore = useCallback(\n (g: FlowGraph | null) => {\n if (!g) return;\n restoring.current = true;\n flow.setGraph(g);\n queueMicrotask(() => {\n restoring.current = false;\n });\n rerender();\n },\n [flow, rerender],\n );\n\n const undo = useCallback(() => restore(history.undo(graphRef.current)), [history, restore]);\n const redo = useCallback(() => restore(history.redo(graphRef.current)), [history, restore]);\n\n const wrapped = useMemo<UseFlowStateReturn>(\n () => ({\n ...flow,\n setNodes: (next) => {\n capture();\n flow.setNodes(next);\n },\n setEdges: (next) => {\n capture();\n flow.setEdges(next);\n },\n setGraph: (g) => {\n capture();\n flow.setGraph(g);\n },\n onNodesChange: (changes: NodeChange[]) => {\n // Only structural removes commit; position/dimensions/select are transient.\n if (!restoring.current && changes.some((c) => c.type === \"remove\")) capture();\n flow.onNodesChange(changes);\n },\n onEdgesChange: (changes: EdgeChange[]) => {\n if (!restoring.current && changes.some((c) => c.type === \"remove\")) capture();\n flow.onEdgesChange(changes);\n },\n onConnect: (conn) => {\n capture();\n flow.onConnect(conn);\n },\n }),\n [flow, capture],\n );\n\n return {\n flow: wrapped,\n undo,\n redo,\n canUndo: history.canUndo(),\n canRedo: history.canRedo(),\n capture,\n onNodeDragStart: capture,\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { checkGraphConnectivity } from './chunk-
|
|
2
|
-
import { resolveNodePorts, getNodeKind, defaultConfigFor, validateConfig } from './chunk-
|
|
1
|
+
import { checkGraphConnectivity } from './chunk-FV3D366L.js';
|
|
2
|
+
import { resolveNodePorts, getNodeKind, defaultConfigFor, validateConfig } from './chunk-27RZJAE2.js';
|
|
3
3
|
|
|
4
4
|
// src/schema/workflow-schema.ts
|
|
5
5
|
var WORKFLOW_SCHEMA_VERSION = 1;
|
|
@@ -168,5 +168,5 @@ function workflowToBlob(schema) {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
export { WORKFLOW_SCHEMA_URL, WORKFLOW_SCHEMA_VERSION, exportWorkflow, importWorkflow, migrateSchema, workflowToBlob };
|
|
171
|
-
//# sourceMappingURL=chunk-
|
|
172
|
-
//# sourceMappingURL=chunk-
|
|
171
|
+
//# sourceMappingURL=chunk-6AYC3BWI.js.map
|
|
172
|
+
//# sourceMappingURL=chunk-6AYC3BWI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schema/workflow-schema.ts"],"names":[],"mappings":";;;;AAMO,IAAM,uBAAA,GAA0B;AAChC,IAAM,mBAAA,GAAsB;AAwH5B,SAAS,cAAA,CACd,KAA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AA,CAAO,KAAK,GAAG,sBAAA,CAAuB,EAAE,KAAA,EAAO,KAAA,EAAO,CAAC,CAAA;AAEvD,EAAA,MAAM,KAAK,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA,KAAM,CAAA,CAAE,UAAU,OAAO,CAAA;AAKlD,EAAA,MAAM,iBAAiB,KAAA,CAAM,OAAA,CAAQ,EAAE,MAAM,CAAA,GACxC,EAAE,MAAA,CAA2B,MAAA;AAAA,IAC5B,CAAC,UACC,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,QAAA,IAAY,OAAQ,KAAA,CAAwB,IAAA,KAAS;AAAA,GAC5F,GACA,MAAA;AAEJ,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA,KAAA,EAAO;AAAA,MACL,KAAA;AAAA,MACA,KAAA;AAAA,MACA,GAAI,kBAAkB,cAAA,CAAe,MAAA,GAAS,IAAI,EAAE,MAAA,EAAQ,cAAA,EAAe,GAAI;AAAC,KAClF;AAAA,IACA;AAAA,GACF;AACF;AAGO,SAAS,eAAe,MAAA,EAA8B;AAC3D,EAAA,OAAO,IAAI,IAAA,CAAK,CAAC,IAAA,CAAK,SAAA,CAAU,MAAA,EAAQ,IAAA,EAAM,CAAC,CAAC,CAAA,EAAG,EAAE,IAAA,EAAM,oBAAoB,CAAA;AACjF","file":"chunk-MTONBM53.js","sourcesContent":["import type { FlowEdge, FlowGraph, FlowNode, PortDescriptor, WorkflowInput } from \"../types\";\nimport { checkGraphConnectivity } from \"../analysis/graph-connectivity\";\nimport { defaultConfigFor, getNodeKind, validateConfig } from \"../registry/registry\";\nimport { resolveNodePorts } from \"../registry/ports\";\n\n/** Schema version. Bump on breaking shape changes; add migrations as needed. */\nexport const WORKFLOW_SCHEMA_VERSION = 1 as const;\nexport const WORKFLOW_SCHEMA_URL = \"https://particle.academy/schemas/workflow/v1.json\";\n\nexport type WorkflowSchema = {\n $schema: typeof WORKFLOW_SCHEMA_URL;\n version: typeof WORKFLOW_SCHEMA_VERSION;\n metadata?: WorkflowMetadata;\n /**\n * What this workflow accepts at run start, passed BY NAME.\n *\n * Lives beside `graph` rather than inside it because it describes the\n * workflow's CONTRACT, not its topology: a caller reads this to know what to\n * pass, and reading it should not mean walking nodes looking for a trigger.\n *\n * Omitted entirely when a workflow takes none, so every existing saved\n * document is unchanged byte for byte.\n */\n inputs?: WorkflowInput[];\n graph: {\n nodes: WorkflowSchemaNode[];\n edges: WorkflowSchemaEdge[];\n };\n view?: {\n viewport?: { x: number; y: number; zoom: number };\n };\n};\n\nexport type WorkflowMetadata = {\n id?: string;\n name?: string;\n description?: string;\n createdAt?: number;\n updatedAt?: number;\n author?: string;\n tags?: string[];\n};\n\nexport type WorkflowSchemaNode = {\n id: string;\n /** Registry kind name (e.g. \"memory_store\"). */\n kind: string;\n position: { x: number; y: number };\n label?: string;\n description?: string;\n /**\n * Announced to a person just before / just after this node runs. Omitted\n * entirely when unset, so a graph of ordinary plumbing nodes does not carry\n * a pair of empty keys per node and every diff of a saved graph stays\n * readable.\n */\n startingMsg?: string;\n stoppingMsg?: string;\n config?: Record<string, unknown>;\n /**\n * Resolved ports, written on export.\n *\n * A kind may derive its ports from config (`switch_case` cases,\n * `llm_branch` routes), and that derivation is a JavaScript function — a\n * runtime in another language cannot execute it. Without the resolved ports\n * in the document, the PHP twin sees no declared outputs and falls back to a\n * single `out`, so every branch edge in an exported flow silently stops\n * firing. Serializing them keeps the schema self-describing and preserves\n * the cross-runtime guarantee: same JSON in, same routing out.\n *\n * Optional and additive — a hand-written schema may omit them, and each\n * runtime then falls back to its own kind registry.\n */\n inputs?: PortDescriptor[];\n outputs?: PortDescriptor[];\n /**\n * Node grouping and visual layout — additive + optional. `parentId`/`extent`\n * say which container a node sits in (swimlanes); `width`/`height` carry an\n * explicit (resized) size; `style` carries inline presentation.\n *\n * **`parentId` is NOT decoration, and a runtime that drops it is wrong.** It\n * decides which terminal a node talks to — a terminal lane owns one session\n * and membership is this field, deliberately, so there is no second copy of\n * the grouping in each node's config to drift from what the canvas shows.\n *\n * This comment used to say these fields exist \"purely for the canvas\", so a\n * runtime that only walks edges and ports could ignore all of them. The\n * Python twin read that literally and carried none of them: a graph loaded\n * there and saved back lost every grouping a person had drawn, silently. The\n * sentence was true when it was written and became false without being\n * revisited, which is the more common way a comment does harm.\n *\n * An older reader that does not know these fields still drops them — that is\n * forward-compatibility, not permission.\n */\n parentId?: string;\n extent?: \"parent\" | [[number, number], [number, number]];\n width?: number;\n height?: number;\n style?: Record<string, unknown>;\n};\n\nexport type WorkflowSchemaEdge = {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n label?: string;\n};\n\nexport type ImportIssue = {\n level: \"error\" | \"warning\";\n nodeId?: string;\n edgeId?: string;\n message: string;\n};\n\nexport type ImportResult = {\n graph: FlowGraph;\n issues: ImportIssue[];\n /** True when the import produced a usable graph (errors may have been\n * rewritten to warnings via `lenient: true`). */\n ok: boolean;\n};\n\n/** Snapshot the in-memory graph as a portable WorkflowSchema. */\nexport function exportWorkflow(\n graph: FlowGraph,\n metadata?: WorkflowMetadata,\n view?: WorkflowSchema[\"view\"],\n): WorkflowSchema {\n return {\n $schema: WORKFLOW_SCHEMA_URL,\n version: WORKFLOW_SCHEMA_VERSION,\n metadata: metadata ? { ...metadata, updatedAt: Date.now() } : undefined,\n // Round-trips, or a saved workflow silently forgets its own contract and\n // every caller's props become \"unknown input\" on the next load.\n ...(graph.inputs && graph.inputs.length > 0 ? { inputs: graph.inputs } : {}),\n graph: {\n nodes: graph.nodes.map(toSchemaNode),\n edges: graph.edges.map(toSchemaEdge),\n },\n view,\n };\n}\n\nfunction toSchemaNode(n: FlowNode): WorkflowSchemaNode {\n const data: any = n.data ?? {};\n const kindName = data.kind ?? n.type ?? \"custom\";\n // Resolve through the same helper the canvas and runtime use, so a\n // config-driven kind writes its ACTUAL ports into the document instead of\n // leaving another language's runtime to guess at them.\n const ports = resolveNodePorts(n, getNodeKind(kindName) ?? undefined);\n const node = n as any;\n return {\n id: n.id,\n kind: kindName,\n position: { x: n.position.x, y: n.position.y },\n label: data.label,\n description: data.description,\n ...(typeof data.startingMsg === \"string\" && data.startingMsg !== \"\" ? { startingMsg: data.startingMsg } : {}),\n ...(typeof data.stoppingMsg === \"string\" && data.stoppingMsg !== \"\" ? { stoppingMsg: data.stoppingMsg } : {}),\n config: data.config,\n inputs: ports.inputs,\n outputs: ports.outputs,\n // Visual layout — only when explicitly set (never persist auto-`measured`\n // dimensions, which are derived, not authored).\n ...(node.parentId ? { parentId: node.parentId } : {}),\n ...(node.extent ? { extent: node.extent } : {}),\n ...(typeof node.width === \"number\" ? { width: node.width } : {}),\n ...(typeof node.height === \"number\" ? { height: node.height } : {}),\n ...(node.style ? { style: node.style } : {}),\n };\n}\n\nfunction toSchemaEdge(e: FlowEdge): WorkflowSchemaEdge {\n return {\n id: e.id,\n source: e.source,\n target: e.target,\n sourceHandle: e.sourceHandle ?? undefined,\n targetHandle: e.targetHandle ?? undefined,\n label: typeof e.label === \"string\" ? e.label : undefined,\n };\n}\n\nexport type ImportOptions = {\n /** When true, unknown kinds become warnings + a \"custom\" placeholder\n * instead of errors. Default false. */\n lenient?: boolean;\n};\n\n/** A migration step: takes a version-N document to version N+1. */\nexport type MigrationStep = (schema: Record<string, unknown>) => Record<string, unknown>;\n\n/**\n * Every migration step, keyed by the version it upgrades FROM.\n *\n * Empty today because v1 is current — when a BREAKING bump lands, add the step\n * here and every stored document upgrades on read, in this runtime and its\n * PHP and Python twins.\n */\nexport const MIGRATIONS: Record<number, MigrationStep> = {};\n\n/**\n * Migrate a raw schema object up to the current version, as far as it can go.\n *\n * Additive changes need no migration — an older document simply lacks the newer\n * optional fields. This is the seam for a future BREAKING bump, and\n * `importWorkflow` runs it before validating the version.\n *\n * ## The three rules, each with a reason\n *\n * - **A PAST version migrates forward**, step by step, to the current one.\n * - **A FUTURE version is left ALONE.** We cannot know what a later schema\n * means, and migrating downward would be guessing. Untouched hands it to the\n * version check, which reports it honestly.\n * - **A GAP in the table is left alone too.** A missing step is not a licence\n * to guess.\n *\n * ## Why `steps` is a parameter\n *\n * With only v1 in existence there is no old document to migrate, so a seam\n * tested against the built-in (empty) table is a check that CANNOT fail — it\n * would pass identically against a function that returned its input untouched,\n * which is what this was until the twins needed the same seam.\n *\n * The PHP and Python runtimes carry the identical shape. That mattered more\n * than it sounds: they had no migration at all and errored on any version\n * mismatch, so a v2 bump would have made every stored Op unreadable on exactly\n * the runtimes where durable runs resume.\n */\nexport function migrateSchema(\n schema: unknown,\n steps: Record<number, MigrationStep> = MIGRATIONS,\n): unknown {\n if (!schema || typeof schema !== \"object\") return schema;\n\n const doc = schema as Record<string, unknown>;\n let version = doc.version;\n\n if (typeof version !== \"number\" || !Number.isInteger(version) || version >= WORKFLOW_SCHEMA_VERSION) {\n return schema;\n }\n\n let out = doc;\n while (version < WORKFLOW_SCHEMA_VERSION) {\n const step = steps[version];\n if (!step) return out;\n\n out = step(out);\n version += 1;\n out.version = version;\n }\n\n return out;\n}\n\n/**\n * Hydrate a schema into runtime FlowGraph + validate kinds/configs against\n * the registry. Reports issues for unknown kinds, missing required config,\n * and dangling edges.\n */\nexport function importWorkflow(schema: unknown, options: ImportOptions = {}): ImportResult {\n const issues: ImportIssue[] = [];\n const lenient = options.lenient === true;\n schema = migrateSchema(schema);\n\n if (!schema || typeof schema !== \"object\") {\n return { ok: false, graph: { nodes: [], edges: [] }, issues: [{ level: \"error\", message: \"Schema is not an object.\" }] };\n }\n const s = schema as Partial<WorkflowSchema>;\n if (s.version !== WORKFLOW_SCHEMA_VERSION) {\n issues.push({\n level: lenient ? \"warning\" : \"error\",\n message: `Unsupported workflow schema version: ${s.version} (expected ${WORKFLOW_SCHEMA_VERSION})`,\n });\n if (!lenient) return { ok: false, graph: { nodes: [], edges: [] }, issues };\n }\n\n const rawNodes = s.graph?.nodes ?? [];\n const rawEdges = s.graph?.edges ?? [];\n\n const nodes: FlowNode[] = rawNodes.map((n) => {\n const kind = getNodeKind(n.kind);\n if (!kind) {\n issues.push({\n level: lenient ? \"warning\" : \"error\",\n nodeId: n.id,\n message: `Unknown kind \"${n.kind}\" — register it before importing.`,\n });\n }\n const config = n.config ?? (kind ? defaultConfigFor(kind) : {});\n if (kind) {\n for (const iss of validateConfig(kind, config)) {\n issues.push({ level: \"warning\", nodeId: n.id, message: `${iss.key}: ${iss.message}` });\n }\n }\n // Canonicalise on the way in: a document may carry a pre-namespace id, and\n // rewriting it here means the graph converges on the canonical id the next\n // time it is saved, rather than carrying the ambiguous name forever.\n const kindId = kind?.name ?? n.kind;\n return {\n id: n.id,\n type: kindId,\n position: { x: n.position?.x ?? 0, y: n.position?.y ?? 0 },\n // Rehydrate visual layout onto the node's top level (where xyflow reads it).\n ...(n.parentId ? { parentId: n.parentId } : {}),\n ...(n.extent ? { extent: n.extent } : {}),\n ...(typeof n.width === \"number\" ? { width: n.width } : {}),\n ...(typeof n.height === \"number\" ? { height: n.height } : {}),\n ...(n.style ? { style: n.style } : {}),\n data: {\n kind: kindId,\n label: n.label ?? kind?.label ?? n.kind,\n description: n.description,\n ...(n.startingMsg ? { startingMsg: n.startingMsg } : {}),\n ...(n.stoppingMsg ? { stoppingMsg: n.stoppingMsg } : {}),\n config,\n // Carry serialized ports back onto the node so a round-trip is stable\n // and an unknown kind still routes the way the document described.\n ...(n.inputs ? { inputs: n.inputs } : {}),\n ...(n.outputs ? { outputs: n.outputs } : {}),\n } as any,\n };\n });\n\n const nodeIds = new Set(nodes.map((n) => n.id));\n const edges: FlowEdge[] = rawEdges\n .map((e) => {\n if (!nodeIds.has(e.source)) {\n issues.push({ level: \"warning\", edgeId: e.id, message: `Edge source \"${e.source}\" not found.` });\n return null;\n }\n if (!nodeIds.has(e.target)) {\n issues.push({ level: \"warning\", edgeId: e.id, message: `Edge target \"${e.target}\" not found.` });\n return null;\n }\n return {\n id: e.id,\n source: e.source,\n target: e.target,\n sourceHandle: e.sourceHandle,\n targetHandle: e.targetHandle,\n label: e.label,\n } as FlowEdge;\n })\n .filter((e): e is FlowEdge => e !== null);\n\n // WIRING, not merely dataflow: a node no edge reaches and that reaches no\n // edge, and an edge reading from a node that publishes nothing.\n //\n // Deliberately AFTER the edge loop, so it sees the same edges the engine will\n // -- a dangling edge is dropped with a warning above, and running this first\n // would let a dropped edge count as a connection.\n //\n // Deliberately NOT gated on `lenient`. That flag is about unknown VOCABULARY\n // (a kind this host has not registered), never about wiring.\n issues.push(...checkGraphConnectivity({ nodes, edges }));\n\n const ok = issues.every((i) => i.level !== \"error\");\n // The declaration comes back with the graph. Dropping it on import would be\n // the worse half of losing it on export: the document still says what it\n // accepts, the loaded graph does not, and every prop a caller passes becomes\n // \"unknown input\" — an error pointing at the caller for a bug in the loader.\n const declaredInputs = Array.isArray(s.inputs)\n ? (s.inputs as WorkflowInput[]).filter(\n (input): input is WorkflowInput =>\n input !== null && typeof input === \"object\" && typeof (input as WorkflowInput).name === \"string\",\n )\n : undefined;\n\n return {\n ok,\n graph: {\n nodes,\n edges,\n ...(declaredInputs && declaredInputs.length > 0 ? { inputs: declaredInputs } : {}),\n },\n issues,\n };\n}\n\n/** Convenience: serialize a schema as a downloadable JSON Blob. */\nexport function workflowToBlob(schema: WorkflowSchema): Blob {\n return new Blob([JSON.stringify(schema, null, 2)], { type: \"application/json\" });\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/schema/workflow-schema.ts"],"names":[],"mappings":";;;;AAMO,IAAM,uBAAA,GAA0B;AAChC,IAAM,mBAAA,GAAsB;AAwH5B,SAAS,cAAA,CACd,KAAA,EACA,QAAA,EACA,IAAA,EACgB;AAChB,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,mBAAA;AAAA,IACT,OAAA,EAAS,uBAAA;AAAA,IACT,QAAA,EAAU,WAAW,EAAE,GAAG,UAAU,SAAA,EAAW,IAAA,CAAK,GAAA,EAAI,EAAE,GAAI,MAAA;AAAA;AAAA;AAAA,IAG9D,GAAI,KAAA,CAAM,MAAA,IAAU,KAAA,CAAM,MAA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AA,IAC5B,CAAC,UACC,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,QAAA,IAAY,OAAQ,KAAA,CAAwB,IAAA,KAAS;AAAA,GAC5F,GACA,MAAA;AAEJ,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA,KAAA,EAAO;AAAA,MACL,KAAA;AAAA,MACA,KAAA;AAAA,MACA,GAAI,kBAAkB,cAAA,CAAe,MAAA,GAAS,IAAI,EAAE,MAAA,EAAQ,cAAA,EAAe,GAAI;AAAC,KAClF;AAAA,IACA;AAAA,GACF;AACF;AAGO,SAAS,eAAe,MAAA,EAA8B;AAC3D,EAAA,OAAO,IAAI,IAAA,CAAK,CAAC,IAAA,CAAK,SAAA,CAAU,MAAA,EAAQ,IAAA,EAAM,CAAC,CAAC,CAAA,EAAG,EAAE,IAAA,EAAM,oBAAoB,CAAA;AACjF","file":"chunk-6AYC3BWI.js","sourcesContent":["import type { FlowEdge, FlowGraph, FlowNode, PortDescriptor, WorkflowInput } from \"../types\";\nimport { checkGraphConnectivity } from \"../analysis/graph-connectivity\";\nimport { defaultConfigFor, getNodeKind, validateConfig } from \"../registry/registry\";\nimport { resolveNodePorts } from \"../registry/ports\";\n\n/** Schema version. Bump on breaking shape changes; add migrations as needed. */\nexport const WORKFLOW_SCHEMA_VERSION = 1 as const;\nexport const WORKFLOW_SCHEMA_URL = \"https://particle.academy/schemas/workflow/v1.json\";\n\nexport type WorkflowSchema = {\n $schema: typeof WORKFLOW_SCHEMA_URL;\n version: typeof WORKFLOW_SCHEMA_VERSION;\n metadata?: WorkflowMetadata;\n /**\n * What this workflow accepts at run start, passed BY NAME.\n *\n * Lives beside `graph` rather than inside it because it describes the\n * workflow's CONTRACT, not its topology: a caller reads this to know what to\n * pass, and reading it should not mean walking nodes looking for a trigger.\n *\n * Omitted entirely when a workflow takes none, so every existing saved\n * document is unchanged byte for byte.\n */\n inputs?: WorkflowInput[];\n graph: {\n nodes: WorkflowSchemaNode[];\n edges: WorkflowSchemaEdge[];\n };\n view?: {\n viewport?: { x: number; y: number; zoom: number };\n };\n};\n\nexport type WorkflowMetadata = {\n id?: string;\n name?: string;\n description?: string;\n createdAt?: number;\n updatedAt?: number;\n author?: string;\n tags?: string[];\n};\n\nexport type WorkflowSchemaNode = {\n id: string;\n /** Registry kind name (e.g. \"memory_store\"). */\n kind: string;\n position: { x: number; y: number };\n label?: string;\n description?: string;\n /**\n * Announced to a person just before / just after this node runs. Omitted\n * entirely when unset, so a graph of ordinary plumbing nodes does not carry\n * a pair of empty keys per node and every diff of a saved graph stays\n * readable.\n */\n startingMsg?: string;\n stoppingMsg?: string;\n config?: Record<string, unknown>;\n /**\n * Resolved ports, written on export.\n *\n * A kind may derive its ports from config (`switch_case` cases,\n * `llm_branch` routes), and that derivation is a JavaScript function — a\n * runtime in another language cannot execute it. Without the resolved ports\n * in the document, the PHP twin sees no declared outputs and falls back to a\n * single `out`, so every branch edge in an exported flow silently stops\n * firing. Serializing them keeps the schema self-describing and preserves\n * the cross-runtime guarantee: same JSON in, same routing out.\n *\n * Optional and additive — a hand-written schema may omit them, and each\n * runtime then falls back to its own kind registry.\n */\n inputs?: PortDescriptor[];\n outputs?: PortDescriptor[];\n /**\n * Node grouping and visual layout — additive + optional. `parentId`/`extent`\n * say which container a node sits in (swimlanes); `width`/`height` carry an\n * explicit (resized) size; `style` carries inline presentation.\n *\n * **`parentId` is NOT decoration, and a runtime that drops it is wrong.** It\n * decides which terminal a node talks to — a terminal lane owns one session\n * and membership is this field, deliberately, so there is no second copy of\n * the grouping in each node's config to drift from what the canvas shows.\n *\n * This comment used to say these fields exist \"purely for the canvas\", so a\n * runtime that only walks edges and ports could ignore all of them. The\n * Python twin read that literally and carried none of them: a graph loaded\n * there and saved back lost every grouping a person had drawn, silently. The\n * sentence was true when it was written and became false without being\n * revisited, which is the more common way a comment does harm.\n *\n * An older reader that does not know these fields still drops them — that is\n * forward-compatibility, not permission.\n */\n parentId?: string;\n extent?: \"parent\" | [[number, number], [number, number]];\n width?: number;\n height?: number;\n style?: Record<string, unknown>;\n};\n\nexport type WorkflowSchemaEdge = {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n label?: string;\n};\n\nexport type ImportIssue = {\n level: \"error\" | \"warning\";\n nodeId?: string;\n edgeId?: string;\n message: string;\n};\n\nexport type ImportResult = {\n graph: FlowGraph;\n issues: ImportIssue[];\n /** True when the import produced a usable graph (errors may have been\n * rewritten to warnings via `lenient: true`). */\n ok: boolean;\n};\n\n/** Snapshot the in-memory graph as a portable WorkflowSchema. */\nexport function exportWorkflow(\n graph: FlowGraph,\n metadata?: WorkflowMetadata,\n view?: WorkflowSchema[\"view\"],\n): WorkflowSchema {\n return {\n $schema: WORKFLOW_SCHEMA_URL,\n version: WORKFLOW_SCHEMA_VERSION,\n metadata: metadata ? { ...metadata, updatedAt: Date.now() } : undefined,\n // Round-trips, or a saved workflow silently forgets its own contract and\n // every caller's props become \"unknown input\" on the next load.\n ...(graph.inputs && graph.inputs.length > 0 ? { inputs: graph.inputs } : {}),\n graph: {\n nodes: graph.nodes.map(toSchemaNode),\n edges: graph.edges.map(toSchemaEdge),\n },\n view,\n };\n}\n\nfunction toSchemaNode(n: FlowNode): WorkflowSchemaNode {\n const data: any = n.data ?? {};\n const kindName = data.kind ?? n.type ?? \"custom\";\n // Resolve through the same helper the canvas and runtime use, so a\n // config-driven kind writes its ACTUAL ports into the document instead of\n // leaving another language's runtime to guess at them.\n const ports = resolveNodePorts(n, getNodeKind(kindName) ?? undefined);\n const node = n as any;\n return {\n id: n.id,\n kind: kindName,\n position: { x: n.position.x, y: n.position.y },\n label: data.label,\n description: data.description,\n ...(typeof data.startingMsg === \"string\" && data.startingMsg !== \"\" ? { startingMsg: data.startingMsg } : {}),\n ...(typeof data.stoppingMsg === \"string\" && data.stoppingMsg !== \"\" ? { stoppingMsg: data.stoppingMsg } : {}),\n config: data.config,\n inputs: ports.inputs,\n outputs: ports.outputs,\n // Visual layout — only when explicitly set (never persist auto-`measured`\n // dimensions, which are derived, not authored).\n ...(node.parentId ? { parentId: node.parentId } : {}),\n ...(node.extent ? { extent: node.extent } : {}),\n ...(typeof node.width === \"number\" ? { width: node.width } : {}),\n ...(typeof node.height === \"number\" ? { height: node.height } : {}),\n ...(node.style ? { style: node.style } : {}),\n };\n}\n\nfunction toSchemaEdge(e: FlowEdge): WorkflowSchemaEdge {\n return {\n id: e.id,\n source: e.source,\n target: e.target,\n sourceHandle: e.sourceHandle ?? undefined,\n targetHandle: e.targetHandle ?? undefined,\n label: typeof e.label === \"string\" ? e.label : undefined,\n };\n}\n\nexport type ImportOptions = {\n /** When true, unknown kinds become warnings + a \"custom\" placeholder\n * instead of errors. Default false. */\n lenient?: boolean;\n};\n\n/** A migration step: takes a version-N document to version N+1. */\nexport type MigrationStep = (schema: Record<string, unknown>) => Record<string, unknown>;\n\n/**\n * Every migration step, keyed by the version it upgrades FROM.\n *\n * Empty today because v1 is current — when a BREAKING bump lands, add the step\n * here and every stored document upgrades on read, in this runtime and its\n * PHP and Python twins.\n */\nexport const MIGRATIONS: Record<number, MigrationStep> = {};\n\n/**\n * Migrate a raw schema object up to the current version, as far as it can go.\n *\n * Additive changes need no migration — an older document simply lacks the newer\n * optional fields. This is the seam for a future BREAKING bump, and\n * `importWorkflow` runs it before validating the version.\n *\n * ## The three rules, each with a reason\n *\n * - **A PAST version migrates forward**, step by step, to the current one.\n * - **A FUTURE version is left ALONE.** We cannot know what a later schema\n * means, and migrating downward would be guessing. Untouched hands it to the\n * version check, which reports it honestly.\n * - **A GAP in the table is left alone too.** A missing step is not a licence\n * to guess.\n *\n * ## Why `steps` is a parameter\n *\n * With only v1 in existence there is no old document to migrate, so a seam\n * tested against the built-in (empty) table is a check that CANNOT fail — it\n * would pass identically against a function that returned its input untouched,\n * which is what this was until the twins needed the same seam.\n *\n * The PHP and Python runtimes carry the identical shape. That mattered more\n * than it sounds: they had no migration at all and errored on any version\n * mismatch, so a v2 bump would have made every stored Op unreadable on exactly\n * the runtimes where durable runs resume.\n */\nexport function migrateSchema(\n schema: unknown,\n steps: Record<number, MigrationStep> = MIGRATIONS,\n): unknown {\n if (!schema || typeof schema !== \"object\") return schema;\n\n const doc = schema as Record<string, unknown>;\n let version = doc.version;\n\n if (typeof version !== \"number\" || !Number.isInteger(version) || version >= WORKFLOW_SCHEMA_VERSION) {\n return schema;\n }\n\n let out = doc;\n while (version < WORKFLOW_SCHEMA_VERSION) {\n const step = steps[version];\n if (!step) return out;\n\n out = step(out);\n version += 1;\n out.version = version;\n }\n\n return out;\n}\n\n/**\n * Hydrate a schema into runtime FlowGraph + validate kinds/configs against\n * the registry. Reports issues for unknown kinds, missing required config,\n * and dangling edges.\n */\nexport function importWorkflow(schema: unknown, options: ImportOptions = {}): ImportResult {\n const issues: ImportIssue[] = [];\n const lenient = options.lenient === true;\n schema = migrateSchema(schema);\n\n if (!schema || typeof schema !== \"object\") {\n return { ok: false, graph: { nodes: [], edges: [] }, issues: [{ level: \"error\", message: \"Schema is not an object.\" }] };\n }\n const s = schema as Partial<WorkflowSchema>;\n if (s.version !== WORKFLOW_SCHEMA_VERSION) {\n issues.push({\n level: lenient ? \"warning\" : \"error\",\n message: `Unsupported workflow schema version: ${s.version} (expected ${WORKFLOW_SCHEMA_VERSION})`,\n });\n if (!lenient) return { ok: false, graph: { nodes: [], edges: [] }, issues };\n }\n\n const rawNodes = s.graph?.nodes ?? [];\n const rawEdges = s.graph?.edges ?? [];\n\n const nodes: FlowNode[] = rawNodes.map((n) => {\n const kind = getNodeKind(n.kind);\n if (!kind) {\n issues.push({\n level: lenient ? \"warning\" : \"error\",\n nodeId: n.id,\n message: `Unknown kind \"${n.kind}\" — register it before importing.`,\n });\n }\n const config = n.config ?? (kind ? defaultConfigFor(kind) : {});\n if (kind) {\n for (const iss of validateConfig(kind, config)) {\n issues.push({ level: \"warning\", nodeId: n.id, message: `${iss.key}: ${iss.message}` });\n }\n }\n // Canonicalise on the way in: a document may carry a pre-namespace id, and\n // rewriting it here means the graph converges on the canonical id the next\n // time it is saved, rather than carrying the ambiguous name forever.\n const kindId = kind?.name ?? n.kind;\n return {\n id: n.id,\n type: kindId,\n position: { x: n.position?.x ?? 0, y: n.position?.y ?? 0 },\n // Rehydrate visual layout onto the node's top level (where xyflow reads it).\n ...(n.parentId ? { parentId: n.parentId } : {}),\n ...(n.extent ? { extent: n.extent } : {}),\n ...(typeof n.width === \"number\" ? { width: n.width } : {}),\n ...(typeof n.height === \"number\" ? { height: n.height } : {}),\n ...(n.style ? { style: n.style } : {}),\n data: {\n kind: kindId,\n label: n.label ?? kind?.label ?? n.kind,\n description: n.description,\n ...(n.startingMsg ? { startingMsg: n.startingMsg } : {}),\n ...(n.stoppingMsg ? { stoppingMsg: n.stoppingMsg } : {}),\n config,\n // Carry serialized ports back onto the node so a round-trip is stable\n // and an unknown kind still routes the way the document described.\n ...(n.inputs ? { inputs: n.inputs } : {}),\n ...(n.outputs ? { outputs: n.outputs } : {}),\n } as any,\n };\n });\n\n const nodeIds = new Set(nodes.map((n) => n.id));\n const edges: FlowEdge[] = rawEdges\n .map((e) => {\n if (!nodeIds.has(e.source)) {\n issues.push({ level: \"warning\", edgeId: e.id, message: `Edge source \"${e.source}\" not found.` });\n return null;\n }\n if (!nodeIds.has(e.target)) {\n issues.push({ level: \"warning\", edgeId: e.id, message: `Edge target \"${e.target}\" not found.` });\n return null;\n }\n return {\n id: e.id,\n source: e.source,\n target: e.target,\n sourceHandle: e.sourceHandle,\n targetHandle: e.targetHandle,\n label: e.label,\n } as FlowEdge;\n })\n .filter((e): e is FlowEdge => e !== null);\n\n // WIRING, not merely dataflow: a node no edge reaches and that reaches no\n // edge, and an edge reading from a node that publishes nothing.\n //\n // Deliberately AFTER the edge loop, so it sees the same edges the engine will\n // -- a dangling edge is dropped with a warning above, and running this first\n // would let a dropped edge count as a connection.\n //\n // Deliberately NOT gated on `lenient`. That flag is about unknown VOCABULARY\n // (a kind this host has not registered), never about wiring.\n issues.push(...checkGraphConnectivity({ nodes, edges }));\n\n const ok = issues.every((i) => i.level !== \"error\");\n // The declaration comes back with the graph. Dropping it on import would be\n // the worse half of losing it on export: the document still says what it\n // accepts, the loaded graph does not, and every prop a caller passes becomes\n // \"unknown input\" — an error pointing at the caller for a bug in the loader.\n const declaredInputs = Array.isArray(s.inputs)\n ? (s.inputs as WorkflowInput[]).filter(\n (input): input is WorkflowInput =>\n input !== null && typeof input === \"object\" && typeof (input as WorkflowInput).name === \"string\",\n )\n : undefined;\n\n return {\n ok,\n graph: {\n nodes,\n edges,\n ...(declaredInputs && declaredInputs.length > 0 ? { inputs: declaredInputs } : {}),\n },\n issues,\n };\n}\n\n/** Convenience: serialize a schema as a downloadable JSON Blob. */\nexport function workflowToBlob(schema: WorkflowSchema): Blob {\n return new Blob([JSON.stringify(schema, null, 2)], { type: \"application/json\" });\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RichInputPreview } from './chunk-F5RPRB7A.js';
|
|
2
|
+
import { NodeResizer, NodeToolbar, Handle, Position } from './chunk-OWENS2H5.js';
|
|
3
|
+
import { BUILTIN_KIND_DATA, getNodeKind, categoryAccent, resolveNodePorts, nodeConfig, registerNodeKind, listNodeKinds, kindIds } from './chunk-27RZJAE2.js';
|
|
4
|
+
import { memo, createContext, useMemo, useState, useRef, useEffect, createElement, useContext } from 'react';
|
|
3
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
6
|
|
|
5
7
|
// src/registry/connection.ts
|
|
@@ -180,6 +182,126 @@ function previewValue(v) {
|
|
|
180
182
|
}
|
|
181
183
|
return "\u2026";
|
|
182
184
|
}
|
|
185
|
+
function LaneNodeInner(props) {
|
|
186
|
+
const data = props.data;
|
|
187
|
+
const config = data.config ?? {};
|
|
188
|
+
const title = config.title ?? data.label ?? "Lane";
|
|
189
|
+
const orientation = config.orientation ?? "horizontal";
|
|
190
|
+
const accent = config.color ?? data.color ?? categoryAccent("layout");
|
|
191
|
+
return /* @__PURE__ */ jsxs(
|
|
192
|
+
"div",
|
|
193
|
+
{
|
|
194
|
+
className: ["ff-lane", `ff-lane--${orientation}`, props.selected ? "ff-lane--selected" : ""].filter(Boolean).join(" "),
|
|
195
|
+
style: { borderColor: props.selected ? accent : void 0 },
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ jsx(NodeResizer, { isVisible: props.selected ?? false, color: accent, minWidth: 160, minHeight: 72 }),
|
|
198
|
+
/* @__PURE__ */ jsx("div", { className: "ff-lane__header", style: { background: accent }, children: /* @__PURE__ */ jsx("span", { className: "ff-lane__title", children: title }) })
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
var LaneNode = memo(LaneNodeInner);
|
|
204
|
+
var FlowEditorContext = createContext(null);
|
|
205
|
+
var FlowEditorProvider = FlowEditorContext.Provider;
|
|
206
|
+
function useFlowEditor() {
|
|
207
|
+
const api = useContext(FlowEditorContext);
|
|
208
|
+
if (api === null) {
|
|
209
|
+
throw new Error("useFlowEditor() must be called inside <FlowEditor>.");
|
|
210
|
+
}
|
|
211
|
+
return api;
|
|
212
|
+
}
|
|
213
|
+
function useFlowEditorOptional() {
|
|
214
|
+
return useContext(FlowEditorContext);
|
|
215
|
+
}
|
|
216
|
+
var NOTE_COLORS = {
|
|
217
|
+
amber: { bg: "rgba(234, 179, 8, 0.14)", border: "rgba(234, 179, 8, 0.55)", title: "#a16207" },
|
|
218
|
+
sky: { bg: "rgba(14, 165, 233, 0.12)", border: "rgba(14, 165, 233, 0.5)", title: "#0369a1" },
|
|
219
|
+
violet: { bg: "rgba(139, 92, 246, 0.13)", border: "rgba(139, 92, 246, 0.5)", title: "#6d28d9" },
|
|
220
|
+
emerald: { bg: "rgba(16, 185, 129, 0.13)", border: "rgba(16, 185, 129, 0.5)", title: "#047857" },
|
|
221
|
+
rose: { bg: "rgba(244, 63, 94, 0.12)", border: "rgba(244, 63, 94, 0.5)", title: "#be123c" },
|
|
222
|
+
slate: { bg: "rgba(100, 116, 139, 0.12)", border: "rgba(100, 116, 139, 0.5)", title: "#475569" }
|
|
223
|
+
};
|
|
224
|
+
function coerceColor(v) {
|
|
225
|
+
return typeof v === "string" && v in NOTE_COLORS ? v : "amber";
|
|
226
|
+
}
|
|
227
|
+
function NoteNodeInner(props) {
|
|
228
|
+
const data = props.data;
|
|
229
|
+
const config = data.config ?? {};
|
|
230
|
+
const api = useFlowEditorOptional();
|
|
231
|
+
const hasConfigText = typeof config.text === "string" && config.text.length > 0;
|
|
232
|
+
const text = hasConfigText ? String(config.text) : typeof data.body === "string" ? data.body : typeof data.text === "string" ? data.text : "";
|
|
233
|
+
const title = typeof config.title === "string" && config.title || (!hasConfigText && typeof data.body === "string" && typeof data.label === "string" ? data.label : "");
|
|
234
|
+
const skin = NOTE_COLORS[coerceColor(config.color)];
|
|
235
|
+
const [editing, setEditing] = useState(false);
|
|
236
|
+
const [draft, setDraft] = useState(text);
|
|
237
|
+
const areaRef = useRef(null);
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
if (editing && areaRef.current) {
|
|
240
|
+
const el = areaRef.current;
|
|
241
|
+
el.focus();
|
|
242
|
+
el.setSelectionRange(el.value.length, el.value.length);
|
|
243
|
+
}
|
|
244
|
+
}, [editing]);
|
|
245
|
+
const commit = () => {
|
|
246
|
+
setEditing(false);
|
|
247
|
+
if (!api || draft === text) return;
|
|
248
|
+
const current = api.nodes.find((n) => n.id === props.id);
|
|
249
|
+
if (!current) return;
|
|
250
|
+
api.updateNode({
|
|
251
|
+
...current,
|
|
252
|
+
data: { ...current.data, config: { ...config, text: draft } }
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
return /* @__PURE__ */ jsxs(
|
|
256
|
+
"div",
|
|
257
|
+
{
|
|
258
|
+
className: ["ff-note", props.selected ? "ff-note--selected" : ""].filter(Boolean).join(" "),
|
|
259
|
+
style: { background: skin.bg, borderColor: skin.border },
|
|
260
|
+
onDoubleClick: api ? () => {
|
|
261
|
+
setDraft(text);
|
|
262
|
+
setEditing(true);
|
|
263
|
+
} : void 0,
|
|
264
|
+
children: [
|
|
265
|
+
/* @__PURE__ */ jsx(NodeResizer, { isVisible: props.selected ?? false, color: skin.border, minWidth: 140, minHeight: 80 }),
|
|
266
|
+
title && /* @__PURE__ */ jsx("div", { className: "ff-note__title", style: { color: skin.title }, children: title }),
|
|
267
|
+
editing ? /* @__PURE__ */ jsx(
|
|
268
|
+
"textarea",
|
|
269
|
+
{
|
|
270
|
+
ref: areaRef,
|
|
271
|
+
className: "ff-note__input nodrag nowheel",
|
|
272
|
+
value: draft,
|
|
273
|
+
onChange: (e) => setDraft(e.target.value),
|
|
274
|
+
onBlur: commit,
|
|
275
|
+
onKeyDown: (e) => {
|
|
276
|
+
if (e.key === "Escape") setEditing(false);
|
|
277
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) commit();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
) : /* @__PURE__ */ jsx("div", { className: "ff-note__body", children: text || /* @__PURE__ */ jsx("span", { className: "ff-note__placeholder", children: api ? "Double-click to write a note\u2026" : "Note" }) })
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
var NoteNode = memo(NoteNodeInner);
|
|
286
|
+
|
|
287
|
+
// src/registry/builtin.ts
|
|
288
|
+
var RENDERERS = {
|
|
289
|
+
"@particle-academy/lane": { component: LaneNode },
|
|
290
|
+
"@particle-academy/terminal_lane": { component: LaneNode },
|
|
291
|
+
"@particle-academy/note": { component: NoteNode },
|
|
292
|
+
"@particle-academy/rich_user_input": {
|
|
293
|
+
// Previews the authored page inside a FauxClient frame, so the canvas shows
|
|
294
|
+
// what the person hitting this step will actually see.
|
|
295
|
+
renderBody: (ctx) => createElement(RichInputPreview, { config: ctx.config ?? {} })
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
var BUILTIN_KINDS = BUILTIN_KIND_DATA.map((kind) => {
|
|
299
|
+
const renderer = RENDERERS[kind.name];
|
|
300
|
+
return renderer ? { ...kind, ...renderer } : kind;
|
|
301
|
+
});
|
|
302
|
+
function registerBuiltinKinds() {
|
|
303
|
+
for (const kind of BUILTIN_KINDS) registerNodeKind(kind);
|
|
304
|
+
}
|
|
183
305
|
|
|
184
306
|
// src/registry/index.ts
|
|
185
307
|
function buildNodeTypes() {
|
|
@@ -191,6 +313,6 @@ function buildNodeTypes() {
|
|
|
191
313
|
return map;
|
|
192
314
|
}
|
|
193
315
|
|
|
194
|
-
export { ANY_PORT_TYPE, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility };
|
|
195
|
-
//# sourceMappingURL=chunk-
|
|
196
|
-
//# sourceMappingURL=chunk-
|
|
316
|
+
export { ANY_PORT_TYPE, BUILTIN_KINDS, FlowEditorProvider, LaneNode, NoteNode, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility, registerBuiltinKinds, useFlowEditor, useFlowEditorOptional };
|
|
317
|
+
//# sourceMappingURL=chunk-6TH646CS.js.map
|
|
318
|
+
//# sourceMappingURL=chunk-6TH646CS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/registry/connection.ts","../src/registry/RegistryNode.tsx","../src/components/nodes/LaneNode.tsx","../src/components/FlowEditor/api.ts","../src/components/nodes/NoteNode.tsx","../src/registry/builtin.ts","../src/registry/index.ts"],"names":["jsxs","jsx","memo"],"mappings":";;;;;;;AAqBO,IAAM,aAAA,GAAgB;AActB,IAAM,wBAAA,GAA8C,CAAC,MAAA,EAAQ,MAAA,KAAW;AAC7E,EAAA,MAAM,IAAI,MAAA,EAAQ,IAAA;AAClB,EAAA,MAAM,IAAI,MAAA,EAAQ,IAAA;AAClB,EAAA,IAAI,CAAC,CAAA,IAAK,CAAC,CAAA,EAAG,OAAO,IAAA;AACrB,EAAA,IAAI,CAAA,KAAM,aAAA,IAAiB,CAAA,KAAM,aAAA,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A;AAC/C,CAAC;AASM,SAAS,oBAAA,GAA6B;AAC3C,EAAA,KAAA,MAAW,IAAA,IAAQ,aAAA,EAAe,gBAAA,CAAiB,IAAI,CAAA;AACzD;;;AC8BO,SAAS,cAAA,GAA4B;AAC1C,EAAA,MAAM,MAAiB,EAAC;AACxB,EAAA,KAAA,MAAW,CAAA,IAAK,eAAc,EAAG;AAM/B,IAAA,MAAM,QAAA,GAAW,EAAE,SAAA,IAAa,YAAA;AAChC,IAAA,KAAA,MAAW,MAAM,OAAA,CAAQ,CAAC,CAAA,EAAG,GAAA,CAAI,EAAE,CAAA,GAAI,QAAA;AAAA,EACzC;AACA,EAAA,OAAO,GAAA;AACT","file":"chunk-6TH646CS.js","sourcesContent":["import type { Connection, Edge } from \"@xyflow/react\";\nimport type { FlowNode, PortDescriptor } from \"../types\";\nimport { getNodeKind } from \"./registry\";\nimport { resolveNodePorts } from \"./ports\";\n\n/**\n * Connection validation — the single rule that decides whether an edge between\n * two ports is allowed. Lives here (React-free, registry-adjacent) so BOTH the\n * canvas (`<FlowCanvas isValidConnection>`) and the agent bridge's\n * `flow_connect` tool call the same function: a connection the canvas refuses\n * is a connection an agent cannot sneak past, and vice versa — no drift.\n *\n * `PortDescriptor.type` has always documented itself as being \"for hosts that\n * want to validate connections\", but nothing consumed it. This wires it up.\n */\n\n/**\n * Wildcard port type — matches any other type. A port that declares no `type`\n * is treated as a wildcard too, so existing flows (whose ports are untyped)\n * validate exactly as before.\n */\nexport const ANY_PORT_TYPE = \"any\";\n\n/** Decides whether a source-output port may feed a target-input port. */\nexport type PortCompatibility = (\n source: PortDescriptor | undefined,\n target: PortDescriptor | undefined,\n) => boolean;\n\n/**\n * Default compatibility rule: allow the connection UNLESS both ports declare a\n * concrete, differing type. An absent type or the `any` wildcard matches\n * anything — so typed ports get enforced while untyped ports stay permissive,\n * making this a safe default that never breaks an existing untyped graph.\n */\nexport const defaultPortCompatibility: PortCompatibility = (source, target) => {\n const s = source?.type;\n const t = target?.type;\n if (!s || !t) return true;\n if (s === ANY_PORT_TYPE || t === ANY_PORT_TYPE) return true;\n return s === t;\n};\n\nexport type ConnectionValidatorOptions = {\n /** Override the type-compatibility rule. Defaults to {@link defaultPortCompatibility}. */\n compatible?: PortCompatibility;\n /**\n * Allow a node's own output to feed its own input (a self-loop). Default\n * false — self-connections are almost always an accident, and the rare flow\n * that wants one can opt in.\n */\n allowSelfConnection?: boolean;\n};\n\n/** Resolve a node's effective ports for one side, going through the registry. */\nfunction portsFor(node: FlowNode, side: \"inputs\" | \"outputs\"): PortDescriptor[] {\n const kind = getNodeKind((node.data as any)?.kind ?? node.type);\n const resolved = resolveNodePorts(node, kind ?? undefined);\n return resolved[side] ?? [];\n}\n\n/**\n * Resolve which port a handle id refers to. When a side has a single port and\n * the handle id is absent (React Flow omits it for a lone default handle), use\n * that port; otherwise match by id.\n */\nfunction findPort(\n ports: PortDescriptor[],\n handleId: string | null | undefined,\n): PortDescriptor | undefined {\n if (handleId == null) return ports.length === 1 ? ports[0] : undefined;\n return ports.find((p) => p.id === handleId);\n}\n\n/**\n * Build an `isValidConnection` predicate that enforces port-type compatibility\n * against a live node list. Pass it straight to `<FlowCanvas isValidConnection>`\n * or reuse it to gate an agent's `flow_connect`.\n *\n * `getNodes` is called on every check so the validator always sees the current\n * graph (wire it to a ref/state getter, not a snapshot).\n *\n * A connection is rejected when: an endpoint is missing; it is a self-loop and\n * `allowSelfConnection` is off; either node is unknown; or the resolved ports\n * are type-incompatible. Nodes/ports with no declared type validate as before.\n */\nexport function createConnectionValidator(\n getNodes: () => FlowNode[],\n options: ConnectionValidatorOptions = {},\n): (connection: Connection | Edge) => boolean {\n const compatible = options.compatible ?? defaultPortCompatibility;\n return (connection) => {\n const { source, target, sourceHandle, targetHandle } = connection;\n if (!source || !target) return false;\n if (!options.allowSelfConnection && source === target) return false;\n\n const nodes = getNodes();\n const src = nodes.find((n) => n.id === source);\n const tgt = nodes.find((n) => n.id === target);\n if (!src || !tgt) return false;\n\n const outPort = findPort(portsFor(src, \"outputs\"), sourceHandle);\n const inPort = findPort(portsFor(tgt, \"inputs\"), targetHandle);\n return compatible(outPort, inPort);\n };\n}\n","import { memo, useMemo } from \"react\";\nimport { Handle, NodeResizer, NodeToolbar, Position, type NodeProps } from \"@xyflow/react\";\nimport type { FlowNode, NodeRunStatus, PortDescriptor } from \"../types\";\nimport { categoryAccent, getNodeKind } from \"./registry\";\nimport { nodeConfig, resolveNodePorts } from \"./ports\";\n\n/**\n * RegistryNode — generic node renderer that looks up the node's kind in\n * the registry and applies its `accent`/`label`/`icon`/`renderBody`. Used\n * as the xyflow node component for every registered kind.\n */\nfunction RegistryNodeInner(props: NodeProps<FlowNode>) {\n const kindName = (props.data as any).kind ?? props.type;\n const kind = useMemo(() => getNodeKind(kindName), [kindName]);\n\n if (!kind) {\n return (\n <div className=\"ff-node ff-node--unknown\">\n <div className=\"ff-node__header\" style={{ background: \"#71717a\" }}>\n <span className=\"ff-node__tag\">UNKNOWN</span>\n <span className=\"ff-node__label\">{kindName}</span>\n </div>\n <p className=\"ff-node__desc\">No registered kind for \"{kindName}\".</p>\n </div>\n );\n }\n\n const data = props.data;\n const status: NodeRunStatus = data.status ?? \"idle\";\n const accent = kind.accent ?? categoryAccent(kind.category);\n const resolved = resolveNodePorts(props, kind);\n const inputs: PortDescriptor[] = resolved.inputs ?? defaultInputs(kind.category);\n const outputs: PortDescriptor[] = resolved.outputs ?? defaultOutputs(kind.category);\n const config = nodeConfig(props);\n const label = data.label ?? kind.label;\n\n return (\n <div\n className={[\n \"ff-node\",\n `ff-node--status-${status}`,\n `ff-node--cat-${kind.category}`,\n props.selected ? \"ff-node--selected\" : \"\",\n kind.resizable ? \"ff-node--resizable\" : \"\",\n ].filter(Boolean).join(\" \")}\n style={{ borderColor: props.selected ? accent : undefined }}\n >\n {kind.resizable && (\n <NodeResizer\n isVisible={props.selected ?? false}\n color={accent}\n {...(typeof kind.resizable === \"object\" ? kind.resizable : {})}\n />\n )}\n {kind.toolbar && (\n <NodeToolbar isVisible={props.selected ?? false}>\n {kind.toolbar({ nodeId: props.id, config: config as any, selected: props.selected ?? false })}\n </NodeToolbar>\n )}\n <header className=\"ff-node__header\" style={{ background: accent }}>\n {kind.icon && <span className=\"ff-node__icon\" aria-hidden>{kind.icon}</span>}\n <span className=\"ff-node__tag\">{kind.label.toUpperCase()}</span>\n <span className=\"ff-node__label\">{label}</span>\n {status !== \"idle\" && <span className={`ff-node__dot ff-node__dot--${status}`} aria-label={`status ${status}`} />}\n </header>\n\n {data.description && <p className=\"ff-node__desc\">{data.description}</p>}\n\n <div className=\"ff-node__body\">\n {kind.renderBody\n ? kind.renderBody({ nodeId: props.id, config: config as any, selected: props.selected ?? false })\n : <DefaultBody config={config} kind={kind.configSchema} />}\n </div>\n\n {data.statusText && <p className=\"ff-node__status-text\">{data.statusText}</p>}\n\n {(data as any).output !== undefined && (\n <p className=\"ff-node__output\" title=\"Latest output\">→ {previewValue((data as any).output)}</p>\n )}\n\n {inputs.map((p, i) => (\n <Handle\n key={p.id}\n type=\"target\"\n position={Position.Left}\n id={p.id}\n style={portStyle(i, inputs.length)}\n title={p.label ?? p.id}\n />\n ))}\n {outputs.map((p, i) => (\n <Handle\n key={p.id}\n type=\"source\"\n position={Position.Right}\n id={p.id}\n style={portStyle(i, outputs.length)}\n title={p.label ?? p.id}\n />\n ))}\n </div>\n );\n}\n\nexport const RegistryNode = memo(RegistryNodeInner);\n\nfunction defaultInputs(category: string): PortDescriptor[] {\n return category === \"trigger\" ? [] : [{ id: \"in\" }];\n}\nfunction defaultOutputs(category: string): PortDescriptor[] {\n return category === \"output\" ? [] : [{ id: \"out\" }];\n}\n\nfunction portStyle(i: number, total: number): React.CSSProperties {\n if (total <= 1) return {};\n const slot = (100 / (total + 1)) * (i + 1);\n return { top: `${slot}%` };\n}\n\n/**\n * DefaultBody — compact summary of the config values for nodes that\n * don't provide a custom renderBody. Skips fields that look empty.\n */\nfunction DefaultBody({ config, kind }: { config: Record<string, unknown>; kind?: import(\"./types\").ConfigField[] }) {\n const fields = kind ?? [];\n // A kind with no config schema has nothing to configure — don't nag with a\n // \"configure in the panel\" prompt (that's only for a kind that HAS fields but\n // none are filled in yet). Triggers, Output, etc. render as just their header.\n if (fields.length === 0) return null;\n const visible = fields\n .map((f) => ({ field: f, value: config[f.key] }))\n .filter(({ value }) => value !== undefined && value !== \"\" && value !== null);\n if (visible.length === 0) {\n return <div className=\"ff-node__body-empty\">— configure in the panel</div>;\n }\n return (\n <ul className=\"ff-node__summary\">\n {visible.slice(0, 4).map(({ field, value }) => (\n <li key={field.key}>\n <span className=\"ff-node__summary-key\">{field.label}:</span>\n <span className=\"ff-node__summary-value\">{previewValue(value)}</span>\n </li>\n ))}\n {visible.length > 4 && <li className=\"ff-node__summary-more\">+ {visible.length - 4} more</li>}\n </ul>\n );\n}\n\nconst truncate = (s: string, n = 30): string => (s.length > n ? s.slice(0, n - 1) + \"…\" : s);\n\n/** A short, human name for one item in a repeater/list value. */\nfunction itemLabel(item: unknown): string {\n if (item && typeof item === \"object\") {\n const o = item as Record<string, unknown>;\n const name = o.label ?? o.name ?? o.key ?? o.title ?? o.id;\n if (typeof name === \"string\" && name) return name;\n if (typeof name === \"number\") return String(name);\n return \"item\";\n }\n return String(item ?? \"\");\n}\n\n/**\n * A node card's job is to read at a glance, not to be a data dump — so a value\n * is summarised, never `JSON.stringify`d. An array becomes its item names (or a\n * count), an object becomes a field count. Raw JSON on a card was the specific\n * thing to kill: `Fields: [{\"key\":\"answer\",…}]` reads as noise.\n */\nexport function previewValue(v: unknown): string {\n if (v === null || v === undefined) return \"\";\n if (typeof v === \"string\") return truncate(v);\n if (typeof v === \"number\" || typeof v === \"boolean\") return String(v);\n if (Array.isArray(v)) {\n if (v.length === 0) return \"none\";\n const names = v.slice(0, 3).map(itemLabel).filter(Boolean).join(\", \");\n const rest = v.length > 3 ? `, +${v.length - 3}` : \"\";\n return names ? truncate(names + rest) : `${v.length} item${v.length === 1 ? \"\" : \"s\"}`;\n }\n if (typeof v === \"object\") {\n const keys = Object.keys(v as object);\n return keys.length === 0 ? \"empty\" : `${keys.length} field${keys.length === 1 ? \"\" : \"s\"}`;\n }\n return \"…\";\n}\n","import { memo } from \"react\";\nimport { NodeResizer, type NodeProps } from \"@xyflow/react\";\nimport type { FlowNode } from \"../../types\";\nimport { categoryAccent } from \"../../registry/registry\";\n\n/**\n * LaneNode — a resizable swimlane band. A portless container: child nodes are\n * parented into it (`parentId` + `extent:'parent'`) and render on top, so this\n * node is just the titled background. Wired as the `@particle-academy/lane`\n * kind's `component`, so `buildNodeTypes` uses it instead of the default card.\n */\nfunction LaneNodeInner(props: NodeProps<FlowNode>) {\n const data = props.data as any;\n const config = data.config ?? {};\n const title: string = config.title ?? data.label ?? \"Lane\";\n const orientation: string = config.orientation ?? \"horizontal\";\n const accent: string = config.color ?? data.color ?? categoryAccent(\"layout\");\n return (\n <div\n className={[\"ff-lane\", `ff-lane--${orientation}`, props.selected ? \"ff-lane--selected\" : \"\"]\n .filter(Boolean)\n .join(\" \")}\n style={{ borderColor: props.selected ? accent : undefined }}\n >\n <NodeResizer isVisible={props.selected ?? false} color={accent} minWidth={160} minHeight={72} />\n <div className=\"ff-lane__header\" style={{ background: accent }}>\n <span className=\"ff-lane__title\">{title}</span>\n </div>\n </div>\n );\n}\n\nexport const LaneNode = memo(LaneNodeInner);\n","import { createContext, useContext } from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { Edge } from \"@xyflow/react\";\nimport type { FlowGraph, FlowNode, NodeRunStatus } from \"../../types\";\nimport type { WorkflowSchema } from \"../../schema\";\nimport type { AlignEdge } from \"./graph-ops\";\nimport type { AutoLayoutOptions } from \"../../layout\";\n\n/**\n * Everything the editor knows and can do, handed to every extension point.\n *\n * This is the seam that makes `<FlowEditor>` composable instead of fixed: it is\n * passed to custom actions and slots, returned from `useFlowEditor()` inside\n * any child, and exposed on the editor `ref` so a host can drive the editor\n * imperatively (or an MCP bridge can drive it for an agent).\n */\nexport type FlowEditorApi = {\n // ── State ────────────────────────────────────────────────────────────\n /** The current graph. */\n graph: FlowGraph;\n nodes: FlowNode[];\n edges: Edge[];\n /** Currently selected node id, or null. */\n selectedId: string | null;\n /** Currently selected node, or null. */\n selected: FlowNode | null;\n /** Currently selected edge id, or null. Independent of node selection. */\n selectedEdgeId: string | null;\n /** Currently selected edge, or null. */\n selectedEdge: Edge | null;\n /** All multi-selected node ids (xyflow box / shift selection). */\n selectedIds: string[];\n /** All multi-selected nodes. */\n selectedNodes: FlowNode[];\n /** True while a run is in flight. */\n running: boolean;\n /** Per-node run status, keyed by node id. */\n statuses: Record<string, NodeRunStatus>;\n\n // ── Selection ────────────────────────────────────────────────────────\n select: (id: string | null) => void;\n /** Select an edge (the connection between two nodes), or clear with null. */\n selectEdge: (id: string | null) => void;\n\n // ── Graph mutation ───────────────────────────────────────────────────\n /** Add a node of `kind` at an optional flow position. Returns the new id. */\n addNode: (kind: string, position?: { x: number; y: number }) => string | null;\n /** Replace one node (matched by id). */\n updateNode: (node: FlowNode) => void;\n /** Delete nodes by id, pruning every edge attached to them. */\n deleteNodes: (ids: string[]) => void;\n /** Delete the current selection (no-op when nothing is selected). */\n deleteSelected: () => void;\n /** Delete edges by id — i.e. break the connections between nodes. */\n deleteEdges: (ids: string[]) => void;\n /** Delete the selected edge (no-op when no edge is selected). */\n deleteSelectedEdge: () => void;\n /** Label a connection, or clear the label by passing undefined/\"\". */\n setEdgeLabel: (id: string, label: string | undefined) => void;\n /** Copy a node (offset slightly) and select the copy. Returns the new id. */\n duplicateNode: (id: string) => string | null;\n /** Replace the whole graph. */\n setGraph: (graph: FlowGraph) => void;\n\n // ── Bulk (multi-selection) ───────────────────────────────────────────\n /** Duplicate the current multi-selection, preserving edges between them. */\n duplicateSelected: () => void;\n /** Align the multi-selection to a shared edge/center of its bounding box. */\n alignSelected: (edge: AlignEdge) => void;\n /** Evenly distribute the multi-selection's gaps along an axis (needs 3+). */\n distributeSelected: (axis: \"h\" | \"v\") => void;\n\n // ── Swimlanes ────────────────────────────────────────────────────────\n /** Add a swimlane, stacked with existing lanes. Returns the new lane id. */\n addLane: (orientation?: \"horizontal\" | \"vertical\", title?: string) => string | null;\n /** Put a node inside a lane (sets parentId + a lane-relative position). */\n assignToLane: (nodeId: string, laneId: string) => void;\n /** Remove a node from its lane (restores its absolute position). */\n removeFromLane: (nodeId: string) => void;\n /** Auto-arrange the graph (or a lane's children) into a tidy DAG layout. */\n autoLayout: (options?: AutoLayoutOptions) => void;\n /** Tidy just one lane's children. */\n tidyLane: (laneId: string) => void;\n\n // ── Clipboard ────────────────────────────────────────────────────────\n /** Copy the current selection to the editor clipboard. */\n copy: () => void;\n /** Copy then delete the current selection. */\n cut: () => void;\n /** Paste the clipboard (optionally at a flow position) and select the result. */\n paste: (at?: { x: number; y: number }) => void;\n\n // ── Run ──────────────────────────────────────────────────────────────\n run: () => void;\n cancel: () => void;\n reset: () => void;\n\n // ── Workflow I/O ─────────────────────────────────────────────────────\n /** The current graph as a WorkflowSchema (what `export` downloads). */\n toWorkflow: () => WorkflowSchema;\n /** Download the workflow as JSON. */\n exportWorkflow: () => void;\n /** Open a file picker and load a workflow. */\n importWorkflow: () => void;\n\n // ── Viewport ─────────────────────────────────────────────────────────\n fitView: () => void;\n\n // ── History ──\n /** Undo the last committing edit (add / delete / connect / config / drag /\n * import). Transient interactions (a drag in progress, selection) are not\n * their own steps. */\n undo: () => void;\n /** Redo the last undone edit. */\n redo: () => void;\n /** True when there is an edit to undo. */\n canUndo: boolean;\n /** True when there is an undone edit to redo. */\n canRedo: boolean;\n};\n\n/**\n * A declarative toolbar button. JSON-friendly on purpose — a host (or an\n * agent) can describe editor affordances as data rather than JSX.\n */\nexport type FlowEditorAction = {\n /** Stable id — also the `data-action` handle, so agents never guess DOM. */\n id: string;\n label: ReactNode;\n /** Native tooltip. */\n title?: string;\n /** Where it sits relative to the built-in buttons. Default \"end\". */\n placement?: \"start\" | \"end\";\n /** Disable when this returns true. Re-evaluated on every render. */\n disabled?: (api: FlowEditorApi) => boolean;\n /** Hide entirely when this returns false. */\n visible?: (api: FlowEditorApi) => boolean;\n /** Only enabled when a node is selected. Sugar over `disabled`. */\n requiresSelection?: boolean;\n onSelect: (api: FlowEditorApi) => void;\n};\n\n/** Which built-in toolbar affordances to render. All default to true. */\nexport type FlowEditorBuiltins = {\n run?: boolean;\n delete?: boolean;\n /** Undo/redo toolbar buttons. Default true. */\n history?: boolean;\n /** \"Add lane\" toolbar button. Default true. */\n addLane?: boolean;\n /** \"Tidy\" (auto-layout) toolbar button. Default true. */\n autoLayout?: boolean;\n /** Right-click a node for Delete / Duplicate. Default true. */\n contextMenu?: boolean;\n /** Right-click a connection for Label / Delete. Default true. */\n edgeContextMenu?: boolean;\n export?: boolean;\n import?: boolean;\n count?: boolean;\n};\n\n/** Replaceable regions. Each receives the editor API. */\nexport type FlowEditorSlots = {\n /** Replace the ENTIRE toolbar (built-ins and actions are not rendered). */\n toolbar?: (api: FlowEditorApi) => ReactNode;\n /** Replace the left palette. */\n palette?: (api: FlowEditorApi) => ReactNode;\n /** Replace the right config panel. */\n panel?: (api: FlowEditorApi) => ReactNode;\n /** Appended inside the config panel, under the fields — per-node actions. */\n panelFooter?: (api: FlowEditorApi) => ReactNode;\n /** Replace the run feed. */\n feed?: (api: FlowEditorApi) => ReactNode;\n /** Rendered over the canvas when the graph is empty. */\n empty?: (api: FlowEditorApi) => ReactNode;\n /** Replace the node right-click menu. Receives the right-clicked node id;\n * call `close` when an item is chosen. */\n contextMenu?: (api: FlowEditorApi, nodeId: string, close: () => void) => ReactNode;\n /** Replace the connection right-click menu. Receives the right-clicked edge\n * id; call `close` when an item is chosen. */\n edgeContextMenu?: (api: FlowEditorApi, edgeId: string, close: () => void) => ReactNode;\n};\n\nconst FlowEditorContext = createContext<FlowEditorApi | null>(null);\n\nexport const FlowEditorProvider = FlowEditorContext.Provider;\n\n/**\n * Read the editor API from any child of `<FlowEditor>`. Throws outside one, so\n * a misplaced custom control fails loudly instead of silently doing nothing.\n */\nexport function useFlowEditor(): FlowEditorApi {\n const api = useContext(FlowEditorContext);\n if (api === null) {\n throw new Error(\"useFlowEditor() must be called inside <FlowEditor>.\");\n }\n return api;\n}\n\n/** Non-throwing variant, for components that may render outside an editor. */\nexport function useFlowEditorOptional(): FlowEditorApi | null {\n return useContext(FlowEditorContext);\n}\n","import { memo, useEffect, useRef, useState } from \"react\";\nimport { NodeResizer, type NodeProps } from \"@xyflow/react\";\nimport type { FlowNode } from \"../../types\";\nimport { useFlowEditorOptional } from \"../FlowEditor/api\";\n\n/**\n * NoteNode — a sticky-note annotation. A portless, visual-only node: nothing\n * wires to it and the engine skips it entirely, so a note NEVER reaches a\n * runner — its text lives in the document purely for people reading the canvas\n * and for editor / agent (MCP) tools. Wired as the `@particle-academy/note`\n * kind's `component`, so `buildNodeTypes` uses it instead of the default card;\n * also the legacy `defaultNodeTypes.note` renderer.\n *\n * Inside a `<FlowEditor>` the note is editable in place — double-click to type;\n * commits flow through `api.updateNode`, so each is one undoable step. In a\n * read-only viewer (no editor context) it renders as static text. Text is read\n * from `config.text` (canonical), falling back to the legacy `data.body` shape.\n */\n\ntype NoteColor = \"amber\" | \"sky\" | \"violet\" | \"emerald\" | \"rose\" | \"slate\";\n\n/** Soft sticky-note fills that read in both light and dark. */\nconst NOTE_COLORS: Record<NoteColor, { bg: string; border: string; title: string }> = {\n amber: { bg: \"rgba(234, 179, 8, 0.14)\", border: \"rgba(234, 179, 8, 0.55)\", title: \"#a16207\" },\n sky: { bg: \"rgba(14, 165, 233, 0.12)\", border: \"rgba(14, 165, 233, 0.5)\", title: \"#0369a1\" },\n violet: { bg: \"rgba(139, 92, 246, 0.13)\", border: \"rgba(139, 92, 246, 0.5)\", title: \"#6d28d9\" },\n emerald: { bg: \"rgba(16, 185, 129, 0.13)\", border: \"rgba(16, 185, 129, 0.5)\", title: \"#047857\" },\n rose: { bg: \"rgba(244, 63, 94, 0.12)\", border: \"rgba(244, 63, 94, 0.5)\", title: \"#be123c\" },\n slate: { bg: \"rgba(100, 116, 139, 0.12)\", border: \"rgba(100, 116, 139, 0.5)\", title: \"#475569\" },\n};\n\nfunction coerceColor(v: unknown): NoteColor {\n return typeof v === \"string\" && v in NOTE_COLORS ? (v as NoteColor) : \"amber\";\n}\n\nfunction NoteNodeInner(props: NodeProps<FlowNode>) {\n const data = props.data as any;\n const config = (data.config ?? {}) as Record<string, unknown>;\n const api = useFlowEditorOptional();\n\n const hasConfigText = typeof config.text === \"string\" && config.text.length > 0;\n // config.text is canonical; legacy notes carried their text in `data.body`.\n const text = hasConfigText\n ? String(config.text)\n : typeof data.body === \"string\"\n ? data.body\n : typeof data.text === \"string\"\n ? data.text\n : \"\";\n // config.title is canonical; a legacy note used its `data.label` as the title.\n const title =\n (typeof config.title === \"string\" && config.title) ||\n (!hasConfigText && typeof data.body === \"string\" && typeof data.label === \"string\" ? data.label : \"\");\n const skin = NOTE_COLORS[coerceColor(config.color)];\n\n const [editing, setEditing] = useState(false);\n const [draft, setDraft] = useState(text);\n const areaRef = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (editing && areaRef.current) {\n const el = areaRef.current;\n el.focus();\n el.setSelectionRange(el.value.length, el.value.length);\n }\n }, [editing]);\n\n const commit = () => {\n setEditing(false);\n if (!api || draft === text) return;\n const current = api.nodes.find((n) => n.id === props.id);\n if (!current) return;\n api.updateNode({\n ...current,\n data: { ...(current.data as any), config: { ...config, text: draft } },\n } as FlowNode);\n };\n\n return (\n <div\n className={[\"ff-note\", props.selected ? \"ff-note--selected\" : \"\"].filter(Boolean).join(\" \")}\n style={{ background: skin.bg, borderColor: skin.border }}\n onDoubleClick={api ? () => { setDraft(text); setEditing(true); } : undefined}\n >\n <NodeResizer isVisible={props.selected ?? false} color={skin.border} minWidth={140} minHeight={80} />\n {title && <div className=\"ff-note__title\" style={{ color: skin.title }}>{title}</div>}\n {editing ? (\n <textarea\n ref={areaRef}\n className=\"ff-note__input nodrag nowheel\"\n value={draft}\n onChange={(e) => setDraft(e.target.value)}\n onBlur={commit}\n onKeyDown={(e) => {\n if (e.key === \"Escape\") setEditing(false);\n if (e.key === \"Enter\" && (e.metaKey || e.ctrlKey)) commit();\n }}\n />\n ) : (\n <div className=\"ff-note__body\">\n {text || <span className=\"ff-note__placeholder\">{api ? \"Double-click to write a note…\" : \"Note\"}</span>}\n </div>\n )}\n </div>\n );\n}\n\nexport const NoteNode = memo(NoteNodeInner);\n","import { createElement } from \"react\";\nimport { registerNodeKind } from \"./registry\";\nimport { RichInputPreview } from \"./rich-input\";\nimport { LaneNode } from \"../components/nodes/LaneNode\";\nimport { NoteNode } from \"../components/nodes/NoteNode\";\nimport { BUILTIN_KIND_DATA } from \"./builtin-kinds\";\nimport type { NodeKindDefinition } from \"./types\";\n\n/**\n * The built-in kit WITH its React renderers — the editor's door into it.\n *\n * ## Why this file is a decorator rather than the table\n *\n * `/engine` promised to be React-free and was not (#11). The exact edge was\n * `engine.ts → registry/registry.ts → registry/builtin.ts → react`, and it was\n * a REGRESSION of a fix whose comment is still in `engine.ts`: that file\n * imports from the module rather than the barrel precisely to avoid this, and\n * `registry.ts` later gained a `builtin.ts` import so the registry\n * self-populates. Both changes were right. Nothing tested the property, so the\n * second silently undid the first.\n *\n * The surface turned out to be four lines across three kinds in a 1,064-line\n * file, so the table moved to `builtin-kinds.ts` (React-free, what `registry.ts`\n * imports) and only the renderers stayed here.\n *\n * ## Where this gets applied, and why THERE\n *\n * `src/index.ts` calls `registerBuiltinKinds()` at module scope. That is not an\n * arbitrary choice: `package.json`'s `sideEffects` lists `./dist/index.js` and\n * `./dist/index.cjs` and NOT `./dist/registry.js`, so a consumer's bundler is\n * entitled to drop a top-level statement in the registry chunk and obliged to\n * keep one in the root barrel. Putting it anywhere else would work until\n * somebody's tree-shaker disagreed, and the symptom would be lanes quietly\n * rendering as ordinary cards.\n *\n * A consumer who never imports the React root still gets every kind — schema,\n * ports, executors — because `registry.ts` self-populates from the data\n * module. They simply get no renderers, which is correct: a queue worker has\n * no DOM to render into.\n *\n * ## Host and marketplace kinds are untouched\n *\n * Both arrive at runtime through `registerNodeKind` carrying their own\n * `component` / `renderBody`, and never pass through here. This split is\n * first-party-only by construction and adds no rule a third-party kind has to\n * follow.\n */\n\n/** The renderers, by canonical kind name. */\nconst RENDERERS: Record<string, Partial<NodeKindDefinition>> = {\n \"@particle-academy/lane\": { component: LaneNode },\n \"@particle-academy/terminal_lane\": { component: LaneNode },\n \"@particle-academy/note\": { component: NoteNode },\n \"@particle-academy/rich_user_input\": {\n // Previews the authored page inside a FauxClient frame, so the canvas shows\n // what the person hitting this step will actually see.\n renderBody: (ctx) =>\n createElement(RichInputPreview, { config: (ctx.config ?? {}) as Record<string, unknown> }),\n },\n};\n\n/**\n * Every builtin, with renderers attached to the four that have one.\n *\n * A kind with no renderer is passed through by identity rather than copied, so\n * `BUILTIN_KINDS` and `BUILTIN_KIND_DATA` share objects wherever there is\n * nothing to add.\n */\nexport const BUILTIN_KINDS: NodeKindDefinition[] = BUILTIN_KIND_DATA.map((kind) => {\n const renderer = RENDERERS[kind.name];\n return renderer ? { ...kind, ...renderer } : kind;\n});\n\n/**\n * Register every built-in kind, renderers included.\n *\n * Idempotent, and safe to call after `registry.ts` has already self-populated\n * the plain table: `registerNodeKind` replaces by name, so this UPGRADES the\n * four kinds in place rather than duplicating anything.\n */\nexport function registerBuiltinKinds(): void {\n for (const kind of BUILTIN_KINDS) registerNodeKind(kind);\n}\n\n// Everything else the table exports keeps its old import path, so no consumer\n// of `./builtin` has to change.\nexport { BUILTIN_KIND_DATA, registerBuiltinKindData } from \"./builtin-kinds\";\n","export type {\n ConfigField,\n TextConfigField,\n TextareaConfigField,\n NumberConfigField,\n SelectConfigField,\n SwitchConfigField,\n JsonConfigField,\n ExpressionConfigField,\n CredentialConfigField,\n RepeaterConfigField,\n RepeaterRowField,\n KeyValueConfigField,\n DocumentConfigField,\n NodeCategory,\n NodeKindDefinition,\n EmitsRelation,\n PortSpec,\n RenderBodyContext,\n} from \"./types\";\n\nexport { resolvePortSpec, resolveNodePorts, nodeConfig } from \"./ports\";\n\nexport {\n createConnectionValidator,\n defaultPortCompatibility,\n ANY_PORT_TYPE,\n type PortCompatibility,\n type ConnectionValidatorOptions,\n} from \"./connection\";\n\n/** Host capabilities — core declares the contract, the host supplies the impl. */\nexport {\n registerLlmClient,\n getLlmClient,\n registerWorkflowResolver,\n getWorkflowResolver,\n registerTerminalHost,\n getTerminalHost,\n capabilityStatus,\n type LlmClient,\n type LlmRoute,\n type LlmRouteRequest,\n type LlmRouteChoice,\n type WorkflowResolver,\n type WorkflowResolution,\n type WorkflowResolutionFailure,\n type TerminalHost,\n type TerminalSession,\n type TerminalSessionSpec,\n type TerminalExit,\n type CapabilityId,\n isResolutionFailure,\n} from \"./capabilities\";\n\n/**\n * The human-pause contract — a run waiting for a person, not a failure.\n * `decodePause` is the one function a durable runner needs.\n */\nexport {\n pauseForHuman,\n encodePause,\n decodePause,\n isPause,\n PAUSE_PREFIX,\n LEGACY_PAUSE_PREFIXES,\n type PauseAwaiting,\n type PauseSignal,\n} from \"./pause\";\n\nexport { subflowExecutor, subflowPorts, subflowMode, DEFAULT_MAX_DEPTH, type SubflowMode } from \"./subflow\";\nexport { llmRouterExecutor, declaredRoutes, resolveFallbackPort } from \"./llm-router\";\n/** @deprecated Renamed to `llmRouterExecutor` — the id and label now match. */\nexport { llmRouterExecutor as llmBranchExecutor } from \"./llm-router\";\n\nexport {\n registerRichInputAdapter,\n getRichInputAdapter,\n isRichInputEnabled,\n onRichInputAdapterChanged,\n RichInputPreview,\n type RichInputAdapter,\n} from \"./rich-input\";\n\nexport {\n registerNodeKind,\n overrideNodeKind,\n clearNodeKindOverrides,\n type NodeKindPresentation,\n getNodeKind,\n resolveKindId,\n kindIds,\n listNodeKinds,\n onNodeKindsChanged,\n defaultConfigFor,\n validateConfig,\n categoryAccent,\n} from \"./registry\";\n\nexport { RegistryNode } from \"./RegistryNode\";\nexport { registerBuiltinKinds, BUILTIN_KINDS } from \"./builtin\";\nexport { ensureBuiltinKinds } from \"./registry\";\n\nimport type { NodeTypes } from \"@xyflow/react\";\nimport { RegistryNode } from \"./RegistryNode\";\nimport { kindIds, listNodeKinds } from \"./registry\";\n\n/**\n * Build an xyflow `nodeTypes` map from the registry — every registered\n * kind gets `RegistryNode` as its renderer. Refresh manually via\n * `useNodeTypes()` (a hook that subscribes to registry changes).\n */\nexport function buildNodeTypes(): NodeTypes {\n const map: NodeTypes = {};\n for (const k of listNodeKinds()) {\n // A kind may bring its own full renderer (lanes/containers); otherwise the\n // default card. Key on every id the kind answers to, not just the canonical\n // one — xyflow looks the renderer up by `node.type` BEFORE RegistryNode gets\n // a chance to resolve aliases, so a graph carrying a pre-namespace type would\n // otherwise fall through to the unknown-node placeholder.\n const renderer = k.component ?? RegistryNode;\n for (const id of kindIds(k)) map[id] = renderer;\n }\n return map;\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createConnectionValidator, buildNodeTypes } from './chunk-
|
|
2
|
-
import { Handle, Position,
|
|
1
|
+
import { NoteNode, createConnectionValidator, buildNodeTypes } from './chunk-6TH646CS.js';
|
|
2
|
+
import { Handle, Position, reconnectEdge, index, BackgroundVariant, Background, Controls, MiniMap, ViewportPortal } from './chunk-OWENS2H5.js';
|
|
3
|
+
import { getNodeKind, categoryAccent } from './chunk-27RZJAE2.js';
|
|
3
4
|
import { memo, useMemo, useRef, useState, useCallback, useEffect } from 'react';
|
|
4
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
6
|
|
|
@@ -621,5 +622,5 @@ function cx(...parts) {
|
|
|
621
622
|
}
|
|
622
623
|
|
|
623
624
|
export { ActionNode, DecisionNode, FlowCanvas, FlowViewer, NodeShell, OutputNode, SubgraphNode, TriggerNode, alignNodes, assignToLane, cloneSubgraph, defaultNodeTypes, distributeNodes, duplicateNode, reconnectEdge2 as reconnectEdge, removeEdges, removeFromLane, removeNodes, setEdgeLabel };
|
|
624
|
-
//# sourceMappingURL=chunk-
|
|
625
|
-
//# sourceMappingURL=chunk-
|
|
625
|
+
//# sourceMappingURL=chunk-BUNFPBTF.js.map
|
|
626
|
+
//# sourceMappingURL=chunk-BUNFPBTF.js.map
|