@particle-academy/fancy-flow 0.77.1 → 0.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/{FlowViewer-Ak8kbY0e.d.cts → FlowViewer-BqYQl2vS.d.cts} +1 -1
  2. package/dist/{FlowViewer-BAV29Zpi.d.ts → FlowViewer-_Fq8AX9V.d.ts} +1 -1
  3. package/dist/{HumanPrompt-xYPCL2jO.d.cts → HumanPrompt-Sl1wD9Bx.d.cts} +2 -2
  4. package/dist/{HumanPrompt-Ge_ccCgS.d.ts → HumanPrompt-_SKIdSpx.d.ts} +2 -2
  5. package/dist/{chunk-G5RAGPVD.js → chunk-3EDB6ELL.js} +3 -3
  6. package/dist/{chunk-G5RAGPVD.js.map → chunk-3EDB6ELL.js.map} +1 -1
  7. package/dist/{chunk-CQAMEPPI.js → chunk-4GNDRRJ3.js} +3 -3
  8. package/dist/{chunk-CQAMEPPI.js.map → chunk-4GNDRRJ3.js.map} +1 -1
  9. package/dist/{chunk-EGXA4SYJ.js → chunk-BBFHGAEN.js} +4 -4
  10. package/dist/{chunk-EGXA4SYJ.js.map → chunk-BBFHGAEN.js.map} +1 -1
  11. package/dist/{chunk-ARSOSEJV.js → chunk-GPFIJR2K.js} +4 -4
  12. package/dist/{chunk-ARSOSEJV.js.map → chunk-GPFIJR2K.js.map} +1 -1
  13. package/dist/{chunk-EEIWAIXW.js → chunk-J5YUYDMK.js} +106 -6
  14. package/dist/chunk-J5YUYDMK.js.map +1 -0
  15. package/dist/{chunk-2VI24UPB.js → chunk-S4MOUOG4.js} +3 -3
  16. package/dist/{chunk-2VI24UPB.js.map → chunk-S4MOUOG4.js.map} +1 -1
  17. package/dist/{chunk-T6WIIGSK.js → chunk-XO4ODEY2.js} +3 -3
  18. package/dist/{chunk-T6WIIGSK.js.map → chunk-XO4ODEY2.js.map} +1 -1
  19. package/dist/connectors.d.cts +2 -2
  20. package/dist/connectors.d.ts +2 -2
  21. package/dist/durable/index.d.cts +2 -2
  22. package/dist/durable/index.d.ts +2 -2
  23. package/dist/durable.cjs +104 -4
  24. package/dist/durable.cjs.map +1 -1
  25. package/dist/durable.js +1 -1
  26. package/dist/engine.cjs +104 -4
  27. package/dist/engine.cjs.map +1 -1
  28. package/dist/engine.d.cts +6 -6
  29. package/dist/engine.d.ts +6 -6
  30. package/dist/engine.js +4 -4
  31. package/dist/fields/react-fancy.d.cts +3 -3
  32. package/dist/fields/react-fancy.d.ts +3 -3
  33. package/dist/index.cjs +104 -4
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +10 -10
  36. package/dist/index.d.ts +10 -10
  37. package/dist/index.js +12 -12
  38. package/dist/layout/index.d.cts +1 -1
  39. package/dist/layout/index.d.ts +1 -1
  40. package/dist/llm/prism.d.cts +1 -1
  41. package/dist/llm/prism.d.ts +1 -1
  42. package/dist/llm/vercel-ai.d.cts +1 -1
  43. package/dist/llm/vercel-ai.d.ts +1 -1
  44. package/dist/registry/index.d.cts +5 -5
  45. package/dist/registry/index.d.ts +5 -5
  46. package/dist/{registry-JUcN_xWK.d.ts → registry-C4GcH583.d.ts} +1 -1
  47. package/dist/{registry-B6SiTaLZ.d.cts → registry-DWIY3bMP.d.cts} +1 -1
  48. package/dist/registry.cjs +104 -4
  49. package/dist/registry.cjs.map +1 -1
  50. package/dist/registry.js +2 -2
  51. package/dist/{run-cohort-rgT_FX3V.d.ts → run-cohort-DAfhZm-p.d.ts} +2 -2
  52. package/dist/{run-cohort-DNpPa0mq.d.cts → run-cohort-DRJvUWO9.d.cts} +2 -2
  53. package/dist/{run-flow-pW0PllaZ.d.cts → run-flow-Bdrn4lQV.d.cts} +1 -1
  54. package/dist/{run-flow-BLP9rXfO.d.ts → run-flow-D2iOjWsj.d.ts} +1 -1
  55. package/dist/runtime/index.d.cts +5 -5
  56. package/dist/runtime/index.d.ts +5 -5
  57. package/dist/runtime.cjs +104 -4
  58. package/dist/runtime.cjs.map +1 -1
  59. package/dist/runtime.js +3 -3
  60. package/dist/schema/index.d.cts +1 -1
  61. package/dist/schema/index.d.ts +1 -1
  62. package/dist/schema.cjs +104 -4
  63. package/dist/schema.cjs.map +1 -1
  64. package/dist/schema.js +3 -3
  65. package/dist/screens.cjs +104 -4
  66. package/dist/screens.cjs.map +1 -1
  67. package/dist/screens.d.cts +2 -2
  68. package/dist/screens.d.ts +2 -2
  69. package/dist/screens.js +4 -4
  70. package/dist/terminal/fancy-term-host.d.cts +1 -1
  71. package/dist/terminal/fancy-term-host.d.ts +1 -1
  72. package/dist/{types-BdkXxjFh.d.cts → types-B1jftRa9.d.cts} +1 -1
  73. package/dist/{types-CbekKMMO.d.ts → types-D5SBBpbe.d.ts} +1 -1
  74. package/dist/{types-B-Syk9-M.d.ts → types-E48Dpesq.d.cts} +20 -0
  75. package/dist/{types-B-Syk9-M.d.cts → types-E48Dpesq.d.ts} +20 -0
  76. package/dist/ux.cjs +104 -4
  77. package/dist/ux.cjs.map +1 -1
  78. package/dist/ux.d.cts +2 -2
  79. package/dist/ux.d.ts +2 -2
  80. package/dist/ux.js +1 -1
  81. package/package.json +2 -2
  82. package/dist/chunk-EEIWAIXW.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { applyNodeChanges, applyEdgeChanges, addEdge } from './chunk-OWENS2H5.js';
2
- import { runFlow, getNodeKind } from './chunk-EEIWAIXW.js';
2
+ import { runFlow, getNodeKind } from './chunk-J5YUYDMK.js';
3
3
  import { useState, useRef, useCallback, useMemo } from 'react';
4
4
 
5
5
  function useFlowRun({ maxFeed = 200 } = {}) {
@@ -235,5 +235,5 @@ function useFlowHistory(flow) {
235
235
  }
236
236
 
237
237
  export { applyOutputsToNodes, applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState };
238
- //# sourceMappingURL=chunk-2VI24UPB.js.map
239
- //# sourceMappingURL=chunk-2VI24UPB.js.map
238
+ //# sourceMappingURL=chunk-S4MOUOG4.js.map
239
+ //# sourceMappingURL=chunk-S4MOUOG4.js.map
@@ -1 +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,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,QAAA,CAAwC,EAAE,CAAA;AAC1E,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,QAAA,CAA6C,EAAE,CAAA;AACnF,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,QAAA,CAA6C,EAAE,CAAA;AACvF,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,QAAA,CAAkC,EAAE,CAAA;AAClE,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAA,CAA6B,EAAE,CAAA;AACvD,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,KAAK,CAAA;AAC5C,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAA2B,IAAI,CAAA;AACnE,EAAA,MAAM,QAAA,GAAW,OAA+B,IAAI,CAAA;AAEpD,EAAA,MAAM,WAAA,GAAc,WAAA;AAAA,IAClB,CAAC,CAAA,KAAgB;AACf,MAAA,QAAQ,EAAE,IAAA;AAAM,QACd,KAAK,aAAA;AACH,UAAA,WAAA,CAAY,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,EAAG,CAAC,CAAA,CAAE,MAAM,GAAG,CAAA,CAAE,MAAA,EAAO,CAAE,CAAA;AACnD,UAAA,aAAA,CAAc,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,EAAG,CAAC,CAAA,CAAE,MAAM,GAAG,CAAA,CAAE,IAAA,EAAK,CAAE,CAAA;AACnD,UAAA,UAAA,C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AA,MACA,SAAA,EAAW,CAAC,IAAA,KAAS;AACnB,QAAA,OAAA,EAAQ;AACR,QAAA,IAAA,CAAK,UAAU,IAAI,CAAA;AAAA,MACrB;AAAA,KACF,CAAA;AAAA,IACA,CAAC,MAAM,OAAO;AAAA,GAChB;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,IAAA;AAAA,IACA,IAAA;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-2VI24UPB.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
+ {"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,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,QAAA,CAAwC,EAAE,CAAA;AAC1E,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,QAAA,CAA6C,EAAE,CAAA;AACnF,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,QAAA,CAA6C,EAAE,CAAA;AACvF,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,QAAA,CAAkC,EAAE,CAAA;AAClE,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAA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A;AAAA,MACA,QAAA,EAAU,CAAC,CAAA,KAAM;AACf,QAAA,OAAA,EAAQ;AACR,QAAA,IAAA,CAAK,SAAS,CAAC,CAAA;AAAA,MACjB,CAAA;AAAA,MACA,aAAA,EAAe,CAAC,OAAA,KAA0B;AAExC,QAAA,IAAI,CAAC,SAAA,CAAU,OAAA,IAAW,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,KAAS,QAAQ,CAAA,EAAG,OAAA,EAAQ;AAC5E,QAAA,IAAA,CAAK,cAAc,OAAO,CAAA;AAAA,MAC5B,CAAA;AAAA,MACA,aAAA,EAAe,CAAC,OAAA,KAA0B;AACxC,QAAA,IAAI,CAAC,SAAA,CAAU,OAAA,IAAW,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,KAAS,QAAQ,CAAA,EAAG,OAAA,EAAQ;AAC5E,QAAA,IAAA,CAAK,cAAc,OAAO,CAAA;AAAA,MAC5B,CAAA;AAAA,MACA,SAAA,EAAW,CAAC,IAAA,KAAS;AACnB,QAAA,OAAA,EAAQ;AACR,QAAA,IAAA,CAAK,UAAU,IAAI,CAAA;AAAA,MACrB;AAAA,KACF,CAAA;AAAA,IACA,CAAC,MAAM,OAAO;AAAA,GAChB;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,IAAA;AAAA,IACA,IAAA;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-S4MOUOG4.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,6 +1,6 @@
1
1
  import { RichInputPreview } from './chunk-F5RPRB7A.js';
2
2
  import { NodeResizer, NodeToolbar, Handle, Position } from './chunk-OWENS2H5.js';
3
- import { BUILTIN_KIND_DATA, getNodeKind, categoryAccent, resolveNodePorts, nodeConfig, ensureBuiltinKinds, registerBuiltinKindInternal, listNodeKinds, kindIds } from './chunk-EEIWAIXW.js';
3
+ import { BUILTIN_KIND_DATA, getNodeKind, categoryAccent, resolveNodePorts, nodeConfig, ensureBuiltinKinds, registerBuiltinKindInternal, listNodeKinds, kindIds } from './chunk-J5YUYDMK.js';
4
4
  import { memo, createContext, useMemo, useState, useRef, useEffect, createElement, useContext } from 'react';
5
5
  import { jsxs, jsx } from 'react/jsx-runtime';
6
6
 
@@ -315,5 +315,5 @@ function buildNodeTypes() {
315
315
  }
316
316
 
317
317
  export { ANY_PORT_TYPE, BUILTIN_KINDS, FlowEditorProvider, LaneNode, NoteNode, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility, registerBuiltinKinds, useFlowEditor, useFlowEditorOptional };
318
- //# sourceMappingURL=chunk-T6WIIGSK.js.map
319
- //# sourceMappingURL=chunk-T6WIIGSK.js.map
318
+ //# sourceMappingURL=chunk-XO4ODEY2.js.map
319
+ //# sourceMappingURL=chunk-XO4ODEY2.js.map
@@ -1 +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,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AAC,IAAA,KAAS;AACjF,EAAA,MAAM,QAAA,GAAW,SAAA,CAAU,IAAA,CAAK,IAAI,CAAA;AACpC,EAAA,OAAO,WAAW,EAAE,GAAG,IAAA,EAAM,GAAG,UAAS,GAAI,IAAA;AAC/C,CAAC;AAkBM,SAAS,oBAAA,GAA6B;AAM3C,EAAA,kBAAA,EAAmB;AAEnB,EAAA,KAAA,MAAW,IAAA,IAAQ,aAAA,EAAe,2BAAA,CAA4B,IAAI,CAAA;AACpE;;;ACmBO,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-T6WIIGSK.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 { ensureBuiltinKinds, registerBuiltinKindInternal } 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: it goes through `registerBuiltinKindInternal`, which\n * replaces a BUILTIN by name, so this UPGRADES the four kinds in place rather\n * than duplicating anything.\n *\n * It does NOT replace a name a host has claimed with `registerNodeKind`. That\n * is the whole point of 0.66.2 — a consumer's replacement of a builtin used to\n * be silently reverted every time this ran, and since the root barrel calls it\n * as an import side effect, whether that happened depended on bundler ordering.\n *\n * The distinction matters to anyone reading this to decide whether calling it\n * is safe: safe against builtins, deliberately powerless against a host.\n */\nexport function registerBuiltinKinds(): void {\n // Lay the React-free table down FIRST, through the same lazy path every other\n // entry point uses. Without this the flag is still unset, so the next read\n // anywhere — `getNodeKind`, the palette, a viewer — triggers\n // `ensureBuiltinKinds()` and re-registers the plain table OVER the decorated\n // kinds, silently dropping the four renderers this function exists to attach.\n ensureBuiltinKinds();\n\n for (const kind of BUILTIN_KINDS) registerBuiltinKindInternal(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 unregisterNodeKind,\n applyKindSchemaOverlay,\n clearKindSchemaOverlays,\n type KindSchemaOverlay,\n type KindSchemaOverlayResult,\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
+ {"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,EAAe,OAAO,IAAA;AACvD,EAAA,OAAO,CAAA,KAAM,CAAA;AACf;AAcA,SAAS,QAAA,CAAS,MAAgB,IAAA,EAA8C;AAC9E,EAAA,MAAM,OAAO,WAAA,CAAa,IAAA,CAAK,IAAA,EAAc,IAAA,IAAQ,KAAK,IAAI,CAAA;AAC9D,EAAA,MAAM,QAAA,GAAW,gBAAA,CAAiB,IAAA,EAAM,IAAA,IAAQ,MAAS,CAAA;AACzD,EAAA,OAAO,QAAA,CAAS,IAAI,CAAA,IAAK,EAAC;AAC5B;AAOA,SAAS,QAAA,CACP,OACA,QAAA,EAC4B;AAC5B,EAAA,IAAI,QAAA,IAAY,MAAM,OAAO,KAAA,CAAM,WAAW,CAAA,GAAI,KAAA,CAAM,CAAC,CAAA,GAAI,MAAA;AAC7D,EAAA,OAAO,MAAM,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,QAAQ,CAAA;AAC5C;AAcO,SAAS,yBAAA,CACd,QAAA,EACA,OAAA,GAAsC,EAAC,EACK;AAC5C,EAAA,MAAM,UAAA,GAAa,QAAQ,UAAA,IAAc,wBAAA;AACzC,EAAA,OAAO,CAAC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A,EAAS;AAAA,EAChD,iCAAA,EAAmC,EAAE,SAAA,EAAW,QAAA,EAAS;AAAA,EACzD,wBAAA,EAA0B,EAAE,SAAA,EAAW,QAAA,EAAS;AAAA,EAChD,mCAAA,EAAqC;AAAA;AAAA;AAAA,IAGnC,UAAA,EAAY,CAAC,GAAA,KACX,aAAA,CAAc,gBAAA,EAAkB,EAAE,MAAA,EAAS,GAAA,CAAI,MAAA,IAAU,EAAC,EAA+B;AAAA;AAE/F,CAAA;AASO,IAAM,aAAA,GAAsC,iBAAA,CAAkB,GAAA,CAAI,CAAC,IAAA,KAAS;AACjF,EAAA,MAAM,QAAA,GAAW,SAAA,CAAU,IAAA,CAAK,IAAI,CAAA;AACpC,EAAA,OAAO,WAAW,EAAE,GAAG,IAAA,EAAM,GAAG,UAAS,GAAI,IAAA;AAC/C,CAAC;AAkBM,SAAS,oBAAA,GAA6B;AAM3C,EAAA,kBAAA,EAAmB;AAEnB,EAAA,KAAA,MAAW,IAAA,IAAQ,aAAA,EAAe,2BAAA,CAA4B,IAAI,CAAA;AACpE;;;ACmBO,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-XO4ODEY2.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 { ensureBuiltinKinds, registerBuiltinKindInternal } 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: it goes through `registerBuiltinKindInternal`, which\n * replaces a BUILTIN by name, so this UPGRADES the four kinds in place rather\n * than duplicating anything.\n *\n * It does NOT replace a name a host has claimed with `registerNodeKind`. That\n * is the whole point of 0.66.2 — a consumer's replacement of a builtin used to\n * be silently reverted every time this ran, and since the root barrel calls it\n * as an import side effect, whether that happened depended on bundler ordering.\n *\n * The distinction matters to anyone reading this to decide whether calling it\n * is safe: safe against builtins, deliberately powerless against a host.\n */\nexport function registerBuiltinKinds(): void {\n // Lay the React-free table down FIRST, through the same lazy path every other\n // entry point uses. Without this the flag is still unset, so the next read\n // anywhere — `getNodeKind`, the palette, a viewer — triggers\n // `ensureBuiltinKinds()` and re-registers the plain table OVER the decorated\n // kinds, silently dropping the four renderers this function exists to attach.\n ensureBuiltinKinds();\n\n for (const kind of BUILTIN_KINDS) registerBuiltinKindInternal(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 unregisterNodeKind,\n applyKindSchemaOverlay,\n clearKindSchemaOverlays,\n type KindSchemaOverlay,\n type KindSchemaOverlayResult,\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,6 +1,6 @@
1
- import { C as ConfigField, N as NodeKindDefinition, O as OutputField } from './types-BdkXxjFh.cjs';
1
+ import { C as ConfigField, N as NodeKindDefinition, O as OutputField } from './types-B1jftRa9.cjs';
2
2
  import 'react';
3
- import './types-B-Syk9-M.cjs';
3
+ import './types-E48Dpesq.cjs';
4
4
  import '@xyflow/react';
5
5
  import './pause-9iT4tCEV.cjs';
6
6
 
@@ -1,6 +1,6 @@
1
- import { C as ConfigField, N as NodeKindDefinition, O as OutputField } from './types-CbekKMMO.js';
1
+ import { C as ConfigField, N as NodeKindDefinition, O as OutputField } from './types-D5SBBpbe.js';
2
2
  import 'react';
3
- import './types-B-Syk9-M.js';
3
+ import './types-E48Dpesq.js';
4
4
  import '@xyflow/react';
5
5
  import './pause-9iT4tCEV.js';
6
6
 
@@ -1,5 +1,5 @@
1
- import { F as FlowGraph, R as RunEvent, c as RunIdentity, E as ExecutorRegistry, a as FlowNode, N as NodeExecutor, d as RunIdentityJson } from '../types-B-Syk9-M.cjs';
2
- import { a as RunResult } from '../run-flow-pW0PllaZ.cjs';
1
+ import { F as FlowGraph, R as RunEvent, c as RunIdentity, E as ExecutorRegistry, a as FlowNode, N as NodeExecutor, d as RunIdentityJson } from '../types-E48Dpesq.cjs';
2
+ import { a as RunResult } from '../run-flow-Bdrn4lQV.cjs';
3
3
  import { b as PauseSignal } from '../pause-9iT4tCEV.cjs';
4
4
  import '@xyflow/react';
5
5
 
@@ -1,5 +1,5 @@
1
- import { F as FlowGraph, R as RunEvent, c as RunIdentity, E as ExecutorRegistry, a as FlowNode, N as NodeExecutor, d as RunIdentityJson } from '../types-B-Syk9-M.js';
2
- import { a as RunResult } from '../run-flow-BLP9rXfO.js';
1
+ import { F as FlowGraph, R as RunEvent, c as RunIdentity, E as ExecutorRegistry, a as FlowNode, N as NodeExecutor, d as RunIdentityJson } from '../types-E48Dpesq.js';
2
+ import { a as RunResult } from '../run-flow-D2iOjWsj.js';
3
3
  import { b as PauseSignal } from '../pause-9iT4tCEV.js';
4
4
  import '@xyflow/react';
5
5
 
package/dist/durable.cjs CHANGED
@@ -835,6 +835,9 @@ async function runFlow(graph, executors, onEvent = () => {
835
835
  executors,
836
836
  depth,
837
837
  run,
838
+ // Structural executors derive a nested lane from the graph they are
839
+ // in; `for_each`'s `item` port cannot be implemented without it.
840
+ graph,
838
841
  terminal: terminalAccessorFor(node)
839
842
  })
840
843
  );
@@ -1330,14 +1333,102 @@ var mergeExecutor = (ctx) => {
1330
1333
  }
1331
1334
  return merged;
1332
1335
  };
1333
- var forEachExecutor = (ctx) => {
1334
- const source = resolve(configOf(ctx.node).source, ctx.inputs);
1336
+ var FOR_EACH_DEFAULT_MAX_ITEMS = 1e3;
1337
+ var FOR_EACH_HARD_MAX_ITEMS = 1e4;
1338
+ function reachable(adjacency, starts) {
1339
+ const seen = /* @__PURE__ */ new Set();
1340
+ const queue = [...starts];
1341
+ for (let cursor = 0; cursor < queue.length; cursor += 1) {
1342
+ const id = queue[cursor];
1343
+ if (seen.has(id)) continue;
1344
+ seen.add(id);
1345
+ for (const target of adjacency.get(id) ?? []) queue.push(target);
1346
+ }
1347
+ return seen;
1348
+ }
1349
+ function forEachLane(graph, nodeId) {
1350
+ const handleOf = (edge) => edge.sourceHandle ?? "out";
1351
+ const itemEdges = graph.edges.filter((e) => e.source === nodeId && handleOf(e) === "item");
1352
+ if (itemEdges.length === 0) return null;
1353
+ const adjacency = /* @__PURE__ */ new Map();
1354
+ for (const edge of graph.edges) {
1355
+ const list = adjacency.get(edge.source) ?? [];
1356
+ list.push(edge.target);
1357
+ adjacency.set(edge.source, list);
1358
+ }
1359
+ const done = reachable(
1360
+ adjacency,
1361
+ graph.edges.filter((e) => e.source === nodeId && handleOf(e) === "done").map((e) => e.target)
1362
+ );
1363
+ const body = new Set(
1364
+ [...reachable(adjacency, itemEdges.map((e) => e.target))].filter(
1365
+ (id) => !done.has(id) && id !== nodeId
1366
+ )
1367
+ );
1368
+ return {
1369
+ graph: {
1370
+ nodes: graph.nodes.filter((n) => body.has(n.id)),
1371
+ edges: graph.edges.filter((e) => body.has(e.source) && body.has(e.target)),
1372
+ ...graph.inputs === void 0 ? {} : { inputs: graph.inputs }
1373
+ },
1374
+ entries: itemEdges.filter((e) => body.has(e.target))
1375
+ };
1376
+ }
1377
+ var forEachExecutor = async (ctx) => {
1378
+ const config = configOf(ctx.node);
1379
+ const source = resolve(config.source, ctx.inputs);
1335
1380
  let items;
1336
1381
  if (Array.isArray(source)) items = source;
1337
1382
  else if (source === null || source === void 0) items = [];
1338
1383
  else if (typeof source === "object") items = Object.values(source);
1339
1384
  else items = [source];
1340
- return { items, count: items.length };
1385
+ const lane = ctx.graph ? forEachLane(ctx.graph, ctx.node.id) : null;
1386
+ if (lane === null || config.mode === "collect") {
1387
+ return { items, count: items.length };
1388
+ }
1389
+ if (lane.graph.nodes.length === 0) {
1390
+ ctx.abort(`for_each "${ctx.node.id}" has an item edge but its derived lane is empty`);
1391
+ }
1392
+ const maxItems = Number(config.maxItems ?? FOR_EACH_DEFAULT_MAX_ITEMS);
1393
+ if (!Number.isFinite(maxItems) || maxItems < 1 || maxItems > FOR_EACH_HARD_MAX_ITEMS) {
1394
+ ctx.abort(`for_each "${ctx.node.id}" maxItems must be between 1 and ${FOR_EACH_HARD_MAX_ITEMS}`);
1395
+ }
1396
+ if (items.length > maxItems) {
1397
+ ctx.abort(
1398
+ `for_each "${ctx.node.id}" resolved ${items.length} items exceeds its maxItems cap of ${maxItems}`
1399
+ );
1400
+ }
1401
+ const results = [];
1402
+ const failures = [];
1403
+ for (const [index, item] of items.entries()) {
1404
+ const initialInputs = {};
1405
+ for (const edge of lane.entries) {
1406
+ initialInputs[edge.target] = {
1407
+ ...initialInputs[edge.target] ?? {},
1408
+ [edge.targetHandle ?? "in"]: item
1409
+ };
1410
+ }
1411
+ const nested = await runFlow(lane.graph, { ...ctx.executors ?? {} }, () => {
1412
+ }, {
1413
+ initialInputs,
1414
+ depth: (ctx.depth ?? 0) + 1,
1415
+ // The index rides on the identity, so a node in iteration 3 cannot share
1416
+ // an idempotency key with the same node in iteration 4.
1417
+ run: ctx.run?.descend(ctx.node.id, index)
1418
+ });
1419
+ if (!nested.ok) {
1420
+ const reason = nested.error ?? "unknown error";
1421
+ if (decodePause(reason)) ctx.abort(reason);
1422
+ results.push(null);
1423
+ failures.push({ index, item, error: reason });
1424
+ continue;
1425
+ }
1426
+ results.push(nested.outputs);
1427
+ }
1428
+ return {
1429
+ __port: "done",
1430
+ value: { items, results, failures, count: items.length }
1431
+ };
1341
1432
  };
1342
1433
  var manualTriggerExecutor = (ctx) => ctx.inputs;
1343
1434
  var outputExecutor = (ctx) => {
@@ -1894,6 +1985,15 @@ var KINDS = [
1894
1985
  name: "@particle-academy/for_each",
1895
1986
  outputShape: [
1896
1987
  { path: "items", type: "array" },
1988
+ // `results` and `failures` are the WIRED shape -- what a lane produces
1989
+ // when the `item` port is connected. Declared unconditionally because a
1990
+ // declaration describes the kind, not one graph's use of it, and because
1991
+ // the shared table requires them: fancy-conformance 0.30.0 added
1992
+ // `results` and 0.31.0 added `failures`, both BREAKING, both so that a
1993
+ // runtime which has not implemented iteration fails here rather than
1994
+ // reporting surface parity it does not have.
1995
+ { path: "results", type: "array" },
1996
+ { path: "failures", type: "array" },
1897
1997
  { path: "count", type: "number" }
1898
1998
  ],
1899
1999
  aliases: ["for_each", "@fancy/for_each"],
@@ -1902,7 +2002,7 @@ var KINDS = [
1902
2002
  executor: forEachExecutor,
1903
2003
  category: "logic",
1904
2004
  label: "For Each",
1905
- description: "Publishes the resolved list and its size on BOTH `item` and `done`. Fan-out as DATA, not as jobs -- nothing runs per item.",
2005
+ description: "Wire `item` to a lane and it runs once per item, aggregating `results` and `failures` on `done`. Leave `item` unwired (or set `mode: collect`) and it just publishes the list and its size -- one node, one checkpoint.",
1906
2006
  icon: "\u21BB",
1907
2007
  inputs: [{ id: "in" }],
1908
2008
  outputs: [{ id: "item", label: "item" }, { id: "done", label: "done" }],