@particle-academy/fancy-flow 0.66.0 → 0.66.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/chunk-27RZJAE2.js +2586 -0
  2. package/dist/chunk-27RZJAE2.js.map +1 -0
  3. package/dist/{chunk-FNYLKSFJ.js → chunk-2QTEELJE.js} +4 -3
  4. package/dist/chunk-2QTEELJE.js.map +1 -0
  5. package/dist/{chunk-MTONBM53.js → chunk-6AYC3BWI.js} +4 -4
  6. package/dist/{chunk-MTONBM53.js.map → chunk-6AYC3BWI.js.map} +1 -1
  7. package/dist/{chunk-IEYCNFXZ.js → chunk-6TH646CS.js} +127 -5
  8. package/dist/chunk-6TH646CS.js.map +1 -0
  9. package/dist/{chunk-UCCTXJXL.js → chunk-BUNFPBTF.js} +5 -4
  10. package/dist/chunk-BUNFPBTF.js.map +1 -0
  11. package/dist/{chunk-B7HKJJVV.js → chunk-FV3D366L.js} +3 -3
  12. package/dist/{chunk-B7HKJJVV.js.map → chunk-FV3D366L.js.map} +1 -1
  13. package/dist/{chunk-HQGOFGAL.js → chunk-OWENS2H5.js} +64 -2754
  14. package/dist/chunk-OWENS2H5.js.map +1 -0
  15. package/dist/{chunk-PNHZHEWE.js → chunk-RE3XNVSB.js} +3 -3
  16. package/dist/{chunk-PNHZHEWE.js.map → chunk-RE3XNVSB.js.map} +1 -1
  17. package/dist/durable.cjs +153 -9213
  18. package/dist/durable.cjs.map +1 -1
  19. package/dist/durable.js +1 -2
  20. package/dist/durable.js.map +1 -1
  21. package/dist/engine.cjs +103 -9165
  22. package/dist/engine.cjs.map +1 -1
  23. package/dist/engine.js +4 -5
  24. package/dist/engine.js.map +1 -1
  25. package/dist/index.cjs +11135 -11121
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.js +15 -13
  28. package/dist/index.js.map +1 -1
  29. package/dist/registry/index.d.cts +15 -3
  30. package/dist/registry/index.d.ts +15 -3
  31. package/dist/registry.cjs +11166 -11153
  32. package/dist/registry.cjs.map +1 -1
  33. package/dist/registry.js +4 -3
  34. package/dist/runtime.cjs +10772 -10924
  35. package/dist/runtime.cjs.map +1 -1
  36. package/dist/runtime.js +4 -4
  37. package/dist/schema.cjs +85 -9147
  38. package/dist/schema.cjs.map +1 -1
  39. package/dist/schema.js +3 -4
  40. package/dist/screens.cjs +7 -52
  41. package/dist/screens.cjs.map +1 -1
  42. package/dist/screens.js +6 -5
  43. package/dist/screens.js.map +1 -1
  44. package/dist/ux.cjs +89 -9147
  45. package/dist/ux.cjs.map +1 -1
  46. package/dist/ux.js +1 -2
  47. package/dist/ux.js.map +1 -1
  48. package/package.json +1 -1
  49. package/dist/chunk-FNYLKSFJ.js.map +0 -1
  50. package/dist/chunk-HQGOFGAL.js.map +0 -1
  51. package/dist/chunk-IEYCNFXZ.js.map +0 -1
  52. package/dist/chunk-UCCTXJXL.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/registry/llm-router.ts","../src/registry/ports.ts","../src/runtime/run-identity.ts","../src/components/FlowEditor/human-fields.ts","../src/registry/subflow.ts","../src/expressions/expr.ts","../src/registry/logic.ts","../src/registry/terminal-nodes.ts","../src/registry/builtin-kinds.ts","../src/registry/registry.ts","../src/runtime/terminal-transcript.ts","../src/runtime/terminal-sessions.ts","../src/runtime/workflow-props.ts","../src/runtime/run-flow.ts"],"names":["resolve","configOf","text"],"mappings":";;;AAkBO,SAAS,eAAe,MAAA,EAA6C;AAC1E,EAAA,MAAM,MAAM,MAAA,CAAO,MAAA;AACnB,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA,SAAU,EAAC;AACjC,EAAA,OAAO,GAAA,CACJ,IAAI,CAAC,CAAA,MAAO,EAAE,IAAA,EAAM,MAAA,CAAQ,CAAA,EAAW,IAAA,IAAQ,EAAE,CAAA,CAAE,MAAK,EAAG,WAAA,EAAc,CAAA,EAAW,WAAA,EAAY,CAAE,CA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EAAK;AACzB,EAAA,IAAI,YAAY,EAAA,EAAI;AAEpB,EAAA,OAAA,CAAQ,EAAE,MAAM,cAAA,EAAgB,MAAA,EAAQ,KAAK,EAAA,EAAI,KAAA,EAAO,SAAS,CAAA;AACnE","file":"chunk-27RZJAE2.js","sourcesContent":["import { getLlmClient, type LlmRoute } from \"./capabilities\";\nimport type { NodeExecutor } from \"../types\";\n\n/**\n * `@fancy/llm_branch` — a SHUTTLE, not an engine.\n *\n * It carries the declared routes and the decision prompt out to whatever LLM\n * client the host registered, and carries the chosen port back down the graph.\n * It contains no provider SDK, no prompt engineering, no response parsing and\n * no retry policy — all of that belongs to the host's client, which is what\n * lets this node live in core without every consumer inheriting an LLM\n * dependency.\n *\n * The one thing it does own is graph integrity, because that is a workflow\n * concern rather than an AI one: a port the model invents must never route.\n */\n\n/** Read the node's declared routes out of config. */\nexport function declaredRoutes(config: Record<string, unknown>): LlmRoute[] {\n const raw = config.routes;\n if (!Array.isArray(raw)) return [];\n return raw\n .map((r) => ({ port: String((r as any)?.port ?? \"\").trim(), description: (r as any)?.description }))\n .filter((r) => r.port !== \"\");\n}\n\n/**\n * Where a run goes when the model returns a port that was never offered.\n *\n * Emitting on a port with no edge silently ends the branch — the worst failure\n * mode in a workflow engine, because the run reports success having done\n * nothing. So: the `fallback` port when it exists, else the first declared\n * route, and always loudly.\n */\nexport function resolveFallbackPort(routes: LlmRoute[], fallbackEnabled: boolean): string {\n if (fallbackEnabled) return \"fallback\";\n // Callers only reach this with at least one declared route (a node with none\n // aborts earlier), so there is always somewhere safe to land.\n return routes[0]?.port ?? \"out\";\n}\n\nexport const llmRouterExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as any)?.config ?? {}) as Record<string, unknown>;\n const routes = declaredRoutes(config);\n\n if (routes.length === 0) {\n ctx.abort(\"llm_router has no routes configured\");\n }\n\n const client = getLlmClient();\n if (!client) {\n // Fail loudly rather than guessing a branch. A silent default here would\n // look like the model made a choice.\n ctx.abort(\n \"No LLM client registered. Call registerLlmClient() with your provider adapter — fancy-flow ships the routing, not the model call.\",\n );\n }\n\n const fallbackEnabled = config.fallback !== false;\n\n const choice = await client!.chooseRoute({\n system: typeof config.system === \"string\" ? config.system : undefined,\n prompt: String(config.prompt ?? ctx.inputs ?? \"\"),\n routes,\n provider: typeof config.provider === \"string\" ? config.provider : undefined,\n model: typeof config.model === \"string\" ? config.model : undefined,\n credential: typeof config.credential === \"string\" ? config.credential : undefined,\n });\n\n const offered = new Set(routes.map((r) => r.port));\n let port = choice?.port ?? \"\";\n let reason = choice?.reason;\n\n if (!offered.has(port)) {\n const safe = resolveFallbackPort(routes, fallbackEnabled);\n ctx.emit({\n type: \"log\",\n nodeId: ctx.node.id,\n level: \"warn\",\n message: `llm_router: model returned \"${port || \"(nothing)\"}\", which is not a declared route. Routing to \"${safe}\".`,\n });\n reason = reason ?? `unrecognised route \"${port}\"`;\n port = safe;\n }\n\n // The reason travels WITH the value, so a completed run explains itself\n // without needing the model call replayed.\n return { __port: port, value: { route: port, reason, input: ctx.inputs } };\n};\n","import type { FlowNode, PortDescriptor } from \"../types\";\nimport type { NodeKindDefinition, PortSpec } from \"./types\";\n\n/**\n * Port resolution — the single place a node's ports are derived, shared by\n * the canvas renderer and the headless runtime.\n *\n * This module is deliberately React-free: `runFlow` (the `/engine` entry)\n * imports it, and the engine bundle must stay free of React.\n *\n * ## Why this is centralized\n *\n * Ports used to be read in two places that disagreed — the canvas consulted\n * `data.outputs ?? kind.outputs`, while the runtime consulted `data.outputs`\n * ONLY and fell back to a single `out` port. A kind that declared branch ports\n * therefore drew correctly and then routed as if it had one output, unless the\n * host remembered to mirror the ports onto every node's `data`. Both callers\n * now go through `resolveNodePorts`, so declared ports and executed ports\n * cannot drift apart.\n */\n\n/**\n * Resolve a `PortSpec` against a config object.\n *\n * A config-driven spec is author-supplied and runs on every render, so a throw\n * is contained: it degrades to \"undeclared\" (letting the caller fall back)\n * rather than taking out the canvas or aborting a run mid-flight.\n */\nexport function resolvePortSpec<TConfig>(\n spec: PortSpec<TConfig> | undefined,\n config: TConfig,\n): PortDescriptor[] | undefined {\n if (spec === undefined) return undefined;\n if (typeof spec !== \"function\") return spec;\n try {\n const resolved = (spec as (c: TConfig) => PortDescriptor[])(config);\n return Array.isArray(resolved) ? resolved : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Read the config bag off a node, tolerating the FlowNodeData union. */\nexport function nodeConfig(node: Pick<FlowNode, \"data\">): Record<string, unknown> {\n return ((node.data as any)?.config ?? {}) as Record<string, unknown>;\n}\n\n/**\n * Resolve a node's effective ports.\n *\n * Precedence: explicit `data.inputs`/`data.outputs` (a per-node host override)\n * beats the kind's declaration. `undefined` means \"nothing declared\" — the\n * caller applies its own category default.\n */\nexport function resolveNodePorts(\n node: Pick<FlowNode, \"data\">,\n kind?: Pick<NodeKindDefinition<any>, \"inputs\" | \"outputs\">,\n): { inputs?: PortDescriptor[]; outputs?: PortDescriptor[] } {\n const config = nodeConfig(node);\n const data = node.data as any;\n return {\n inputs: data?.inputs ?? resolvePortSpec(kind?.inputs, config),\n outputs: data?.outputs ?? resolvePortSpec(kind?.outputs, config),\n };\n}\n","/**\n * Who is running, which step this is, and how many times it has been tried.\n *\n * ## Why an engine needs this at all\n *\n * A node that WRITES to somebody else's system — charge a card, send a message,\n * open a pull request — can only survive a retry if the retry carries the same\n * idempotency key the first attempt did. Otherwise the provider treats the\n * second call as a new request and the customer is charged twice.\n *\n * Until this existed the executor context was `{ node, inputs, emit, abort }`,\n * which is not enough to derive one. Both obvious fallbacks are worse than\n * sending no key at all:\n *\n * - **the node id alone** is stable across retries, and also across RUNS — two\n * legitimate payments share a key and the provider silently collapses the\n * second into the first. A payment that never happened, reported as success;\n * - **a fresh random value** is unique per run, and also per ATTEMPT — a retry\n * creates a second charge, which is the thing being avoided.\n *\n * ## What actually identifies a step\n *\n * Not `(run, node)`. A node legitimately executes more than once inside one\n * run: once per subflow invocation, once per iteration of a loop an executor\n * drives itself. `(run, node)` would give every one of those the same key, and\n * a provider would honour exactly one of them.\n *\n * So a step is identified by the **path of invocations that led to it**, plus\n * an optional **occurrence** for repetition at the same level:\n *\n * ```text\n * runKey \":\" segment (\"/\" segment)* segment := escape(id) [\"#\" occurrence]\n * ```\n *\n * And the part that is easy to get backwards: **`attempt` is NOT in the key.**\n * It is carried here for logging and for {@link RunIdentity.isReplaySafe}, and\n * putting it in the key would restore the exact bug the key exists to prevent.\n *\n * Pinned cross-runtime by `shared/flow-run-identity` in\n * `@particle-academy/fancy-conformance`.\n */\n\n/** The wire shape — what a queue job payload carries. */\nexport type RunIdentityJson = {\n runKey: string;\n path?: string[];\n attempt?: number;\n firstAttemptAt?: string;\n};\n\n/**\n * Escape one segment so the composition is injective.\n *\n * `%` FIRST, or the escaping is not reversible: escaping `/` before `%` turns a\n * literal `a%2Fb` into the same text as the escaped form of `a/b`, which is the\n * collision this exists to prevent, reintroduced by its own fix.\n */\nexport function escapeSegment(value: string): string {\n // Not `replaceAll` — the package targets ES2020, and this must produce the\n // identical string on every runtime that reads the conformance table.\n return value.replace(/%/g, \"%25\").replace(/\\//g, \"%2F\").replace(/#/g, \"%23\");\n}\n\nfunction renderSegment(value: string, occurrence?: number | null): string {\n const escaped = escapeSegment(value);\n // `occurrence === 0` is a real occurrence. A truthiness check here silently\n // collapses iteration 0 into the un-iterated key.\n return occurrence === undefined || occurrence === null ? escaped : `${escaped}#${occurrence}`;\n}\n\nfunction instant(value: string): number {\n const ms = Date.parse(value);\n if (Number.isNaN(ms)) {\n throw new Error(\n `RunIdentity: firstAttemptAt is not a parseable timestamp: ${JSON.stringify(value)}`,\n );\n }\n return ms;\n}\n\n/**\n * A run, a position inside it, and how many times this position has been tried.\n *\n * Immutable. {@link descend} returns a new identity rather than mutating, so an\n * executor cannot change what its siblings see.\n */\nexport class RunIdentity {\n /** Stable for the whole run: same across retries, resumes, workers and hosts. */\n readonly runKey: string;\n\n /**\n * Enclosing invocation segments, outermost first, ALREADY RENDERED.\n *\n * Empty at the top level. A subflow pushes the invoking node's id; an\n * executor that loops pushes `id#i`.\n */\n readonly path: readonly string[];\n\n /**\n * 1-based attempt of THIS logical step. Never part of the key.\n *\n * The durable driver sets it from the node's claim row, which is exact. A\n * plain in-process `runFlow` gets whatever the host passed, which is\n * run-scoped and therefore conservative — see `isReplaySafe`.\n */\n readonly attempt: number;\n\n /** ISO-8601 UTC instant of attempt 1 of this step. */\n readonly firstAttemptAt: string;\n\n constructor(\n runKey: string,\n path: readonly string[] = [],\n attempt = 1,\n firstAttemptAt: string = new Date().toISOString(),\n ) {\n if (!runKey || runKey.trim() === \"\") {\n throw new Error(\"RunIdentity: runKey must be a non-empty string.\");\n }\n this.runKey = runKey;\n this.path = Object.freeze([...path]);\n this.attempt = Math.max(1, Math.trunc(attempt));\n this.firstAttemptAt = firstAttemptAt;\n Object.freeze(this);\n }\n\n /**\n * The identity of one execution of one node — stable across retries of that\n * execution, distinct from every other execution of the same node.\n *\n * Pass `occurrence` when an executor runs the same node more than once at the\n * same level (a loop body, one item of a fan-out it drives itself).\n */\n stepKey(nodeId: string, occurrence?: number | null): string {\n return `${this.runKey}:${[...this.path, renderSegment(nodeId, occurrence)].join(\"/\")}`;\n }\n\n /**\n * A child identity for work nested inside this step.\n *\n * `subflow` pushes the invoking node's id, so a node inside the child graph\n * cannot collide with a same-named node in the parent. Attempt and\n * `firstAttemptAt` are carried down unchanged: the nested work happens inside\n * this step's attempt, and shares its clock.\n */\n descend(segment: string, occurrence?: number | null): RunIdentity {\n return new RunIdentity(\n this.runKey,\n [...this.path, renderSegment(segment, occurrence)],\n this.attempt,\n this.firstAttemptAt,\n );\n }\n\n /** A copy on a different attempt, first-attempt clock preserved. */\n withAttempt(attempt: number, firstAttemptAt?: string): RunIdentity {\n return new RunIdentity(\n this.runKey,\n this.path,\n attempt,\n firstAttemptAt ?? this.firstAttemptAt,\n );\n }\n\n /**\n * May this attempt reuse the step key and still be deduplicated?\n *\n * Providers forget idempotency keys — Stripe after 24 hours. Past that\n * window, resending the key creates a second charge and sending a fresh one\n * creates a second charge, so **the caller must refuse rather than pick\n * between them**: a loud stuck run beats a silent double write.\n *\n * `true` on attempt 1 whatever the elapsed time — nothing was sent on an\n * earlier attempt, so there is nothing for the provider to have forgotten.\n * That is what lets a run park on a human gate for a week and then write.\n *\n * `windowSeconds: null` means the provider does not expire keys. `0` means\n * it does not dedupe at all, so no retry may reuse a key — it is a real\n * window, not an absent one, and the two must not be conflated: reading `0`\n * as `null` turns \"this provider does not dedupe\" into \"this provider\n * dedupes forever\", which is the more dangerous of the two by a distance.\n */\n isReplaySafe(windowSeconds: number | null | undefined, now: Date | string = new Date()): boolean {\n if (this.attempt <= 1) return true;\n if (windowSeconds === null || windowSeconds === undefined) return true;\n if (windowSeconds <= 0) return false;\n\n const nowMs = typeof now === \"string\" ? instant(now) : now.getTime();\n // Clock skew between two workers must not turn a legitimate retry into a\n // refusal, so a negative elapsed clamps to zero.\n const elapsedSeconds = Math.max(0, (nowMs - instant(this.firstAttemptAt)) / 1000);\n\n // Inclusive: a key written at T is remembered THROUGH T + window.\n return elapsedSeconds <= windowSeconds;\n }\n\n toJSON(): Required<RunIdentityJson> {\n return {\n runKey: this.runKey,\n path: [...this.path],\n attempt: this.attempt,\n firstAttemptAt: this.firstAttemptAt,\n };\n }\n\n /** Rebuild from a queue payload. */\n static from(value: RunIdentity | RunIdentityJson | string): RunIdentity {\n if (value instanceof RunIdentity) return value;\n if (typeof value === \"string\") return new RunIdentity(value);\n return new RunIdentity(\n value.runKey,\n value.path ?? [],\n value.attempt ?? 1,\n value.firstAttemptAt ?? new Date().toISOString(),\n );\n }\n}\n","/**\n * The field vocabulary a `user_input` node declares, and the normalizer that\n * turns whatever was actually written into something renderable.\n *\n * ## Why this is a separate module from `HumanPrompt.tsx`\n *\n * `src/registry/builtin.ts` needs `humanFieldType` for the `user_input` kind's\n * `outputShape`, and `builtin.ts` is in the import graph of the `/engine`\n * entry — the one `tests/core-nodes.test.ts` guards as React-free so a queue\n * worker or a CLI can register kinds without dragging React in. Importing the\n * modal's `.tsx` from there put a React module on that path and left the guard\n * standing only because treeshaking happened to drop it.\n *\n * Pure functions over plain data, in a `.ts` file, so the headless path cannot\n * regress on a future edit to the component.\n */\n\n/**\n * The control a field renders as, after {@link humanInputFields} has resolved\n * whatever the author, a peer runtime or an agent actually wrote.\n *\n * These are the CANONICAL names. The vocabulary an author may write is wider —\n * see {@link HUMAN_FIELD_TYPE_ALIASES} — because a `fields` array arrives from\n * three places (the config panel, a hand-written workflow JSON, and the PHP /\n * Python runtimes) and each has its own habits for spelling \"boolean\".\n */\nexport type HumanFieldType =\n | \"text\"\n | \"textarea\"\n | \"number\"\n | \"select\"\n | \"switch\"\n | \"date\"\n | \"datetime\"\n | \"time\"\n | \"email\"\n | \"url\"\n | \"tel\"\n | \"password\";\n\n/** One choice in a `select` field, after normalization. */\nexport type HumanFieldOption = { value: string; label: string };\n\n/** A field the input modal renders. Mirrors a `user_input` `fields` row. */\nexport type HumanField = {\n key: string;\n label?: string;\n type?: HumanFieldType;\n required?: boolean;\n placeholder?: string;\n options?: HumanFieldOption[];\n default?: unknown;\n};\n\n/**\n * Every spelling of a field type this accepts, mapped onto its canonical\n * control.\n *\n * The bug this table exists to fix: the old normalizer accepted exactly five\n * literal names and coerced everything else to `text`, so `boolean`, `date`,\n * `email` and `enum` — the words a person reaches for first, and the words the\n * peer runtimes' own docs use — all arrived at the form as a plain text box.\n * The person then typed a date into a text field and the run resumed with a\n * string where a date was declared, which nothing downstream could detect.\n *\n * Aliases rather than a stricter schema because the declaration is DATA. It is\n * written by hand and emitted by agents, and rejecting `boolean` on a spelling\n * technicality would be a worse failure than accepting it.\n */\nexport const HUMAN_FIELD_TYPE_ALIASES: Readonly<Record<string, HumanFieldType>> = {\n text: \"text\",\n string: \"text\",\n str: \"text\",\n input: \"text\",\n\n textarea: \"textarea\",\n long_text: \"textarea\",\n longtext: \"textarea\",\n \"long-text\": \"textarea\",\n multiline: \"textarea\",\n paragraph: \"textarea\",\n markdown: \"textarea\",\n\n number: \"number\",\n numeric: \"number\",\n integer: \"number\",\n int: \"number\",\n float: \"number\",\n decimal: \"number\",\n\n select: \"select\",\n enum: \"select\",\n choice: \"select\",\n choices: \"select\",\n dropdown: \"select\",\n options: \"select\",\n radio: \"select\",\n\n switch: \"switch\",\n bool: \"switch\",\n boolean: \"switch\",\n checkbox: \"switch\",\n toggle: \"switch\",\n\n date: \"date\",\n\n datetime: \"datetime\",\n \"datetime-local\": \"datetime\",\n datetimelocal: \"datetime\",\n timestamp: \"datetime\",\n\n time: \"time\",\n\n email: \"email\",\n \"e-mail\": \"email\",\n\n url: \"url\",\n uri: \"url\",\n link: \"url\",\n\n tel: \"tel\",\n phone: \"tel\",\n telephone: \"tel\",\n\n password: \"password\",\n secret: \"password\",\n};\n\n/**\n * Resolve a declared type name to a control.\n *\n * An unrecognised name becomes `text` — never a crash and never a dropped\n * field. A field the form refuses to render is a value the run will never\n * receive, which is strictly worse than rendering it as free text.\n */\nexport function humanFieldType(raw: unknown): HumanFieldType {\n if (typeof raw !== \"string\") return \"text\";\n return HUMAN_FIELD_TYPE_ALIASES[raw.trim().toLowerCase()] ?? \"text\";\n}\n\n/**\n * Normalize whatever an author wrote for a select's choices.\n *\n * Accepts the three shapes that actually turn up:\n *\n * - `[\"small\", \"large\"]` — bare strings, the shorthand `TextConfigField.choices`\n * already accepts elsewhere in this package.\n * - `[{ value: \"s\", label: \"Small\" }]` — the explicit form.\n * - `{ s: \"Small\", l: \"Large\" }` — what the config panel's `keyvalue` control\n * stores, which is how choices are authored on the `user_input` node.\n *\n * A missing `label` falls back to the value rather than rendering an empty\n * option — the old code read `o.label` off a bare string and put `undefined`\n * into both the value and the text, so a shorthand list rendered as a dropdown\n * of blank rows.\n */\nexport function humanFieldOptions(raw: unknown): HumanFieldOption[] | undefined {\n const entries: HumanFieldOption[] = [];\n\n if (Array.isArray(raw)) {\n for (const item of raw) {\n if (typeof item === \"string\" || typeof item === \"number\") {\n const value = String(item);\n if (value !== \"\") entries.push({ value, label: value });\n continue;\n }\n if (item && typeof item === \"object\") {\n const value = (item as { value?: unknown }).value;\n if (value === undefined || value === null || value === \"\") continue;\n const label = (item as { label?: unknown }).label;\n entries.push({\n value: String(value),\n label: typeof label === \"string\" && label !== \"\" ? label : String(value),\n });\n }\n }\n } else if (raw && typeof raw === \"object\") {\n for (const [value, label] of Object.entries(raw as Record<string, unknown>)) {\n if (value === \"\") continue;\n entries.push({ value, label: typeof label === \"string\" && label !== \"\" ? label : value });\n }\n }\n\n return entries.length ? entries : undefined;\n}\n\n/**\n * Normalize a `user_input` node's `fields` config into renderable fields. Falls\n * back to a single text field so even an unconfigured User Input node still\n * collects something rather than silently returning nothing.\n */\nexport function humanInputFields(config: Record<string, unknown>): HumanField[] {\n const raw = Array.isArray((config as any)?.fields) ? ((config as any).fields as any[]) : [];\n const fields: HumanField[] = raw\n .filter((f) => f && typeof f === \"object\" && typeof (f as any).key === \"string\" && (f as any).key)\n .map((f: any) => ({\n key: f.key,\n label: typeof f.label === \"string\" && f.label ? f.label : f.key,\n type: humanFieldType(f.type),\n required: !!f.required,\n placeholder: typeof f.placeholder === \"string\" ? f.placeholder : undefined,\n options: humanFieldOptions(f.options ?? f.choices),\n default: f.default,\n }));\n if (fields.length) return fields;\n const title = typeof (config as any)?.title === \"string\" && (config as any).title ? (config as any).title : \"Your answer\";\n return [{ key: \"value\", label: title, type: \"textarea\", required: true }];\n}\n\n","import { getWorkflowResolver, isResolutionFailure } from \"./capabilities\";\nimport { runFlow } from \"../runtime/run-flow\";\nimport type { NodeExecutor, RunEvent } from \"../types\";\n\n/**\n * `@fancy/subflow` — run another workflow and bring its result home.\n *\n * Core, not marketplace: it introduces no third-party dependency. It runs a\n * child graph through the very same engine, so the only thing it needs from the\n * host is where workflows live (`registerWorkflowResolver`).\n *\n * Three output modes, because both halves are genuinely useful:\n *\n * - `output` — the child's outputs arrive on `out` when it finishes.\n * - `stream` — the child's events are forwarded live on `stream` as they\n * happen, so a parent can show progress instead of a spinner.\n * - `both` — stream while running AND deliver the final outputs.\n *\n * Recursion is guarded by depth. A workflow that references itself (directly or\n * through a chain) would otherwise recurse until the stack dies, which surfaces\n * as an opaque crash rather than \"you built a loop\".\n */\n\nexport const DEFAULT_MAX_DEPTH = 8;\n\nexport type SubflowMode = \"output\" | \"stream\" | \"both\";\n\nexport function subflowMode(config: Record<string, unknown>): SubflowMode {\n const mode = config.mode;\n return mode === \"stream\" || mode === \"both\" ? mode : \"output\";\n}\n\n/** Ports follow the mode — `stream` only exists when something streams. */\nexport function subflowPorts(config: Record<string, unknown>) {\n const mode = subflowMode(config);\n const ports = [{ id: \"out\", label: \"result\" }];\n if (mode === \"stream\" || mode === \"both\") ports.unshift({ id: \"stream\", label: \"stream\" });\n return ports;\n}\n\nexport const subflowExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as any)?.config ?? {}) as Record<string, unknown>;\n const ref = String(config.workflow ?? \"\").trim();\n if (!ref) ctx.abort(\"subflow has no workflow reference configured\");\n\n const resolver = getWorkflowResolver();\n if (!resolver) {\n ctx.abort(\n \"No workflow resolver registered. Call registerWorkflowResolver() so subflow can find the workflow it references.\",\n );\n }\n\n const maxDepth = Number.isFinite(config.maxDepth) ? Number(config.maxDepth) : DEFAULT_MAX_DEPTH;\n const depth = ctx.depth ?? 0;\n if (depth + 1 > maxDepth) {\n // Name the cause. \"Maximum call stack exceeded\" tells an author nothing\n // about the workflow they wired into itself.\n ctx.abort(\n `subflow depth limit reached (${maxDepth}) at \"${ref}\" — a workflow is referencing itself, directly or through a chain.`,\n );\n }\n\n // An optional pin. A workflow another workflow depends on is an interface:\n // without a pin, someone edits the child and the parent silently runs\n // different logic while still reporting success.\n const pinned = config.version === undefined || config.version === \"\" ? undefined : Number(config.version);\n if (pinned !== undefined && !Number.isInteger(pinned)) {\n ctx.abort(`subflow \"${ref}\" has a non-integer version pin (${String(config.version)}).`);\n }\n\n const resolved = await resolver!(ref, pinned);\n\n // A mismatch names BOTH versions. Reporting it as \"not found\" would send an\n // author looking for a workflow that is sitting right there — which is why\n // the resolver can say which of the two failures it hit.\n const child = isResolutionFailure(resolved)\n ? ctx.abort(\n resolved.reason === \"version-mismatch\"\n ? (resolved.message ??\n `subflow \"${ref}\" is pinned to version ${pinned}, but the host has ${resolved.available ?? \"a different version\"}.`)\n : (resolved.message ?? `subflow could not resolve workflow \"${ref}\"`),\n )\n : resolved;\n\n if (!child) ctx.abort(`subflow could not resolve workflow \"${ref}\"`);\n\n const mode = subflowMode(config);\n const streaming = mode === \"stream\" || mode === \"both\";\n\n const forward = (event: RunEvent) => {\n if (!streaming) return;\n // Surface the child's progress on the PARENT's feed as a log line against\n // this node. Re-emitting the child's raw events would collide with the\n // parent's own node ids — a child's \"node-status\" for its `output` node is\n // not a status for anything in the parent graph.\n const detail =\n event.type === \"node-status\"\n ? `${event.nodeId} ${event.status}`\n : event.type === \"run-end\"\n ? `finished (${event.ok ? \"ok\" : \"failed\"})`\n : event.type;\n ctx.emit({\n type: \"log\",\n nodeId: ctx.node.id,\n level: \"info\",\n message: `[${ref}] ${detail}`,\n });\n };\n\n const result = await runFlow(\n child!,\n // Inherit the parent's registry, then let the graph layer its own on top.\n // The inherited half is the fix; the layered half keeps a graph that\n // deliberately hands its child extra or different executors working.\n { ...(ctx.executors ?? {}), ...((config.executors as Record<string, unknown>) ?? {}) } as never,\n forward,\n {\n initialInputs: (config.inputs as Record<string, Record<string, unknown>>) ?? {\n // With no explicit mapping, hand the parent's inputs to the child's\n // entry points — the obvious default, and it makes the simple case\n // require no configuration at all.\n __parent: ctx.inputs as Record<string, unknown>,\n },\n depth: depth + 1,\n // Push THIS node onto the identity path, so a node inside the child graph\n // cannot share an idempotency key with a same-named node in the parent —\n // or with the same child graph invoked from a different parent node.\n // Attempt and the first-attempt clock ride down unchanged: the child's\n // work happens inside this node's attempt.\n run: ctx.run?.descend(ctx.node.id),\n },\n );\n\n if (!result.ok) {\n ctx.abort(`subflow \"${ref}\" failed: ${result.error ?? \"unknown error\"}`);\n }\n\n // `stream` alone still emits a final value on `stream` so downstream nodes\n // have something to run on; `both` publishes on every declared port.\n if (mode === \"stream\") {\n return { __port: \"stream\", value: result.outputs };\n }\n if (mode === \"both\") {\n return result.outputs;\n }\n return { __port: \"out\", value: result.outputs };\n};\n","/**\n * `{{ }}` resolution — the TypeScript twin of `FancyFlow\\Nodes\\Support\\Expr`.\n *\n * ## Why this is opt-in and not wired into `runFlow`\n *\n * The PHP runtime resolves expressions inside its batteries-included executors.\n * The JS runtime never has: `runFlow` hands `node.data.config` to your executor\n * verbatim, so every host that uses `{{ }}` today already resolves it itself.\n * Turning resolution on inside `runFlow` would interpolate a second time over\n * values those hosts had already substituted — silently, and only for graphs\n * that happen to contain `{{` in their DATA.\n *\n * So this exports the semantics and changes no behaviour. Call it yourself:\n *\n * ```ts\n * const url = evaluateExpression(node.data.config.url, inputs);\n * ```\n *\n * ## The semantics are the PHP file's, deliberately\n *\n * This is not a general expression language and must not grow into one. It\n * resolves a dot-path against a context and nothing else — no arithmetic, no\n * comparisons, no calls. Hosts that want real expressions override the executor\n * (the PHP docblock points at symfony/expression-language for the same reason).\n *\n * Divergence here is a correctness bug rather than a style difference: the same\n * graph is authored once and may run on either runtime. `suites/shared/expr`\n * in `@particle-academy/fancy-conformance` is the fixture table both sides run,\n * so parity is a test result instead of a claim.\n */\n\n/** Anything a context or a resolved value can be. */\nexport type ExprValue = unknown;\n\n/** The context an expression resolves against — the executor's `inputs`. */\nexport type ExprContext = Record<string, ExprValue>;\n\n/**\n * `{{ … }}` is parsed by SCANNING, not by a regular expression.\n *\n * Two CodeQL `js/polynomial-redos` alerts (#2, #3) came out of the regex\n * version, and the second survived the obvious fix — which is the useful part.\n * Dropping the ambiguous `\\s*` around the capture killed one witness\n * (`'{{{{' + ' '.repeat(n)`) and CodeQL immediately produced another\n * (`'{{{{a'` repeated). That is not a pattern bug: a GLOBAL lazy scan for a\n * delimiter that never arrives is quadratic by construction — O(n) starts, each\n * scanning O(n) forward — and no amount of tuning the pattern removes it.\n *\n * `indexOf` has no backtracking at all. Each character is visited a bounded\n * number of times, so this is linear by construction rather than by careful\n * pattern-writing, and there is no next witness to find.\n *\n * The behaviour is deliberately identical to the regexes it replaces, including\n * the odd corner: `{{a}}{{b}}` is a WHOLE expression whose path is `a}}{{b`\n * (which resolves to null), because the old pattern was `$`-anchored and its\n * lazy capture had to grow to reach the end. The PHP twin does the same, and\n * `shared/expr` is what holds the two together.\n */\n\n/** The inner text of a template that is exactly one expression, else `null`. */\nfunction wholeExpression(trimmed: string): string | null {\n if (trimmed.length < 4) return null;\n if (!trimmed.startsWith(\"{{\") || !trimmed.endsWith(\"}}\")) return null;\n return trimmed.slice(2, -2);\n}\n\n/**\n * Replace every `{{ … }}` run, left to right, in a single pass.\n *\n * An unterminated `{{` is literal text — the same thing the regex did by simply\n * not matching, and the case an author hits constantly while typing.\n */\nfunction interpolate(template: string, resolve: (path: string) => string): string {\n let out = \"\";\n let i = 0;\n\n for (;;) {\n const open = template.indexOf(\"{{\", i);\n if (open === -1) return out + template.slice(i);\n\n const close = template.indexOf(\"}}\", open + 2);\n if (close === -1) return out + template.slice(i);\n\n out += template.slice(i, open) + resolve(template.slice(open + 2, close));\n i = close + 2;\n }\n}\n\n/**\n * Strings PHP's `Expr::truthy` treats as false.\n *\n * `\"0\"` and `\"false\"` are the ones that matter: a branch condition arriving as\n * text from a form or a JSON body would otherwise be truthy for every non-empty\n * string, and `\"false\"` taking the true branch is the kind of bug that looks\n * like the engine is broken.\n */\nconst FALSY_STRINGS = new Set([\"\", \"0\", \"false\", \"no\", \"off\", \"null\"]);\n\n/**\n * What a resolution attempt ANSWERS — did the path resolve, and to what.\n *\n * `resolvePath` cannot express this, and that is the defect it exists to fix:\n * it returns `null` both for \"this path does not exist\" and for \"this path\n * exists and holds null\". One value standing for two states.\n *\n * At the interpolation layer the collapse is worse, because `null` stringifies\n * to `\"\"`. A consumer put it exactly:\n *\n * > \"An unresolvable path yields `''`, so a wrong field is indistinguishable\n * > from an empty one at runtime.\"\n *\n * A misspelled field renders as an empty string, which looks precisely like a\n * field that is legitimately empty. The graph runs, the node succeeds, and the\n * output is quietly missing a value nobody is told about — worst on\n * LLM-authored graphs, where the field name was guessed in the first place.\n *\n * Same shape as the four `??` collapses fixed across all four runtimes on\n * 2026-08-26 (absent vs null), one layer up: **presence is the only correct\n * test, and a return value that cannot express presence cannot be tested for\n * it.** Hence a second return channel rather than a cleverer sentinel — every\n * sentinel is a legal value for somebody.\n */\nexport interface Resolution {\n /** Whether the path resolved at all. `false` means it does not exist. */\n resolved: boolean;\n /** The value, when `resolved`. `null` when not — do not read it blind. */\n value: ExprValue;\n}\n\n/** Thrown by the `\"throw\"` policy when a path does not resolve. */\nexport class UnresolvedPathError extends Error {\n constructor(readonly path: string) {\n super(\n `Expression path \"${path}\" did not resolve. ` +\n `Under the \"throw\" policy an unresolvable path is an error rather than an empty string.`,\n );\n this.name = \"UnresolvedPathError\";\n }\n}\n\n/**\n * What evaluation does with a path that does not resolve.\n *\n * - `\"empty\"` — today's behaviour, and the DEFAULT. Interpolates to `\"\"`; a\n * whole expression yields `null`. Unchanged so that widening this API breaks\n * nobody: 40 call sites across the runtimes assume it.\n * - `\"keep\"` — leave the `{{ … }}` text in place. The failure becomes VISIBLE\n * in the output without stopping the run, which is what you want for\n * human-reviewed content: a rendered `{{ in.recipient_naem }}` is self-\n * diagnosing in a way an absence never is.\n * - `\"throw\"` — refuse. For hosts that would rather fail a run than deliver a\n * silently incomplete result.\n *\n * Opt-in before default at the request of the consumer who reported it — the\n * host with the most LLM-authored graphs, and so both the biggest beneficiary\n * and the right place for it to break first if it is going to.\n */\nexport type UnresolvedPolicy = \"empty\" | \"keep\" | \"throw\";\n\n/** Options for {@link evaluateExpression} / {@link evaluateConfig}. */\nexport interface EvaluateOptions {\n /** What to do with a path that does not resolve. Default `\"empty\"`. */\n onUnresolved?: UnresolvedPolicy;\n}\n\n/**\n * Resolve a dot-path, reporting WHETHER it resolved.\n *\n * The same walk as `resolvePath` — deliberately, so the two can never disagree\n * about what resolves; `resolvePath` is defined in terms of this one below.\n *\n * A note on JS having two absent values: a key present with the value\n * `undefined` reports `resolved: false`, matching `resolvePath`'s long-standing\n * behaviour. It cannot arise from graph data (JSON has no `undefined`), and\n * changing it would make the two functions disagree for no reachable gain.\n */\nexport function tryResolvePath(path: string, context: ExprContext): Resolution {\n const unresolved: Resolution = { resolved: false, value: null };\n\n const trimmed = path.trim();\n if (trimmed === \"\") return unresolved;\n\n const segments = trimmed.split(\".\");\n let cursor: ExprValue;\n\n const head = segments[0];\n if (head === \"$json\" || head === \"$input\") {\n cursor = context !== null && typeof context === \"object\" && \"in\" in context ? context.in : context;\n segments.shift();\n } else {\n cursor = context;\n }\n\n for (const segment of segments) {\n if (cursor === null || cursor === undefined) return unresolved;\n if (typeof cursor !== \"object\") return unresolved;\n // Arrays are indexed by their numeric keys, matching PHP's list access.\n const next = (cursor as Record<string, ExprValue>)[segment];\n if (next === undefined) return unresolved;\n cursor = next;\n }\n\n return { resolved: true, value: cursor === undefined ? null : cursor };\n}\n\n/**\n * Resolve a dot-path against the context, honouring the `$json` / `$input`\n * alias.\n *\n * Both aliases point at the `in` port value when the context has one, and at\n * the whole context otherwise — the same fallback the PHP does, which is what\n * makes `{{ $json.x }}` work on a trigger node that has no upstream input.\n *\n * A path that does not resolve returns `null`, never `undefined`: PHP has one\n * absent value and JS has two, and letting the difference leak would make the\n * two runtimes disagree about `{{ missing }}` for no useful reason.\n */\nexport function resolvePath(path: string, context: ExprContext): ExprValue {\n // Defined in terms of `tryResolvePath` rather than repeating the walk. Two\n // copies of a traversal agree right up until someone edits one of them, and\n // nothing anywhere reports that -- the same reason the shared conformance\n // tables exist instead of hand-copied fixture rows.\n return tryResolvePath(path, context).value;\n}\n\n/**\n * Evaluate a template against a context.\n *\n * A string that is EXACTLY one expression returns the resolved value with its\n * type intact — `{{ $json.count }}` gives you a number, not `\"3\"`. Anything\n * else interpolates each run as text. That distinction is load-bearing: it is\n * what lets a config field carry either a value or a sentence.\n *\n * Non-string templates pass through untouched, so this is safe to map over a\n * whole config object.\n */\nexport function evaluateExpression(\n template: ExprValue,\n context: ExprContext,\n options: EvaluateOptions = {},\n): ExprValue {\n if (typeof template !== \"string\") return template;\n\n const policy = options.onUnresolved ?? \"empty\";\n\n const whole = wholeExpression(template.trim());\n if (whole !== null) {\n const r = tryResolvePath(whole, context);\n if (r.resolved) return r.value;\n\n // The whole-expression branch returns `null` under `\"empty\"`, not `\"\"` --\n // that is what it has always done, and the asymmetry is deliberate: this\n // branch preserves TYPE, so its absent value is the typed one.\n if (policy === \"throw\") throw new UnresolvedPathError(whole);\n return policy === \"keep\" ? template : null;\n }\n\n return interpolate(template, (path) => {\n const r = tryResolvePath(path, context);\n if (r.resolved) return stringify(r.value);\n if (policy === \"throw\") throw new UnresolvedPathError(path);\n return policy === \"keep\" ? `{{${path}}}` : \"\";\n });\n}\n\n/**\n * Truthiness for branch / switch decisions.\n *\n * Mirrors PHP's rules rather than JavaScript's, because the graph is authored\n * once and may run on either side. The two disagree in exactly the places a\n * workflow hits: `\"0\"` and `\"false\"` are truthy in JS and falsy here, and an\n * empty array is truthy in JS and falsy here.\n */\nexport function truthy(value: ExprValue): boolean {\n if (typeof value === \"boolean\") return value;\n if (value === null || value === undefined) return false;\n if (typeof value === \"string\") return !FALSY_STRINGS.has(value.trim().toLowerCase());\n if (Array.isArray(value)) return value.length > 0;\n if (typeof value === \"number\") return value !== 0;\n return Boolean(value);\n}\n\n/** Coerce a value to text the way interpolation does. */\nexport function text(value: ExprValue): string {\n return stringify(value);\n}\n\nfunction stringify(value: ExprValue): string {\n if (typeof value === \"string\") return value;\n if (typeof value === \"boolean\") return value ? \"true\" : \"false\";\n if (value === null || value === undefined) return \"\";\n if (typeof value === \"number\" || typeof value === \"bigint\") return String(value);\n try {\n return JSON.stringify(value) ?? \"\";\n } catch {\n return \"\";\n }\n}\n\n/**\n * Resolve every string in a config object, one level of nesting at a time.\n *\n * The convenience most hosts actually want, and the shape their hand-rolled\n * version usually takes. Opt-in like the rest of this module.\n */\nexport function evaluateConfig<T extends Record<string, ExprValue>>(\n config: T,\n context: ExprContext,\n options: EvaluateOptions = {},\n): T {\n const out: Record<string, ExprValue> = {};\n for (const [key, value] of Object.entries(config)) {\n out[key] = Array.isArray(value)\n ? value.map((v) => evaluateExpression(v, context, options))\n : value !== null && typeof value === \"object\"\n ? evaluateConfig(value as Record<string, ExprValue>, context, options)\n : evaluateExpression(value, context, options);\n }\n return out as T;\n}\n","import { evaluateExpression, truthy, text } from \"../expressions/expr\";\nimport type { NodeExecutor } from \"../types\";\n\n/**\n * Default executors for the four PURE-LOGIC builtins.\n *\n * ## Why these four ship one and `api_request` does not\n *\n * The kit's rule is that a kind ships schema + UI and the HOST wires the\n * executor, so it controls where memory, network and model calls actually go.\n * That reasoning is exactly right for `api_request`, `llm_call`, `memory_store`\n * — anything that touches the outside world, where a default would be a\n * decision made on the host's behalf about its own infrastructure.\n *\n * It is much weaker for `transform`, which does no I/O at all. `branch`,\n * `transform`, `merge` and `for_each` are pure functions of their inputs and\n * their config: there is exactly one correct answer and no infrastructure to\n * choose. Leaving them out meant every host reimplemented the same four, from\n * a schema, with no reference implementation to check against — and a consumer\n * asked whether that was deliberate (#13), which is a fair question to have to\n * ask.\n *\n * Host executors still take precedence: `pickExecutor` consults the host\n * registry first and falls back to the kind's own. Anyone who already wrote\n * these keeps theirs, unchanged.\n *\n * ## They implement the TypeScript schema, which is wider than the twin's\n *\n * `branch` and `transform` each have TWO authoring paths: a builder\n * (`conditions[]` / `fields[]`), which is what the editor produces by default,\n * and a raw-expression escape hatch (`condition` / `expression`). The Python\n * twin implements only the escape hatches. See the note in `docs/` — a graph\n * drawn the default way and run there routes or reshapes wrongly, silently.\n * These implement BOTH, so the TypeScript side is the complete one.\n */\n\ntype Config = Record<string, unknown>;\n\nfunction configOf(node: unknown): Config {\n return (((node as { data?: { config?: Config } })?.data?.config) ?? {}) as Config;\n}\n\n/** The expression context every one of these resolves against. */\nfunction contextOf(inputs: Record<string, unknown>): Record<string, unknown> {\n return inputs as Record<string, unknown>;\n}\n\n/** `{{ }}`-aware resolve. A non-string config value is already a value. */\nfunction resolve(value: unknown, inputs: Record<string, unknown>): unknown {\n if (typeof value !== \"string\") return value;\n return evaluateExpression(value, contextOf(inputs) as never);\n}\n\n/**\n * One row of the `conditions` repeater.\n *\n * `left` is an expression; `right` is plain text in the schema but is resolved\n * too, because an author who types `{{ $json.threshold }}` there means it.\n */\nfunction conditionHolds(row: Config, inputs: Record<string, unknown>): boolean {\n const left = resolve(row.left, inputs);\n const right = resolve(row.right, inputs);\n const operator = typeof row.operator === \"string\" ? row.operator : \"eq\";\n\n const asText = (v: unknown) => text(v as never);\n const asNumber = (v: unknown) => {\n const n = typeof v === \"number\" ? v : Number(asText(v));\n return Number.isFinite(n) ? n : NaN;\n };\n // A number comparison against something unparseable is FALSE rather than a\n // throw: an author comparing a missing field to 10 wants the branch not to\n // take, not the run to die.\n const numeric = (fn: (a: number, b: number) => boolean) => {\n const a = asNumber(left);\n const b = asNumber(right);\n return Number.isFinite(a) && Number.isFinite(b) ? fn(a, b) : false;\n };\n const isEmpty = (v: unknown) =>\n v === null\n || v === undefined\n || v === \"\"\n || (Array.isArray(v) && v.length === 0)\n || (typeof v === \"object\" && !Array.isArray(v) && Object.keys(v as object).length === 0);\n\n switch (operator) {\n // Compared as TEXT, deliberately. `right` is a text field in the schema, so\n // `status == \"2\"` must match the number 2 an upstream node produced —\n // strict equality there would fail on a difference the author cannot see.\n case \"eq\": return asText(left) === asText(right);\n case \"neq\": return asText(left) !== asText(right);\n case \"contains\": return asText(left).includes(asText(right));\n case \"not_contains\": return !asText(left).includes(asText(right));\n case \"gt\": return numeric((a, b) => a > b);\n case \"gte\": return numeric((a, b) => a >= b);\n case \"lt\": return numeric((a, b) => a < b);\n case \"lte\": return numeric((a, b) => a <= b);\n case \"truthy\": return truthy(left as never);\n case \"falsy\": return !truthy(left as never);\n case \"empty\": return isEmpty(left);\n case \"not_empty\": return !isEmpty(left);\n default:\n // An operator the schema does not declare is a config error, not a\n // silent false — false would look exactly like a condition that did not\n // match, which is the answer an author would then try to debug.\n return false;\n }\n}\n\n/**\n * `branch` — two ports, exactly one taken.\n *\n * The raw `condition` WINS when set, because its own schema description says so\n * (\"Overrides the conditions above when set\"). The input passes through\n * unchanged down whichever side is taken and the other edge stays dead.\n */\nexport const branchExecutor: NodeExecutor = (ctx) => {\n const config = configOf(ctx.node);\n const inputs = ctx.inputs as Record<string, unknown>;\n\n let taken: boolean;\n\n const raw = config.condition;\n if (typeof raw === \"string\" && raw.trim() !== \"\") {\n taken = truthy(resolve(raw, inputs) as never);\n } else {\n const rows = Array.isArray(config.conditions) ? (config.conditions as Config[]) : [];\n // No conditions at all is FALSE, not true. An empty `all` is vacuously\n // true in logic, and that would send an unconfigured branch down the\n // success path — the one place a half-built graph should not go.\n if (rows.length === 0) {\n taken = false;\n } else {\n const results = rows.map((row) => conditionHolds(row, inputs));\n taken = config.match === \"any\" ? results.some(Boolean) : results.every(Boolean);\n }\n }\n\n return { __port: taken ? \"true\" : \"false\", value: ctx.inputs.in ?? ctx.inputs };\n};\n\n/**\n * `transform` — reshape in place. One `out` port, always active.\n *\n * `mode` decides which authoring path is read, defaulting to `fields` exactly\n * as the schema does.\n */\nexport const transformExecutor: NodeExecutor = (ctx) => {\n const config = configOf(ctx.node);\n const inputs = ctx.inputs as Record<string, unknown>;\n const passthrough = ctx.inputs.in ?? ctx.inputs;\n\n if (config.mode === \"expression\") {\n const expression = config.expression;\n if (typeof expression !== \"string\" || expression.trim() === \"\") return passthrough;\n return resolve(expression, inputs);\n }\n\n const rows = Array.isArray(config.fields) ? (config.fields as Config[]) : [];\n // Nothing configured passes the input through untouched rather than\n // returning `{}`. A half-built transform that silently empties the payload\n // breaks every node downstream of it with no clue where the data went.\n if (rows.length === 0) return passthrough;\n\n const out: Record<string, unknown> = {};\n let wrote = false;\n for (const row of rows) {\n const key = typeof row.key === \"string\" ? row.key.trim() : \"\";\n if (key === \"\") continue;\n out[key] = resolve(row.value, inputs);\n wrote = true;\n }\n return wrote ? out : passthrough;\n};\n\n/**\n * `merge` — several inputs, one value.\n *\n * `merge` combines into one object: a plain object is spread in by key,\n * anything else is keyed by its PORT id. `concat` flattens into one list.\n *\n * `null`/`undefined` inputs are skipped, and dead edges never reach the\n * executor at all — so a merge downstream of a branch receives only the side\n * that actually ran, which is what makes it a merge point rather than a join.\n */\nexport const mergeExecutor: NodeExecutor = (ctx) => {\n const entries = Object.entries(ctx.inputs as Record<string, unknown>);\n\n if (configOf(ctx.node).mode === \"concat\") {\n const out: unknown[] = [];\n for (const [, value] of entries) {\n if (value === null || value === undefined) continue;\n if (Array.isArray(value)) out.push(...value);\n else out.push(value);\n }\n return out;\n }\n\n const merged: Record<string, unknown> = {};\n for (const [port, value] of entries) {\n if (value === null || value === undefined) continue;\n if (typeof value === \"object\" && !Array.isArray(value)) Object.assign(merged, value);\n else merged[port] = value;\n }\n return merged;\n};\n\n/**\n * `for_each` — fan-out as DATA, not as jobs.\n *\n * Publishes the resolved collection and its size. It does NOT spawn one job per\n * item, and that is deliberate rather than unfinished: on a durable run a\n * `for_each` over 10,000 rows is one node, one claim, one checkpoint — not\n * 10,000. A host that wants true per-item iteration overrides this, which is\n * exactly what the executor seam is for.\n *\n * Matches the Python twin, including `concurrency` being carried for a host\n * that does iterate rather than acted on here.\n */\nexport const forEachExecutor: NodeExecutor = (ctx) => {\n const source = resolve(configOf(ctx.node).source, ctx.inputs as Record<string, unknown>);\n\n let items: unknown[];\n if (Array.isArray(source)) items = source;\n else if (source === null || source === undefined) items = [];\n else if (typeof source === \"object\") items = Object.values(source as object);\n else items = [source];\n\n return { items, count: items.length };\n};\n","import type { NodeExecutor } from \"../types\";\nimport type { TranscriptWaitResult } from \"../runtime/terminal-transcript\";\n\n/**\n * The three terminal primitives.\n *\n * They are core rather than marketplace for the same reason `subflow` is: they\n * introduce no third-party dependency. The PTY lives behind\n * `registerTerminalHost`, so this file imports nothing that a browser build\n * would choke on.\n *\n * ## Why three, and not one\n *\n * A terminal is two different things depending on what is running in it, and\n * one node cannot serve both:\n *\n * - **A shell** answers a question and finishes, so the useful unit is\n * \"run this, tell me what it said and whether it worked\" — `terminal_run`.\n * - **A TUI** (Claude Code, Codex, a REPL, an installer asking a question)\n * never finishes. There is no exit code to wait for and no prompt to return\n * to; there is only text going in and text coming out. That is\n * `terminal_send` + `terminal_await`, and it is the pair that makes an agent\n * TUI drivable at all.\n *\n * Collapsing them into one node would mean guessing which mode the author\n * meant, and guessing wrong on a TUI means hanging until a timeout.\n */\n\nconst DEFAULT_TIMEOUT_MS = 120_000;\n\n/** Enter, in a PTY, is a carriage return. */\nconst ENTER = \"\\r\";\n\nfunction configOf(node: unknown): Record<string, unknown> {\n return (((node as { data?: { config?: Record<string, unknown> } })?.data?.config) ?? {}) as Record<\n string,\n unknown\n >;\n}\n\nfunction text(config: Record<string, unknown>, key: string): string {\n const value = config[key];\n return typeof value === \"string\" ? value : \"\";\n}\n\nfunction millis(config: Record<string, unknown>, key: string, fallback: number): number {\n const value = Number(config[key]);\n return Number.isFinite(value) && value >= 0 ? value : fallback;\n}\n\n/**\n * The marker `terminal_run` appends so it can tell when a command finished and\n * what it returned.\n *\n * A persistent shell has no completion channel — output just stops arriving,\n * and \"stopped arriving\" is indistinguishable from \"still thinking\". So the\n * command is followed by an echo of its own exit status, and THAT is what the\n * node waits for.\n *\n * The nonce matters: without it, a command whose own output happened to contain\n * the marker would end the wait early, and a run that left a stale marker in\n * the buffer would satisfy the NEXT command instantly. One per execution.\n */\nexport function exitMarker(nonce: string): { token: string; pattern: RegExp } {\n const token = `__fancy_flow_exit_${nonce}__`;\n return {\n token,\n // The expanded status is required to be digits. The shell ECHOES the typed\n // command back first, and that echo contains the marker with `$?`\n // unexpanded — so requiring digits is what stops the node matching its own\n // command line and reporting success before anything has run.\n pattern: new RegExp(`${token}:(\\\\d+)`),\n };\n}\n\nlet counter = 0;\n\nfunction newNonce(): string {\n counter += 1;\n return `${Date.now().toString(36)}${counter.toString(36)}${Math.random().toString(36).slice(2, 8)}`;\n}\n\n/**\n * Drop every line carrying the marker.\n *\n * Two of them exist in a normal run — the shell's echo of the command that was\n * typed, and the marker line itself — and neither is output the author asked\n * for. Filtering by line rather than slicing by index survives an echo that is\n * wrapped, disabled, or reordered, none of which is under our control.\n */\nfunction withoutMarker(output: string, token: string): string {\n return output\n .split(\"\\n\")\n .filter((line) => !line.includes(token))\n .join(\"\\n\")\n .trim();\n}\n\ntype Ctx = Parameters<NodeExecutor>[0];\n\n/**\n * Abort, in a shape the compiler believes.\n *\n * `ctx.abort` is declared `=> never`, but TypeScript only narrows control flow\n * through a never-returning call when the callee is a plain function name — not\n * a mutable property on a parameter. So calling `ctx.abort` directly left every\n * later line thinking the run might have continued, and the code had to be\n * written as if a value could still be `undefined` after it had been rejected.\n *\n * That is not a cosmetic complaint: the workaround is a non-null assertion, and\n * a `!` on a line that \"cannot be reached\" is indistinguishable from a `!` on a\n * line that can.\n */\nfunction fail(ctx: Ctx, message: string): never {\n ctx.abort(message);\n // Unreachable — `abort` throws. Present so this function's own return type is\n // honest without depending on the narrowing that is missing above.\n throw new Error(message);\n}\n\n/** Shared: resolve the lane's terminal, or abort naming the real problem. */\nfunction requireTerminal(ctx: Ctx): NonNullable<Ctx[\"terminal\"]> {\n if (!ctx.terminal) {\n fail(\n ctx,\n `\"${String(ctx.node.data?.label ?? ctx.node.id)}\" is a terminal node but is not inside a terminal lane. `\n + \"Drag it into one — a terminal node outside a lane has no session to talk to, and opening a private \"\n + \"shell for it would defeat the point of the lane.\",\n );\n }\n return ctx.terminal;\n}\n\n/**\n * The pattern a `terminal_await` waits for.\n *\n * Plain text is the default and is ESCAPED, so a prompt like `? (y/n)` matches\n * itself instead of being read as a regex and either failing to compile or —\n * worse — matching something else entirely while looking like it works.\n *\n * `g` and `y` are stripped from author-supplied flags. Both make a regex carry\n * `lastIndex` between calls, so the same pattern would resume part-way through\n * a buffer it had never read, and a wait would miss a match sitting in plain\n * view. The transcript resets `lastIndex` too; this is the belt to that\n * braces, because the cost of being wrong is a hang.\n */\nfunction compilePattern(ctx: Ctx, raw: string, config: Record<string, unknown>): RegExp {\n const flags = typeof config.flags === \"string\" ? config.flags.replace(/[gy]/g, \"\") : \"\";\n try {\n return config.mode === \"regex\"\n ? new RegExp(raw, flags)\n : new RegExp(raw.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), flags);\n } catch (e) {\n // Named as an INVALID PATTERN. A bad regex thrown raw reads as a crash in\n // the engine rather than as a typo in one node's config.\n return fail(ctx, `terminal_await has an invalid regex: ${e instanceof Error ? e.message : String(e)}`);\n }\n}\n\n/**\n * `terminal_run` — send a command, wait for it to finish, report its exit code.\n *\n * Shell-only, and it says so on the node: a TUI never returns to a prompt, so\n * there is nothing for the marker to ride on. Use send + await there.\n */\nexport const terminalRunExecutor: NodeExecutor = async (ctx) => {\n const config = configOf(ctx.node);\n const command = text(config, \"command\").trim();\n if (!command) fail(ctx, \"terminal_run has no command configured\");\n\n const terminal = requireTerminal(ctx);\n const session = await terminal.session();\n const transcript = await terminal.transcript();\n\n const { token, pattern } = exitMarker(newNonce());\n const timeoutMs = millis(config, \"timeoutMs\", DEFAULT_TIMEOUT_MS);\n\n // Everything the shell said before this command is somebody else's output.\n // Carrying it into this node's result would attribute the previous command's\n // text — and, worse, let a marker-shaped string from earlier satisfy the wait.\n transcript.clear();\n\n await session.write(`${command}; printf '${token}:%s\\\\n' \"$?\"${ENTER}`);\n\n const result = await transcript.waitFor(pattern, { timeoutMs, exited: session.exited });\n\n if (result.status === \"exited\") {\n fail(\n ctx,\n `The terminal exited (code ${result.exitCode}${result.signal ? `, signal ${result.signal}` : \"\"}) while `\n + `running \"${command}\". The lane's session is gone, so every later node in this lane would fail too.`,\n );\n }\n\n if (result.status === \"timeout\") {\n fail(\n ctx,\n `\"${command}\" did not finish within ${timeoutMs}ms. Raise the node's timeout if it is genuinely slow — `\n + \"but a command that waits for input never finishes at all, and needs terminal_send + terminal_await.\",\n );\n }\n\n const exitCode = Number(result.match[1]);\n const output = withoutMarker(result.text, token);\n\n const failOnNonZero = config.failOnNonZero !== false;\n if (failOnNonZero && exitCode !== 0) {\n // Aborting is the default because the alternative is the failure this whole\n // estate keeps finding: a step that failed, a run that reports success, and\n // nothing anywhere that says the two disagree.\n ctx.abort(`\"${command}\" exited ${exitCode}.\\n${output}`);\n }\n\n return { output, exitCode, command };\n};\n\n/**\n * `terminal_send` — type at the process and move on.\n *\n * The node that makes a TUI usable. It does NOT wait, deliberately: what\n * counts as an answer is the author's decision, not ours, and pairing every\n * send with a hardcoded wait would make the common case (send, then await a\n * specific prompt) impossible to express.\n */\nexport const terminalSendExecutor: NodeExecutor = async (ctx) => {\n const config = configOf(ctx.node);\n const terminal = requireTerminal(ctx);\n const session = await terminal.session();\n\n const body = text(config, \"text\");\n // `submit !== false` — a send that does not press Enter leaves the text\n // sitting on the process's input line, which looks exactly like the process\n // ignoring it.\n const submit = config.submit !== false;\n\n if (config.clearFirst === true) {\n (await terminal.transcript()).clear();\n }\n\n await session.write(submit ? `${body}${ENTER}` : body);\n\n return { sent: body, submitted: submit };\n};\n\n/**\n * `terminal_await` — wait for the process to say something.\n *\n * The other half of driving a TUI. Without it a graph can type at Claude Code\n * and never learn that it has answered, so every downstream node runs against\n * whatever was on screen when the run started.\n *\n * Three ways it can end and all three are reported distinctly, because\n * collapsing them is how a wrong diagnosis gets shipped: a match, a timeout,\n * and the process EXITING — which without its own branch reads as \"timed out\",\n * sending whoever debugs it to lengthen a timeout on a process that is not\n * running.\n */\nexport const terminalAwaitExecutor: NodeExecutor = async (ctx) => {\n const config = configOf(ctx.node);\n const terminal = requireTerminal(ctx);\n const session = await terminal.session();\n const transcript = await terminal.transcript();\n\n const raw = text(config, \"pattern\").trim();\n if (!raw) fail(ctx, \"terminal_await has no pattern configured — there is nothing for it to wait for\");\n\n const pattern = compilePattern(ctx, raw, config);\n\n const timeoutMs = millis(config, \"timeoutMs\", DEFAULT_TIMEOUT_MS);\n const result: TranscriptWaitResult = await transcript.waitFor(pattern, {\n timeoutMs,\n exited: session.exited,\n });\n\n if (result.status === \"exited\") {\n fail(\n ctx,\n `The terminal exited (code ${result.exitCode}${result.signal ? `, signal ${result.signal}` : \"\"}) while `\n + `waiting for ${JSON.stringify(raw)}. It never appeared, and the lane's session is gone.`,\n );\n }\n\n if (result.status === \"timeout\") {\n // The default is to FAIL. An await that shrugs after a timeout lets the\n // next node type at a process that never became ready, and the run reports\n // success — so continuing has to be something the author asked for.\n if (config.onTimeout === \"continue\") {\n ctx.emit({\n type: \"log\",\n nodeId: ctx.node.id,\n level: \"warn\",\n message: `terminal_await: ${JSON.stringify(raw)} did not appear within ${timeoutMs}ms; continuing as configured.`,\n });\n return { matched: false, output: result.text, groups: [] };\n }\n\n fail(\n ctx,\n `${JSON.stringify(raw)} did not appear within ${timeoutMs}ms. Last output:\\n${result.text.slice(-2000)}`,\n );\n }\n\n return {\n matched: true,\n output: result.text,\n matchedText: result.match[0],\n // Capture groups are the reason to use regex mode at all — a prompt that\n // reports a session id or a file path is only useful if the value comes out.\n groups: result.match.slice(1),\n };\n};\n","import { registerNodeKind } from \"./registry\";\nimport { humanFieldType, type HumanFieldType } from \"../components/FlowEditor/human-fields\";\nimport { llmRouterExecutor } from \"./llm-router\";\nimport { subflowExecutor, subflowPorts, DEFAULT_MAX_DEPTH } from \"./subflow\";\nimport { branchExecutor, forEachExecutor, mergeExecutor, transformExecutor } from \"./logic\";\nimport { terminalAwaitExecutor, terminalRunExecutor, terminalSendExecutor } from \"./terminal-nodes\";\nimport type { PortDescriptor } from \"../types\";\nimport type { ConfigField, NodeKindDefinition } from \"./types\";\n\n/**\n * Built-in agentic node kit. Every kind ships with schema + UI but\n * NO executor — host apps wire executors per kind so they control where\n * memory, data, network, and AI calls actually go.\n */\n\n/**\n * What each `user_input` control actually resolves to, in the vocabulary\n * `OutputField.type` uses.\n *\n * Date / time controls are strings deliberately — the form resolves the input's\n * `value`, which is an ISO-ish string, not a `Date`. Claiming otherwise here\n * would make the picker lie in the other direction.\n */\nconst HUMAN_FIELD_OUTPUT_TYPE: Record<HumanFieldType, \"string\" | \"number\" | \"boolean\"> = {\n text: \"string\",\n textarea: \"string\",\n select: \"string\",\n date: \"string\",\n datetime: \"string\",\n time: \"string\",\n email: \"string\",\n url: \"string\",\n tel: \"string\",\n password: \"string\",\n number: \"number\",\n switch: \"boolean\",\n};\n\n/**\n * Ports for `switch_case`, derived from its `cases` map (match value → port).\n *\n * Several match values may route to the same port, so ports are de-duplicated\n * and labelled with every value that reaches them (\"a|c\"). `default` is always\n * present — unmatched input has to land somewhere.\n */\nfunction casePorts(cases: unknown): PortDescriptor[] {\n const byPort = new Map<string, string[]>();\n if (cases && typeof cases === \"object\" && !Array.isArray(cases)) {\n for (const [match, port] of Object.entries(cases as Record<string, unknown>)) {\n if (typeof port !== \"string\" || port === \"\" || port === \"default\") continue;\n const matches = byPort.get(port) ?? [];\n matches.push(match);\n byPort.set(port, matches);\n }\n }\n const ports: PortDescriptor[] = [...byPort].map(([id, matches]) => ({\n id,\n label: matches.join(\"|\"),\n }));\n return [...ports, { id: \"default\", label: \"default\" }];\n}\n\n/**\n * Ports for `llm_branch`, derived from its `routes` list. Blank and duplicate\n * port names are dropped so a half-typed route can't collide with a real one.\n */\nfunction routePorts(routes: unknown, fallback?: unknown): PortDescriptor[] {\n const ports: PortDescriptor[] = [];\n const seen = new Set<string>();\n if (Array.isArray(routes)) {\n for (const route of routes) {\n const id = (route as any)?.port;\n if (typeof id !== \"string\" || id.trim() === \"\" || seen.has(id)) continue;\n seen.add(id);\n ports.push({ id, label: id });\n }\n }\n if (fallback !== false && !seen.has(\"fallback\")) {\n ports.push({ id: \"fallback\", label: \"fallback\" });\n }\n if (ports.length === 0) ports.push({ id: \"out\" });\n return ports;\n}\n\nconst HTTP_METHODS: ConfigField[] = [\n { type: \"select\", key: \"method\", label: \"Method\", options: [\n { value: \"GET\", label: \"GET\" },\n { value: \"POST\", label: \"POST\" },\n { value: \"PUT\", label: \"PUT\" },\n { value: \"PATCH\", label: \"PATCH\" },\n { value: \"DELETE\", label: \"DELETE\" },\n ], default: \"GET\", required: true },\n];\n\nconst KINDS: NodeKindDefinition[] = [\n // ───────────── Triggers ─────────────\n {\n name: \"@particle-academy/manual_trigger\",\n // Returns the raw inputs MAP, not the `in` port -- flat at an entry\n // point, port-keyed the moment the node has an inbound edge.\n emits: \"input-map-merged\",\n aliases: [\"manual_trigger\", \"@fancy/manual_trigger\"],\n category: \"trigger\",\n label: \"Manual\",\n description: \"Entry point fired when the user clicks Run.\",\n icon: \"⚡\",\n inputs: [],\n outputs: [{ id: \"out\" }],\n },\n {\n name: \"@particle-academy/webhook_trigger\",\n aliases: [\"webhook_trigger\", \"@fancy/webhook_trigger\"],\n category: \"trigger\",\n label: \"Webhook\",\n description: \"Triggered by an inbound HTTP request to a host-provided URL.\",\n icon: \"📡\",\n inputs: [],\n outputs: [{ id: \"out\", label: \"payload\" }],\n configSchema: [\n { type: \"text\", key: \"path\", label: \"Path\", placeholder: \"/hooks/my-flow\", required: true },\n { type: \"select\", key: \"method\", label: \"Method\", options: [\n { value: \"POST\", label: \"POST\" }, { value: \"GET\", label: \"GET\" },\n ], default: \"POST\" },\n { type: \"credential\", key: \"secret\", label: \"Verifying secret\", credentialType: \"webhook_secret\" },\n ],\n },\n {\n name: \"@particle-academy/schedule_trigger\",\n outputShape: [\n { path: \"cron\", type: \"string\" as const, description: \"The cron expression that fired.\" },\n { path: \"timezone\", type: \"string\" as const, description: \"The timezone it was evaluated in.\" },\n ],\n // Merges $ctx->inputs ITSELF beside cron/timezone -- the MAP, whose\n // shape depends on position, not each port's payload the way `merge` does.\n emits: \"input-map-merged\",\n aliases: [\"schedule_trigger\", \"@fancy/schedule_trigger\"],\n category: \"trigger\",\n label: \"Schedule\",\n description: \"Fires on a cron schedule (host-implemented).\",\n icon: \"⏱\",\n inputs: [],\n outputs: [{ id: \"out\" }],\n configSchema: [\n { type: \"text\", key: \"cron\", label: \"Cron\", placeholder: \"*/5 * * * *\", required: true,\n description: \"Standard 5-field cron expression.\" },\n { type: \"text\", key: \"timezone\", label: \"Timezone\", placeholder: \"UTC\", default: \"UTC\" },\n ],\n },\n {\n name: \"@particle-academy/user_input\",\n // The keys an author declared on THIS node — the case a static list cannot\n // express, and the one issue #5 named.\n //\n // The TYPE comes from the same normalizer the form renders with, so the\n // variable picker agrees with what the run actually resolves. It used to say\n // `string` for every field, which was wrong the moment a field was a number\n // or a switch — the picker told an author `{{ $json.age }}` was text while\n // the form handed the next node a number.\n outputShape: (config: { fields?: Array<{ key?: string; label?: string; type?: unknown }> }) =>\n (config.fields ?? [])\n .filter((f) => typeof f.key === \"string\" && f.key !== \"\")\n .map((f) => ({\n path: f.key as string,\n type: HUMAN_FIELD_OUTPUT_TYPE[humanFieldType(f.type)],\n description: f.label,\n })),\n aliases: [\"user_input\", \"@fancy/user_input\"],\n pausesForHuman: \"input\",\n category: \"human\",\n label: \"User Input\",\n description: \"Pause the flow until the user submits the configured form.\",\n icon: \"✎\",\n inputs: [{ id: \"in\" }],\n outputs: [{ id: \"out\", label: \"values\" }],\n configSchema: [\n { type: \"text\", key: \"title\", label: \"Form title\", default: \"Need your input\" },\n {\n type: \"repeater\",\n key: \"fields\",\n label: \"Fields\",\n description: \"The form the run pauses on.\",\n titleKey: \"label\",\n addLabel: \"Add field\",\n minItems: 1,\n fields: [\n { type: \"text\", key: \"key\", label: \"Key\", required: true, placeholder: \"answer\" },\n { type: \"text\", key: \"label\", label: \"Label\", required: true, placeholder: \"Your answer\" },\n {\n type: \"select\", key: \"type\", label: \"Type\", default: \"text\",\n // Every control `HumanPrompt` can render. A type the form supports\n // but the panel cannot select is reachable only by hand-editing the\n // workflow JSON — which is the audience this panel exists for.\n options: [\n { value: \"text\", label: \"Text\" },\n { value: \"textarea\", label: \"Long text\" },\n { value: \"number\", label: \"Number\" },\n { value: \"select\", label: \"Select\" },\n { value: \"switch\", label: \"Switch (yes / no)\" },\n { value: \"date\", label: \"Date\" },\n { value: \"datetime\", label: \"Date + time\" },\n { value: \"time\", label: \"Time\" },\n { value: \"email\", label: \"Email\" },\n { value: \"url\", label: \"URL\" },\n { value: \"tel\", label: \"Phone\" },\n { value: \"password\", label: \"Password\" },\n ],\n },\n {\n // Without this a panel-authored select had nothing to choose from,\n // so it rendered an empty dropdown — the type was declarable and\n // unusable in the same breath.\n type: \"keyvalue\",\n key: \"options\",\n label: \"Choices\",\n description: \"Select fields only. Left is the value the flow receives, right is what the person sees.\",\n keyLabel: \"Value\",\n valueLabel: \"Label\",\n keyPlaceholder: \"small\",\n valuePlaceholder: \"Small\",\n addLabel: \"Add choice\",\n },\n { type: \"switch\", key: \"required\", label: \"Required\", default: false },\n ],\n default: [{ key: \"answer\", label: \"Your answer\", type: \"textarea\", required: true }],\n },\n ],\n },\n\n {\n name: \"@particle-academy/rich_user_input\",\n aliases: [\"rich_user_input\", \"@fancy/rich_user_input\"],\n pausesForHuman: \"input\",\n category: \"human\",\n label: \"Rich User Input\",\n description: \"Pause the flow on a fully authored page — content, required reading, multi-section forms.\",\n icon: \"▤\",\n inputs: [{ id: \"in\" }],\n outputs: [{ id: \"out\", label: \"values\" }],\n configSchema: [\n { type: \"text\", key: \"title\", label: \"Step title\", default: \"Please review\" },\n {\n type: \"document\",\n key: \"document\",\n label: \"Page content\",\n documentType: \"stages\",\n description: \"Authored with the host's document editor (fancy-cms Stages).\",\n },\n { type: \"switch\", key: \"requireConfirm\", label: \"Require explicit confirmation\", default: true },\n { type: \"text\", key: \"submitLabel\", label: \"Submit button\", default: \"Continue\" },\n ],\n },\n\n {\n name: \"@particle-academy/subflow\",\n aliases: [\"subflow\", \"@fancy/subflow\"],\n category: \"logic\",\n label: \"SubFlow\",\n description: \"Run another workflow and bring its result — or its live progress — back into this one.\",\n icon: \"⧉\",\n inputs: [{ id: \"in\" }],\n // The stream port only exists when something actually streams.\n outputs: (config: any) => subflowPorts(config ?? {}),\n // Core, not marketplace: it runs a child graph through this same engine and\n // needs nothing from outside except where workflows live.\n executor: subflowExecutor,\n configSchema: [\n { type: \"text\", key: \"workflow\", label: \"Workflow\", required: true,\n placeholder: \"onboarding-v2\",\n description: \"Reference resolved by the host's registerWorkflowResolver().\" },\n { type: \"number\", key: \"version\", label: \"Pin to version\",\n description: \"Optional. Leave blank to always run the child's current version. Pinning fails the run loudly if the child has moved on — without it, someone edits the child and this flow silently runs different logic.\" },\n {\n type: \"select\", key: \"mode\", label: \"Return\", default: \"output\",\n options: [\n { value: \"output\", label: \"Output when it finishes\" },\n { value: \"stream\", label: \"Stream progress as it runs\" },\n { value: \"both\", label: \"Both — stream, then output\" },\n ],\n description: \"Streaming adds a second port so a parent can show progress instead of a spinner.\",\n },\n { type: \"keyvalue\", key: \"inputs\", label: \"Input mapping\",\n description: \"Values handed to the child's entry points. Omit to pass this node's inputs straight through.\",\n keyLabel: \"Name\", valueLabel: \"Value\", addLabel: \"Add input\" },\n { type: \"number\", key: \"maxDepth\", label: \"Max nesting depth\", default: DEFAULT_MAX_DEPTH, min: 1, max: 32,\n description: \"Guards against a workflow referencing itself.\" },\n ],\n },\n\n // ───────────── Logic ─────────────\n {\n name: \"@particle-academy/branch\",\n // returns its input on the chosen port\n emits: \"input\",\n aliases: [\"branch\", \"@fancy/branch\"],\n // Pure logic: no I/O to choose, so a default is safe. A host\n // executor still wins -- pickExecutor consults the registry first.\n executor: branchExecutor,\n category: \"logic\",\n label: \"Branch\",\n description: \"Multi-way branch on a condition or value.\",\n icon: \"◇\",\n inputs: [{ id: \"in\" }],\n outputs: [{ id: \"true\", label: \"true\" }, { id: \"false\", label: \"false\" }],\n configSchema: [\n {\n type: \"select\", key: \"match\", label: \"Match\", default: \"all\",\n options: [\n { value: \"all\", label: \"All conditions (AND)\" },\n { value: \"any\", label: \"Any condition (OR)\" },\n ],\n },\n {\n type: \"repeater\",\n key: \"conditions\",\n label: \"Conditions\",\n description: \"Routes to `true` when these match, otherwise `false`.\",\n titleKey: \"left\",\n addLabel: \"Add condition\",\n minItems: 1,\n fields: [\n { type: \"expression\", key: \"left\", label: \"Value\", example: \"{{ $json.status }}\", required: true },\n {\n type: \"select\", key: \"operator\", label: \"Is\", default: \"eq\",\n options: [\n { value: \"eq\", label: \"equal to\" },\n { value: \"neq\", label: \"not equal to\" },\n { value: \"contains\", label: \"contains\" },\n { value: \"not_contains\", label: \"does not contain\" },\n { value: \"gt\", label: \"greater than\" },\n { value: \"gte\", label: \"greater than or equal to\" },\n { value: \"lt\", label: \"less than\" },\n { value: \"lte\", label: \"less than or equal to\" },\n { value: \"truthy\", label: \"true\" },\n { value: \"falsy\", label: \"false\" },\n { value: \"empty\", label: \"empty\" },\n { value: \"not_empty\", label: \"not empty\" },\n ],\n },\n { type: \"text\", key: \"right\", label: \"Compared to\", placeholder: \"active\" },\n ],\n default: [{ left: \"\", operator: \"eq\", right: \"\" }],\n },\n {\n type: \"expression\",\n key: \"condition\",\n label: \"Raw expression (advanced)\",\n example: \"{{ $json.active && $json.score > 10 }}\",\n description: \"Escape hatch for logic the builder can't express. Overrides the conditions above when set.\",\n },\n ],\n },\n {\n name: \"@particle-academy/switch_case\",\n // returns its input on the chosen port\n emits: \"input\",\n aliases: [\"switch_case\", \"@fancy/switch_case\"],\n category: \"logic\",\n label: \"Switch\",\n description: \"Route to one of N labelled outputs based on a key.\",\n icon: \"⤳\",\n inputs: [{ id: \"in\" }],\n // Ports ARE the config: every distinct port a case routes to becomes an\n // output handle, plus the always-present `default`. Editing the cases map\n // moves the ports on the canvas and the ports the runtime activates.\n outputs: (config: any) => casePorts(config?.cases),\n configSchema: [\n { type: \"expression\", key: \"value\", label: \"Switch on\", example: \"{{ $json.kind }}\", required: true },\n {\n type: \"keyvalue\",\n key: \"cases\",\n label: \"Cases\",\n description: \"Match value → output port. Unmatched input takes `default`.\",\n keyLabel: \"When value is\",\n valueLabel: \"Route to port\",\n keyPlaceholder: \"a\",\n valuePlaceholder: \"case_a\",\n addLabel: \"Add case\",\n default: { a: \"case_a\", b: \"case_b\" },\n },\n ],\n },\n {\n name: \"@particle-academy/for_each\",\n outputShape: [\n { path: \"items\", type: \"array\" },\n { path: \"count\", type: \"number\" },\n ],\n aliases: [\"for_each\", \"@fancy/for_each\"],\n // Pure logic: no I/O to choose, so a default is safe. A host\n // executor still wins -- pickExecutor consults the registry first.\n executor: forEachExecutor,\n category: \"logic\",\n label: \"For Each\",\n description: \"Iterate over a list, emitting each item on `item`.\",\n icon: \"↻\",\n inputs: [{ id: \"in\" }],\n outputs: [{ id: \"item\", label: \"item\" }, { id: \"done\", label: \"done\" }],\n configSchema: [\n { type: \"expression\", key: \"source\", label: \"List\", example: \"{{ $json.users }}\", required: true },\n { type: \"number\", key: \"concurrency\", label: \"Concurrency\", default: 1, min: 1, max: 50 },\n ],\n },\n {\n name: \"@particle-academy/merge\",\n // `merge` mode unions every object input at the TOP level; `concat` builds\n // a list instead, whose elements are not addressable as fields. So concat\n // declares NOTHING rather than an empty list -- `[]` would claim \"emits no\n // fields\" of a kind that emits a list, which is false and refuses every\n // reference.\n emits: (config: { mode?: string }) =>\n (config?.mode ?? \"merge\") === \"concat\" ? null : (\"inputs-merged\" as const),\n aliases: [\"merge\", \"@fancy/merge\"],\n // Pure logic: no I/O to choose, so a default is safe. A host\n // executor still wins -- pickExecutor consults the registry first.\n executor: mergeExecutor,\n category: \"logic\",\n label: \"Merge\",\n description: \"Combine multiple inputs into one object or array.\",\n icon: \"⊕\",\n inputs: [{ id: \"a\" }, { id: \"b\" }],\n outputs: [{ id: \"out\" }],\n configSchema: [\n { type: \"select\", key: \"mode\", label: \"Mode\", default: \"merge\",\n options: [{ value: \"merge\", label: \"Object merge\" }, { value: \"concat\", label: \"Array concat\" }] },\n ],\n },\n {\n name: \"@particle-academy/wait\",\n outputShape: [\n { path: \"waited\", type: \"string\" as const, description: \"Which wait mode ran.\" },\n { path: \"duration\", type: \"number\" as const, description: \"How long it waited.\" },\n { path: \"input\", type: \"unknown\" as const, description: \"The value that arrived, carried forward.\" },\n ],\n aliases: [\"wait\", \"@fancy/wait\"],\n category: \"logic\",\n label: \"Wait\",\n description: \"Sleep or wait for an external event.\",\n icon: \"⏸\",\n configSchema: [\n { type: \"select\", key: \"mode\", label: \"Mode\", default: \"duration\",\n options: [{ value: \"duration\", label: \"Duration\" }, { value: \"until\", label: \"Until timestamp\" }, { value: \"event\", label: \"External event\" }] },\n { type: \"text\", key: \"duration\", label: \"Duration\", placeholder: \"5s, 10m, 1h\", description: \"Used when mode = duration.\" },\n ],\n },\n {\n name: \"@particle-academy/transform\",\n // Two behaviours: the input unchanged when no expression is configured,\n // else the shape that expression names. So the RELATION is config-dependent.\n emits: (config: { expression?: string }) =>\n (config?.expression ?? \"\") === \"\" ? (\"input\" as const) : (\"expression:expression\" as const),\n aliases: [\"transform\", \"@fancy/transform\"],\n // Pure logic: no I/O to choose, so a default is safe. A host\n // executor still wins -- pickExecutor consults the registry first.\n executor: transformExecutor,\n category: \"logic\",\n label: \"Transform\",\n description: \"Reshape data with an expression.\",\n icon: \"ƒ\",\n configSchema: [\n {\n type: \"select\", key: \"mode\", label: \"Build the output\", default: \"fields\",\n options: [\n { value: \"fields\", label: \"Field by field\" },\n { value: \"expression\", label: \"One expression\" },\n ],\n },\n {\n type: \"repeater\",\n key: \"fields\",\n label: \"Output fields\",\n description: \"Each row becomes a key on the result.\",\n titleKey: \"key\",\n addLabel: \"Add field\",\n fields: [\n { type: \"text\", key: \"key\", label: \"Key\", required: true, placeholder: \"name\" },\n { type: \"expression\", key: \"value\", label: \"Value\", example: \"{{ $json.first }}\", required: true },\n ],\n default: [{ key: \"\", value: \"\" }],\n },\n {\n type: \"expression\",\n key: \"expression\",\n label: \"Expression (advanced)\",\n example: \"{{ { id: $json.id, name: $json.first + ' ' + $json.last } }}\",\n description: \"Used when the mode above is set to one expression.\",\n },\n ],\n },\n\n // ───────────── Data ─────────────\n {\n name: \"@particle-academy/memory_store\",\n aliases: [\"memory_store\", \"@fancy/memory_store\"],\n category: \"data\",\n label: \"Memory Store\",\n description: \"Read or write per-conversation memory.\",\n icon: \"🧠\",\n configSchema: [\n { type: \"select\", key: \"operation\", label: \"Operation\", required: true, default: \"read\",\n options: [{ value: \"read\", label: \"Read\" }, { value: \"write\", label: \"Write\" }, { value: \"append\", label: \"Append\" }] },\n { type: \"text\", key: \"key\", label: \"Key\", placeholder: \"user.preferences\", required: true },\n { type: \"expression\", key: \"value\", label: \"Value (write/append only)\", example: \"{{ $json }}\" },\n { type: \"credential\", key: \"store\", label: \"Memory store\", credentialType: \"memory_store\" },\n ],\n },\n {\n name: \"@particle-academy/data_store\",\n aliases: [\"data_store\", \"@fancy/data_store\"],\n category: \"data\",\n label: \"Data Store\",\n description: \"Key-value or table read/write against a host store.\",\n icon: \"🗃\",\n configSchema: [\n { type: \"select\", key: \"operation\", label: \"Operation\", required: true, default: \"get\",\n options: [\n { value: \"get\", label: \"Get\" }, { value: \"set\", label: \"Set\" }, { value: \"delete\", label: \"Delete\" },\n { value: \"query\", label: \"Query\" }, { value: \"list\", label: \"List\" },\n ] },\n { type: \"text\", key: \"table\", label: \"Table / collection\", required: true },\n { type: \"text\", key: \"key\", label: \"Key\" },\n { type: \"keyvalue\", key: \"where\", label: \"Where\",\n description: \"Field/value pairs to match. For query and list operations.\",\n keyLabel: \"Field\", valueLabel: \"Equals\", addLabel: \"Add filter\" },\n { type: \"expression\", key: \"value\", label: \"Value (set only)\", example: \"{{ $json }}\" },\n { type: \"credential\", key: \"store\", label: \"Data store\", credentialType: \"data_store\" },\n ],\n },\n {\n name: \"@particle-academy/variable\",\n // evaluates the expression in config.value\n emits: \"expression:value\",\n aliases: [\"variable\", \"@fancy/variable\"],\n category: \"data\",\n label: \"Variable\",\n description: \"Workflow-scoped value used by other nodes.\",\n icon: \"𝓍\",\n configSchema: [\n { type: \"text\", key: \"name\", label: \"Name\", required: true },\n { type: \"expression\", key: \"value\", label: \"Value\", required: true },\n ],\n },\n\n // ───────────── AI ─────────────\n {\n name: \"@particle-academy/llm_call\",\n // LlmClient::complete() -> array{text:string,data?:mixed,usage?:array,raw?:mixed}\n //\n // A FUNCTION of config, because `data` exists only when this node was asked\n // for a schema. Declaring it statically would offer `{{ $json.data }}` on\n // every llm_call in the kit, including the ones that emit nothing of the\n // sort — and a suggestion that resolves to null at runtime is worse than no\n // suggestion, since the picker is exactly what gave the author confidence.\n outputShape: (config: { response_schema?: unknown }) => {\n const asked =\n config?.response_schema != null &&\n config.response_schema !== \"\" &&\n !(Array.isArray(config.response_schema) && config.response_schema.length === 0);\n\n return [\n { path: \"text\", type: \"string\" as const, description: \"The model's completion.\" },\n ...(asked\n ? [{ path: \"data\", type: \"unknown\" as const, description: \"The parsed, schema-checked result.\" }]\n : []),\n { path: \"usage\", type: \"object\" as const, description: \"Token counts, when the provider reports them.\" },\n { path: \"raw\", type: \"unknown\" as const, description: \"The provider's untouched response.\" },\n ];\n },\n aliases: [\"llm_call\", \"@fancy/llm_call\"],\n category: \"ai\",\n label: \"LLM Call\",\n description: \"Send a prompt + context to a model and receive a response.\",\n icon: \"✦\",\n configSchema: [\n { type: \"select\", key: \"provider\", label: \"Provider\", default: \"anthropic\",\n options: [\n { value: \"anthropic\", label: \"Anthropic\" },\n { value: \"openai\", label: \"OpenAI\" },\n { value: \"custom\", label: \"Custom\" },\n ] },\n { type: \"text\", key: \"model\", label: \"Model\", placeholder: \"claude-sonnet-4-5\", required: true },\n { type: \"textarea\", key: \"system\", label: \"System prompt\", rows: 4 },\n { type: \"expression\", key: \"prompt\", label: \"User prompt\", example: \"{{ $json.question }}\", required: true },\n { type: \"number\", key: \"temperature\", label: \"Temperature\", min: 0, max: 2, step: 0.1, default: 0.7 },\n { type: \"number\", key: \"max_tokens\", label: \"Max tokens\", min: 1, max: 8192, default: 1024 },\n {\n type: \"repeater\", key: \"tools\", label: \"Tools\",\n description: \"Tools the model may call.\",\n titleKey: \"name\", addLabel: \"Add tool\",\n fields: [\n { type: \"text\", key: \"name\", label: \"Name\", required: true, placeholder: \"search_index\" },\n { type: \"text\", key: \"description\", label: \"When to use it\" },\n { type: \"json\", key: \"input_schema\", label: \"Input schema\",\n description: \"JSON Schema for the tool's arguments.\" },\n ],\n },\n {\n type: \"json\", key: \"response_schema\", label: \"Response schema\",\n description:\n \"Optional JSON Schema. When set, the runtime asks the provider for schema-valid JSON \" +\n \"and the node emits the parsed value as `data` — reference it as {{ $json.data }}. \" +\n \"A response that cannot be parsed or does not match FAILS the node rather than \" +\n \"passing an empty value downstream.\",\n },\n { type: \"credential\", key: \"credential\", label: \"API credential\", credentialType: \"llm_credential\" },\n ],\n },\n {\n name: \"@particle-academy/llm_router\",\n outputShape: [\n { path: \"route\", type: \"string\" as const, description: \"The port the model chose.\" },\n { path: \"reason\", type: \"string\" as const, description: \"Why the model chose it.\" },\n { path: \"input\", type: \"unknown\" as const, description: \"The value that arrived, carried forward.\" },\n ],\n // Every id this node has ever shipped under keeps resolving — MOIC's saved\n // flows carry the bare `llm_branch`.\n aliases: [\"llm_router\", \"llm_branch\", \"@fancy/llm_branch\", \"@fancy/llm_router\"],\n category: \"ai\",\n label: \"LLM Router\",\n description: \"Let a model choose which route the flow takes.\",\n icon: \"✧\",\n inputs: [{ id: \"in\" }],\n // Each declared route is a port. The executor returns `{ __port: id }`\n // (or `Port.only(id)` on the PHP runtime) to pick one.\n outputs: (config: any) => routePorts(config?.routes, config?.fallback),\n // A shuttle, not an engine: it carries the routes out to whatever LLM\n // client the host registered and carries the choice back. No provider SDK\n // reaches core, so this stays a builtin without adding a dependency.\n executor: llmRouterExecutor,\n configSchema: [\n { type: \"textarea\", key: \"system\", label: \"System prompt\", rows: 3,\n description: \"Optional framing for the routing decision.\" },\n { type: \"expression\", key: \"prompt\", label: \"What to route on\",\n example: \"{{ $json.message }}\", required: true },\n {\n type: \"repeater\",\n key: \"routes\",\n label: \"Routes\",\n description: \"The model picks exactly one. Descriptions are what it chooses between — make them distinct.\",\n titleKey: \"port\",\n addLabel: \"Add route\",\n minItems: 2,\n fields: [\n { type: \"text\", key: \"port\", label: \"Port\", required: true, placeholder: \"billing\" },\n { type: \"text\", key: \"description\", label: \"When to choose it\", required: true,\n placeholder: \"The user is asking about an invoice, refund, or payment.\" },\n ],\n default: [\n { port: \"a\", description: \"Describe when the model should pick this route.\" },\n { port: \"b\", description: \"Describe when the model should pick this route.\" },\n ],\n },\n { type: \"select\", key: \"provider\", label: \"Provider\", default: \"anthropic\",\n options: [\n { value: \"anthropic\", label: \"Anthropic\" },\n { value: \"openai\", label: \"OpenAI\" },\n { value: \"custom\", label: \"Custom\" },\n ] },\n { type: \"text\", key: \"model\", label: \"Model\", placeholder: \"claude-sonnet-4-5\" },\n { type: \"switch\", key: \"fallback\", label: \"Add a `fallback` port\", default: true,\n description: \"Where the flow goes if the model returns no usable route.\" },\n { type: \"credential\", key: \"credential\", label: \"API credential\", credentialType: \"llm_credential\" },\n ],\n },\n {\n name: \"@particle-academy/tool_use\",\n aliases: [\"tool_use\", \"@fancy/tool_use\"],\n category: \"ai\",\n label: \"Tool Use\",\n description: \"Hand control to a host-registered tool by name.\",\n icon: \"🛠\",\n configSchema: [\n { type: \"text\", key: \"tool\", label: \"Tool name\", placeholder: \"search_index\", required: true },\n { type: \"expression\", key: \"args\", label: \"Arguments\", example: \"{{ { query: $json.q } }}\" },\n ],\n },\n {\n name: \"@particle-academy/embed_search\",\n outputShape: [\n { path: \"query\", type: \"string\" },\n { path: \"matches\", type: \"array\", description: \"Ranked results from the vector store.\" },\n ],\n aliases: [\"embed_search\", \"@fancy/embed_search\"],\n category: \"ai\",\n label: \"Embed & Search\",\n description: \"Embed a query and search a vector store.\",\n icon: \"✺\",\n configSchema: [\n { type: \"expression\", key: \"query\", label: \"Query\", required: true, example: \"{{ $json.question }}\" },\n { type: \"number\", key: \"topK\", label: \"Top K\", default: 5, min: 1, max: 50 },\n { type: \"credential\", key: \"vectorStore\", label: \"Vector store\", credentialType: \"vector_store\" },\n ],\n },\n\n // ───────────── IO ─────────────\n {\n name: \"@particle-academy/api_request\",\n // HttpClient::send() -> array{status:int,headers:array,body:mixed}\n outputShape: [\n { path: \"status\", type: \"number\", description: \"HTTP status code.\" },\n { path: \"headers\", type: \"object\" },\n { path: \"body\", type: \"unknown\", description: \"Decoded JSON when the response is JSON, otherwise the raw body.\" },\n ],\n aliases: [\"api_request\", \"@fancy/api_request\"],\n category: \"io\",\n label: \"API Request\",\n description: \"HTTP request to any URL.\",\n icon: \"↔\",\n configSchema: [\n ...HTTP_METHODS,\n { type: \"text\", key: \"url\", label: \"URL\", placeholder: \"https://api.example.com/...\", required: true },\n { type: \"keyvalue\", key: \"headers\", label: \"Headers\",\n keyLabel: \"Header\", valueLabel: \"Value\",\n keyPlaceholder: \"content-type\", valuePlaceholder: \"application/json\",\n addLabel: \"Add header\",\n default: { \"content-type\": \"application/json\" } },\n { type: \"json\", key: \"body\", label: \"Body\" },\n { type: \"credential\", key: \"auth\", label: \"Auth\", credentialType: \"api_credential\" },\n ],\n },\n {\n name: \"@particle-academy/webhook_out\",\n outputShape: [\n { path: \"sent\", type: \"boolean\" as const, description: \"True once the request was made.\" },\n { path: \"status\", type: \"number\" as const, description: \"HTTP status, when the transport reported one.\" },\n { path: \"response\", type: \"unknown\" as const, description: \"The response body, when there was one.\" },\n ],\n aliases: [\"webhook_out\", \"@fancy/webhook_out\"],\n category: \"io\",\n label: \"Send Webhook\",\n description: \"POST a payload to a configured URL.\",\n icon: \"↗\",\n configSchema: [\n { type: \"text\", key: \"url\", label: \"URL\", required: true },\n { type: \"keyvalue\", key: \"headers\", label: \"Headers\",\n keyLabel: \"Header\", valueLabel: \"Value\", addLabel: \"Add header\" },\n { type: \"expression\", key: \"payload\", label: \"Payload\", required: true, example: \"{{ $json }}\" },\n ],\n },\n\n // ───────────── Human ─────────────\n {\n name: \"@particle-academy/human_approval\",\n // returns its input on approved/denied\n emits: \"input\",\n aliases: [\"human_approval\", \"@fancy/human_approval\"],\n pausesForHuman: \"approval\",\n category: \"human\",\n label: \"Human Approval\",\n description: \"Pause until a human approves or denies.\",\n icon: \"✓\",\n inputs: [{ id: \"in\" }],\n outputs: [{ id: \"approved\", label: \"approved\" }, { id: \"denied\", label: \"denied\" }],\n configSchema: [\n { type: \"text\", key: \"title\", label: \"Approval title\", default: \"Approve action\" },\n { type: \"textarea\", key: \"description\", label: \"Description for approver\", rows: 3 },\n { type: \"credential\", key: \"channel\", label: \"Notify channel\", credentialType: \"notify_channel\" },\n ],\n },\n {\n name: \"@particle-academy/notify\",\n outputShape: [\n { path: \"sent\", type: \"boolean\" as const, description: \"True once the message was handed to the channel.\" },\n { path: \"channel\", type: \"string\" as const, description: \"The channel it went to.\" },\n { path: \"to\", type: \"string\" as const, description: \"The recipient.\" },\n { path: \"message\", type: \"string\" as const, description: \"The rendered message.\" },\n ],\n aliases: [\"notify\", \"@fancy/notify\"],\n category: \"human\",\n label: \"Notify\",\n description: \"Send a message via Slack / email / SMS / etc.\",\n icon: \"🔔\",\n configSchema: [\n { type: \"select\", key: \"channel\", label: \"Channel\", default: \"slack\",\n options: [\n { value: \"slack\", label: \"Slack\" }, { value: \"email\", label: \"Email\" },\n { value: \"sms\", label: \"SMS\" }, { value: \"discord\", label: \"Discord\" },\n ] },\n { type: \"text\", key: \"to\", label: \"To\", required: true },\n { type: \"expression\", key: \"message\", label: \"Message\", required: true, example: \"{{ $json.summary }}\" },\n ],\n },\n\n // ───────────── Output ─────────────\n {\n name: \"@particle-academy/output\",\n // returns its input unchanged\n emits: \"input\",\n aliases: [\"output\", \"@fancy/output\"],\n category: \"output\",\n label: \"Output\",\n description: \"Terminal node — captures the workflow's result.\",\n icon: \"●\",\n inputs: [{ id: \"in\" }],\n outputs: [],\n },\n {\n name: \"@particle-academy/log\",\n outputShape: [\n { path: \"logged\", type: \"string\" as const, description: \"The message that was written.\" },\n { path: \"level\", type: \"string\" as const, description: \"The level it was written at.\" },\n ],\n aliases: [\"log\", \"@fancy/log\"],\n category: \"output\",\n label: \"Log\",\n description: \"Send to the run feed.\",\n icon: \"≡\",\n inputs: [{ id: \"in\" }],\n outputs: [],\n configSchema: [\n { type: \"select\", key: \"level\", label: \"Level\", default: \"info\",\n options: [{ value: \"info\", label: \"info\" }, { value: \"warn\", label: \"warn\" }, { value: \"error\", label: \"error\" }] },\n { type: \"expression\", key: \"message\", label: \"Message\", required: true, example: \"{{ $json }}\" },\n ],\n },\n {\n // Swimlane — a portless, resizable container. Child nodes are parented into\n // it; it never runs (the runtime skips the `layout` category). Uses its own\n // renderer (LaneNode) instead of the default card.\n name: \"@particle-academy/lane\",\n aliases: [\"lane\", \"@fancy/lane\"],\n category: \"layout\",\n label: \"Lane\",\n description: \"A resizable swimlane — drop nodes into it to group them.\",\n icon: \"▤\",\n inputs: [],\n outputs: [],\n configSchema: [\n { type: \"text\", key: \"title\", label: \"Title\", default: \"Lane\" },\n { type: \"select\", key: \"orientation\", label: \"Orientation\", default: \"horizontal\",\n options: [{ value: \"horizontal\", label: \"Row\" }, { value: \"vertical\", label: \"Column\" }] },\n ],\n defaultConfig: { title: \"Lane\", orientation: \"horizontal\" },\n resizable: { minWidth: 160, minHeight: 72 },\n },\n {\n // Terminal lane — a lane that OWNS a terminal for the length of the run.\n //\n // Visually a swimlane, and `layout` for the same reason the plain lane is:\n // a lane is not a step, so it never executes and never appears in topo\n // order. What is new is that it DECLARES a resource. The runtime opens its\n // terminal lazily, when the first terminal node inside it runs, and closes\n // it in the run's `finally` — so a graph that never reaches a terminal node\n // never spawns a process, and one that does gets exactly one session no\n // matter how many nodes use it.\n //\n // Membership is `parentId`, which already persists into the WorkflowSchema.\n // That is what lets a headless runtime resolve the same grouping the canvas\n // shows, without a second association to keep in sync.\n name: \"@particle-academy/terminal_lane\",\n aliases: [\"terminal_lane\", \"@fancy/terminal_lane\"],\n category: \"layout\",\n label: \"Terminal lane\",\n description: \"A lane that owns one terminal. Opens at the first terminal node, closes when the run ends.\",\n icon: \"▣\",\n inputs: [],\n outputs: [],\n configSchema: [\n { type: \"text\", key: \"title\", label: \"Title\", default: \"Terminal\" },\n {\n type: \"text\",\n key: \"command\",\n label: \"Command\",\n placeholder: \"Leave empty for the default shell\",\n },\n { type: \"text\", key: \"cwd\", label: \"Working directory\", placeholder: \"Host default\" },\n { type: \"keyvalue\", key: \"env\", label: \"Environment\" },\n {\n type: \"select\",\n key: \"orientation\",\n label: \"Orientation\",\n default: \"horizontal\",\n options: [\n { value: \"horizontal\", label: \"Row\" },\n { value: \"vertical\", label: \"Column\" },\n ],\n },\n ],\n defaultConfig: { title: \"Terminal\", orientation: \"horizontal\" },\n resizable: { minWidth: 220, minHeight: 120 },\n },\n {\n // Terminal nodes. All three live inside a terminal lane and talk to the\n // session that lane owns; outside one they abort by name rather than\n // opening a shell of their own.\n name: \"@particle-academy/terminal_run\",\n aliases: [\"terminal_run\", \"@fancy/terminal_run\"],\n category: \"io\",\n label: \"Run in terminal\",\n description: \"Run a shell command in the lane's terminal and wait for its exit code.\",\n icon: \"$\",\n inputs: [{ id: \"in\" }],\n outputs: [{ id: \"out\", label: \"output\" }],\n executor: terminalRunExecutor,\n configSchema: [\n {\n type: \"textarea\",\n key: \"command\",\n label: \"Command\",\n rows: 3,\n required: true,\n placeholder: \"npm test\",\n description:\n \"Runs in the lane's shell, so `cd` and exported variables persist between nodes. \"\n + \"SHELL ONLY — a TUI never returns to a prompt, so use Send + Await for one.\",\n },\n {\n type: \"number\",\n key: \"timeoutMs\",\n label: \"Timeout (ms)\",\n default: 120000,\n description: \"How long to wait for the command to finish before failing the run.\",\n },\n {\n type: \"switch\",\n key: \"failOnNonZero\",\n label: \"Fail the run on a non-zero exit\",\n default: true,\n description:\n \"On by default. Turning it off means a failed command lets the run report success — \"\n + \"read the exit code on the output port and branch on it instead.\",\n },\n ],\n defaultConfig: { command: \"\", timeoutMs: 120000, failOnNonZero: true },\n },\n\n {\n name: \"@particle-academy/terminal_send\",\n aliases: [\"terminal_send\", \"@fancy/terminal_send\"],\n category: \"io\",\n label: \"Send to terminal\",\n description: \"Type text at whatever is running in the lane's terminal, without waiting.\",\n icon: \"⌨\",\n inputs: [{ id: \"in\" }],\n outputs: [{ id: \"out\", label: \"sent\" }],\n executor: terminalSendExecutor,\n configSchema: [\n {\n type: \"textarea\",\n key: \"text\",\n label: \"Text\",\n rows: 4,\n placeholder: \"Summarise the failing test and propose a fix.\",\n description: \"What to type. This is how a graph prompts an agent TUI such as Claude Code or Codex.\",\n },\n {\n type: \"switch\",\n key: \"submit\",\n label: \"Press Enter\",\n default: true,\n description: \"Off leaves the text on the input line — useful for building one up across several nodes.\",\n },\n {\n type: \"switch\",\n key: \"clearFirst\",\n label: \"Forget earlier output first\",\n default: false,\n description:\n \"Discards anything the terminal said before this send, so a following Await cannot match \"\n + \"a prompt left over from the previous exchange.\",\n },\n ],\n defaultConfig: { text: \"\", submit: true, clearFirst: false },\n },\n\n {\n name: \"@particle-academy/terminal_await\",\n aliases: [\"terminal_await\", \"@fancy/terminal_await\"],\n category: \"io\",\n label: \"Await terminal output\",\n description: \"Wait until the lane's terminal prints something that matches.\",\n icon: \"⏱\",\n inputs: [{ id: \"in\" }],\n outputs: [{ id: \"out\", label: \"output\" }],\n executor: terminalAwaitExecutor,\n configSchema: [\n {\n type: \"text\",\n key: \"pattern\",\n label: \"Wait for\",\n required: true,\n placeholder: \"esc to interrupt\",\n description: \"Matched against the output with colour codes already stripped, so match what you SEE.\",\n },\n {\n type: \"select\",\n key: \"mode\",\n label: \"Match as\",\n default: \"text\",\n options: [\n { value: \"text\", label: \"Plain text\" },\n { value: \"regex\", label: \"Regular expression\" },\n ],\n description: \"Regex mode also returns capture groups, which is how a value gets out of a prompt.\",\n },\n {\n type: \"number\",\n key: \"timeoutMs\",\n label: \"Timeout (ms)\",\n default: 120000,\n },\n {\n type: \"select\",\n key: \"onTimeout\",\n label: \"If it never appears\",\n default: \"fail\",\n options: [\n { value: \"fail\", label: \"Fail the run\" },\n { value: \"continue\", label: \"Continue with matched: false\" },\n ],\n description:\n \"Failing is the default. Continuing lets the next node type at a process that never became \"\n + \"ready while the run still reports success, so it has to be asked for.\",\n },\n ],\n defaultConfig: { pattern: \"\", mode: \"text\", timeoutMs: 120000, onTimeout: \"fail\" },\n },\n\n {\n // Note — a sticky-note annotation. Portless + visual-only: the runtime skips\n // the `annotation` category, so a note's text NEVER reaches a runner — it\n // rides in the document purely for people, editors, and MCP tools. Uses its\n // own renderer (NoteNode); double-click on the canvas to edit in place.\n name: \"@particle-academy/note\",\n aliases: [\"note\", \"@fancy/note\"],\n category: \"annotation\",\n label: \"Note\",\n description: \"A sticky note that documents the canvas. Never runs — editor + agent only.\",\n icon: \"🗒\",\n inputs: [],\n outputs: [],\n configSchema: [\n { type: \"text\", key: \"title\", label: \"Title\", placeholder: \"Optional heading\" },\n { type: \"textarea\", key: \"text\", label: \"Note\", rows: 5, placeholder: \"What does this part of the flow do?\" },\n { type: \"select\", key: \"color\", label: \"Color\", default: \"amber\", options: [\n { value: \"amber\", label: \"Amber\" },\n { value: \"sky\", label: \"Sky\" },\n { value: \"violet\", label: \"Violet\" },\n { value: \"emerald\", label: \"Emerald\" },\n { value: \"rose\", label: \"Rose\" },\n { value: \"slate\", label: \"Slate\" },\n ] },\n ],\n defaultConfig: { text: \"\", color: \"amber\" },\n resizable: { minWidth: 140, minHeight: 80 },\n },\n];\n\n/**\n * Register every built-in kind AS DATA -- no renderers.\n *\n * This is what `registry.ts` self-populates with, so a headless consumer gets\n * the full vocabulary without React. `builtin.ts` re-registers the four kinds\n * that have renderers on top; `registerNodeKind` replaces by name, so that\n * upgrades them in place.\n */\nexport function registerBuiltinKindData(): void {\n for (const k of KINDS) registerNodeKind(k);\n}\n\n/** The raw table, renderer-free. `builtin.ts` exports the decorated one. */\nexport const BUILTIN_KIND_DATA: NodeKindDefinition[] = KINDS;\n","import type { ConfigField, NodeKindDefinition } from \"./types\";\n// The DATA module, deliberately -- importing `./builtin` here is what put\n// React into `/engine` (#11). See that file for the whole story.\nimport { registerBuiltinKindData } from \"./builtin-kinds\";\n\nconst kinds = new Map<string, NodeKindDefinition<any, any, any>>();\n/** alias → canonical name. See `resolveKindId`. */\nconst aliases = new Map<string, string>();\nconst listeners = new Set<() => void>();\n/**\n * canonical name → presentation patch. See `overrideNodeKind`.\n *\n * Kept SEPARATE from `kinds` on purpose: an override has to survive its base\n * kind being re-registered (HMR, a later `registerBuiltinKinds()`, a package\n * upgrade). Merging into the definition would mean the next registration\n * silently reverts the consumer's naming.\n */\nconst overrides = new Map<string, NodeKindPresentation>();\n\nlet builtinsEnsured = false;\n\n/**\n * Put the builtin kit in the registry before anyone reads or writes it.\n *\n * Registration used to be a bare `registerBuiltinKinds()` in `src/index.ts`, so\n * it fired ONLY as an import side effect of that one entry. Every other route in\n * — the `/engine` and `/registry` subpaths, or a root import that TypeScript\n * erases because it only took types — got an empty registry, and an empty\n * registry is silent: `getNodeKind()` returns null, `FlowViewer` falls through\n * its title chain, and the canvas shows `@particle-academy/llm_call` where a\n * name belongs.\n *\n * Doing it here instead means correctness no longer depends on which entry a\n * consumer imported, or on a bundler agreeing to keep a top-level statement.\n *\n * The flag is set BEFORE the call so a listener that reads the registry from\n * inside `notify()` cannot recurse. `registerNodeKind` ensures too, so builtins\n * are always in place before a host registers over one of them.\n */\nexport function ensureBuiltinKinds(): void {\n if (builtinsEnsured) return;\n builtinsEnsured = true;\n registerBuiltinKindData();\n}\n\n/**\n * The presentation fields a consumer may override on someone else's node kind.\n *\n * Deliberately excludes everything behavioural — `executor`, `inputs`,\n * `outputs`, `configSchema`, `sideEffects`. An \"override\" that could change\n * those is not an override, it is a fork wearing a friendly name, and it would\n * desync the graph from the runtime that executes it.\n *\n * `category` IS included: which drawer a node appears in is presentation, and a\n * consumer regrouping their palette is the same kind of act as renaming.\n */\nexport type NodeKindPresentation = Partial<\n Pick<NodeKindDefinition, \"label\" | \"description\" | \"icon\" | \"accent\" | \"category\">\n>;\n\n/**\n * registerNodeKind — install a node kind in the global registry. Returns\n * an `unregister` function. Calling with the same name replaces the prior\n * registration (handy for HMR).\n *\n * A kind's `name` is its CANONICAL id and is what gets written into saved\n * documents. Publish namespaced (`@fancy/llm_branch`, `@acme/salesforce_upsert`)\n * and list any previous bare names in `aliases`, so graphs saved before the\n * rename keep resolving.\n */\nexport function registerNodeKind<TC = any, TI = any, TO = any>(\n definition: NodeKindDefinition<TC, TI, TO>,\n): () => void {\n ensureBuiltinKinds();\n kinds.set(definition.name, definition as NodeKindDefinition<any, any, any>);\n for (const alias of definition.aliases ?? []) aliases.set(alias, definition.name);\n notify();\n return () => {\n if (kinds.get(definition.name) === (definition as any)) {\n kinds.delete(definition.name);\n for (const alias of definition.aliases ?? []) {\n if (aliases.get(alias) === definition.name) aliases.delete(alias);\n }\n notify();\n }\n };\n}\n\n/**\n * Resolve any id — canonical or alias — to the canonical one, or null.\n *\n * `kind` is persisted inside every saved graph, so a bare name that two\n * packages could both claim is unfixable after the fact: the ambiguous string\n * is already in the document. Canonical ids are namespaced; aliases exist so\n * documents written before namespacing keep opening.\n */\nexport function resolveKindId(id: string): string | null {\n ensureBuiltinKinds();\n if (kinds.has(id)) return id;\n const canonical = aliases.get(id);\n return canonical && kinds.has(canonical) ? canonical : null;\n}\n\n/**\n * Rename or re-describe a kind you did not author.\n *\n * Before this existed the only way to relabel a builtin was `registerNodeKind`\n * with a full definition — which REPLACES the kind, so a consumer wanting\n * \"Call an API\" instead of \"HTTP Request\" had to re-declare that node's\n * configSchema, ports, executor and renderer, and silently forfeited whatever\n * the builtin gained in the next release. In practice nobody renamed a node,\n * and the palette could not be localised at all.\n *\n * ```ts\n * const undo = overrideNodeKind(\"@particle-academy/api_request\", {\n * label: \"Call an API\",\n * description: \"Fetch or post JSON to a URL\",\n * });\n * ```\n *\n * Applies at `getNodeKind()` and `listNodeKinds()`, so one call reaches the\n * palette, the node cards on the canvas, `FlowViewer`, and anything else that\n * reads the registry. Returns an unsubscribe, matching `registerNodeKind`.\n *\n * Patching an unregistered id is allowed and takes effect if that kind is\n * registered later — order of module side effects is not something a consumer\n * should have to reason about.\n */\nexport function overrideNodeKind(name: string, patch: NodeKindPresentation): () => void {\n const canonical = resolveKindId(name) ?? name;\n const previous = overrides.get(canonical);\n\n overrides.set(canonical, { ...previous, ...patch });\n notify();\n\n return () => {\n if (previous) {\n overrides.set(canonical, previous);\n } else {\n overrides.delete(canonical);\n }\n notify();\n };\n}\n\n/** Remove every presentation override. Mostly for tests. */\nexport function clearNodeKindOverrides(): void {\n if (overrides.size === 0) return;\n overrides.clear();\n notify();\n}\n\nfunction withOverride(kind: NodeKindDefinition | undefined): NodeKindDefinition | null {\n if (!kind) return null;\n const patch = overrides.get(kind.name);\n return patch ? ({ ...kind, ...patch } as NodeKindDefinition) : kind;\n}\n\n/** Get a single kind by canonical id or alias, or null. */\nexport function getNodeKind(name: string): NodeKindDefinition | null {\n const canonical = resolveKindId(name);\n return canonical ? withOverride(kinds.get(canonical) as NodeKindDefinition) : null;\n}\n\n/** Every id a kind answers to — canonical first. Used to key node-type maps. */\nexport function kindIds(kind: NodeKindDefinition): string[] {\n return [kind.name, ...(kind.aliases ?? [])];\n}\n\n/** List every registered kind, optionally filtered by category. */\nexport function listNodeKinds(category?: string): NodeKindDefinition[] {\n ensureBuiltinKinds();\n const all = Array.from(kinds.values()).map((k) =>\n withOverride(k as NodeKindDefinition),\n ) as NodeKindDefinition[];\n // Filter AFTER applying overrides, so an override that moves a node to a\n // different category actually moves it in the palette rather than leaving it\n // filed under the old one with a new name.\n return category ? all.filter((k) => k.category === category) : all;\n}\n\n/** Subscribe to registry changes. Returns an unsubscribe function. */\nexport function onNodeKindsChanged(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\nfunction notify(): void {\n for (const l of listeners) l();\n}\n\n/** Fill in defaults from a kind's configSchema for newly-created nodes. */\nexport function defaultConfigFor(kind: NodeKindDefinition): Record<string, unknown> {\n const fromKind = kind.defaultConfig ? { ...(kind.defaultConfig as Record<string, unknown>) } : {};\n for (const field of kind.configSchema ?? []) {\n if (fromKind[field.key] !== undefined) continue;\n if (\"default\" in field && (field as any).default !== undefined) {\n fromKind[field.key] = (field as any).default;\n }\n }\n return fromKind;\n}\n\n/**\n * Validate a config object against a kind's schema. Returns an array of\n * issues (empty = valid). Validation is intentionally light — type\n * coercion + required-field checks. Hosts can layer Zod / Ajv on top.\n */\nexport function validateConfig(\n kind: NodeKindDefinition,\n config: Record<string, unknown>,\n): Array<{ key: string; message: string }> {\n const issues: Array<{ key: string; message: string }> = [];\n for (const field of kind.configSchema ?? []) {\n const value = config[field.key];\n if (field.required && (value === undefined || value === null || value === \"\")) {\n issues.push({ key: field.key, message: `${field.label} is required` });\n continue;\n }\n if (value === undefined || value === null) continue;\n const issue = validateField(field, value);\n if (issue) issues.push({ key: field.key, message: issue });\n }\n return issues;\n}\n\nfunction validateField(field: ConfigField, value: unknown): string | null {\n switch (field.type) {\n case \"text\":\n case \"textarea\":\n case \"expression\":\n case \"credential\":\n return typeof value === \"string\" ? null : `${field.label} must be a string`;\n case \"number\": {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return `${field.label} must be a number`;\n if (field.min !== undefined && value < field.min) return `${field.label} must be >= ${field.min}`;\n if (field.max !== undefined && value > field.max) return `${field.label} must be <= ${field.max}`;\n return null;\n }\n case \"switch\":\n return typeof value === \"boolean\" ? null : `${field.label} must be a boolean`;\n case \"select\": {\n const allowed = field.options.map((o) => o.value);\n return allowed.includes(String(value)) ? null : `${field.label} must be one of ${allowed.join(\", \")}`;\n }\n case \"json\":\n return null; // permissive — just JSON-shaped\n case \"repeater\": {\n if (!Array.isArray(value)) return `${field.label} must be a list`;\n if (field.minItems !== undefined && value.length < field.minItems) {\n return `${field.label} needs at least ${field.minItems}`;\n }\n if (field.maxItems !== undefined && value.length > field.maxItems) {\n return `${field.label} allows at most ${field.maxItems}`;\n }\n // Surface the first offending row so the author knows WHICH one.\n for (let i = 0; i < value.length; i++) {\n const row = value[i];\n if (!row || typeof row !== \"object\" || Array.isArray(row)) {\n return `${field.label} item ${i + 1} must be an object`;\n }\n for (const sub of field.fields) {\n const cell = (row as Record<string, unknown>)[sub.key];\n if (sub.required && (cell === undefined || cell === null || cell === \"\")) {\n return `${field.label} item ${i + 1}: ${sub.label} is required`;\n }\n if (cell === undefined || cell === null) continue;\n const issue = validateField(sub, cell);\n if (issue) return `${field.label} item ${i + 1}: ${issue}`;\n }\n }\n return null;\n }\n case \"keyvalue\": {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return `${field.label} must be a key/value map`;\n }\n const allowed = field.valueOptions?.map((o) => o.value);\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (typeof v !== \"string\") return `${field.label}: \"${k}\" must be a string`;\n if (allowed && !allowed.includes(v)) {\n return `${field.label}: \"${k}\" must be one of ${allowed.join(\", \")}`;\n }\n }\n return null;\n }\n case \"document\":\n return null; // opaque to fancy-flow — the host's editor owns its shape\n default:\n return null;\n }\n}\n\n/** Default accents per category. */\nexport function categoryAccent(category: string): string {\n switch (category) {\n case \"trigger\": return \"#10b981\";\n case \"logic\": return \"#f59e0b\";\n case \"data\": return \"#0ea5e9\";\n case \"ai\": return \"#8b5cf6\";\n case \"io\": return \"#3b82f6\";\n case \"human\": return \"#ec4899\";\n case \"output\": return \"#a855f7\";\n case \"layout\": return \"#64748b\";\n case \"annotation\": return \"#eab308\";\n default: return \"#71717a\";\n }\n}\n","/**\n * What a terminal has said, in a form a node can wait on.\n *\n * A raw `onData` stream is not something a workflow can match against, for\n * three reasons that all fail the same way — intermittently, and usually only\n * once there is real output moving:\n *\n * 1. **Chunks are arbitrary.** A PTY splits wherever it splits, so `Ready >`\n * can arrive as `Rea` + `dy >`. Testing each chunk on its own finds the\n * pattern when output is small enough to land in one write and misses it\n * when it is not. So matching runs against an ACCUMULATED buffer, never a\n * chunk.\n *\n * 2. **Output arrives before anyone is listening.** A node that types at a\n * process and a node that waits for its reply are two steps, and anything\n * printed between them is gone if the buffer starts when the wait does.\n * So the transcript is attached when the SESSION opens, and a wait reads\n * what has already accumulated before it subscribes to anything new.\n *\n * 3. **Escape sequences are everywhere and they also straddle.** An agent TUI\n * writes `Ready` as `ESC[32m Ready ESC[0m`, so matching raw bytes fails on\n * text a person can plainly read. Stripping per chunk reintroduces problem\n * 1 in a second guise — `ESC[3` + `2mReady` strips to `ESC[32mReady` with\n * the escape now INSIDE the text. So an incomplete trailing sequence is\n * held back until the rest of it arrives.\n *\n * Text is consumed through a match, so two waits for the same pattern do not\n * both resolve on the first occurrence — which would let a loop appear to make\n * progress while reading one old line forever.\n */\n\n/**\n * The control characters, by code point rather than as literals.\n *\n * A raw ESC byte sitting in a `.ts` file survives most tools and not all of\n * them, and the failure is the quiet kind: strip one out and the pattern below\n * still parses, still looks right in review, and matches nothing — so every\n * wait fails on coloured output while the code reads as correct. It happened\n * twice while this file was being written, which is the argument.\n */\nconst ESC = String.fromCharCode(0x1b);\nconst CSI = String.fromCharCode(0x9b);\nconst BEL = String.fromCharCode(0x07);\n\n/**\n * CSI (`ESC [ ... final`), OSC (`ESC ] ... BEL|ST`), and the two-character\n * escapes. Written out rather than taken from a dependency: it is a regex, and\n * the suite's rule is that third-party code is a liability carried for years.\n */\nconst ANSI = new RegExp(\n `[${ESC}${CSI}](?:\\\\[[0-?]*[ -/]*[@-~]|\\\\][^${BEL}${ESC}]*(?:${BEL}|${ESC}\\\\\\\\)|[@-Z\\\\\\\\-_])`,\n \"g\",\n);\n\n/**\n * How much unterminated escape to hold back before giving up on it.\n *\n * An OSC sequence carrying a window title is legitimately long, but a lone\n * `ESC` that never terminates is just a byte — holding the rest of the stream\n * hostage behind it would stall a wait forever, which is a worse failure than\n * one stray character in the output.\n */\nconst MAX_PENDING_ESCAPE = 1024;\n\n/**\n * Cap on retained text. A chatty process across a long run would otherwise grow\n * this without limit. Dropping from the FRONT keeps the recent output — which\n * is what a wait is about to match — and a pattern spanning a megabyte of\n * output is not a pattern anybody wrote.\n */\nconst MAX_BUFFER = 1_000_000;\n\nexport type TranscriptWaitResult =\n | { status: \"matched\"; text: string; match: RegExpMatchArray }\n | { status: \"timeout\"; text: string }\n | { status: \"exited\"; text: string; exitCode: number; signal?: string };\n\nexport class TerminalTranscript {\n /** Stripped, complete text not yet consumed by a wait. */\n private text = \"\";\n\n /** Raw bytes held back because they may be the start of an escape sequence. */\n private tail = \"\";\n\n private readonly waiters = new Set<() => void>();\n\n /** Feed raw terminal output in. Safe to call with any chunking. */\n append(chunk: string): void {\n this.tail += chunk;\n\n const safe = this.safeLength();\n if (safe > 0) {\n this.text += this.tail.slice(0, safe).replace(ANSI, \"\");\n this.tail = this.tail.slice(safe);\n }\n\n if (this.text.length > MAX_BUFFER) {\n this.text = this.text.slice(this.text.length - MAX_BUFFER);\n }\n\n for (const wake of [...this.waiters]) wake();\n }\n\n /**\n * How much of `tail` can be stripped now.\n *\n * Everything, unless the final `ESC` has not yet been terminated — in which\n * case processing stops there and resumes when the rest arrives.\n */\n private safeLength(): number {\n const lastEsc = Math.max(this.tail.lastIndexOf(ESC), this.tail.lastIndexOf(CSI));\n if (lastEsc === -1) return this.tail.length;\n\n // A complete sequence starting there means nothing is pending.\n ANSI.lastIndex = lastEsc;\n const match = ANSI.exec(this.tail);\n ANSI.lastIndex = 0;\n if (match && match.index === lastEsc) return this.tail.length;\n\n // Unterminated, but long enough that it is not really an escape.\n if (this.tail.length - lastEsc > MAX_PENDING_ESCAPE) return this.tail.length;\n\n return lastEsc;\n }\n\n /** Unconsumed output, escape sequences removed. */\n peek(): string {\n return this.text;\n }\n\n /** Drop everything currently buffered — used before typing a new command. */\n clear(): void {\n this.text = \"\";\n this.tail = \"\";\n }\n\n /**\n * Wait until `pattern` matches the unconsumed text.\n *\n * Checks what has ALREADY arrived before subscribing, because the common case\n * is that the process answered while the previous node was still finishing.\n *\n * `exited` is raced deliberately. Without it, a shell that dies reports as\n * \"timed out waiting for X\" — sending whoever reads it to lengthen a timeout\n * for a process that is not running. Naming the exit is the difference\n * between a diagnosis and a wrong lead.\n */\n waitFor(\n pattern: RegExp,\n options: { timeoutMs: number; exited?: Promise<{ exitCode: number; signal?: string }> },\n ): Promise<TranscriptWaitResult> {\n return new Promise<TranscriptWaitResult>((resolve) => {\n let settled = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const finish = (result: TranscriptWaitResult) => {\n if (settled) return;\n settled = true;\n this.waiters.delete(check);\n if (timer) clearTimeout(timer);\n resolve(result);\n };\n\n const check = () => {\n // A global or sticky pattern carries `lastIndex` between calls, so it\n // would start each attempt part-way through a buffer it has not read.\n pattern.lastIndex = 0;\n const match = pattern.exec(this.text);\n if (!match) return;\n\n // `|| 1` so a pattern that can match empty still makes progress rather\n // than consuming nothing and matching the same position forever.\n const through = match.index + (match[0].length || 1);\n const text = this.text.slice(0, through);\n this.text = this.text.slice(through);\n finish({ status: \"matched\", text, match });\n };\n\n this.waiters.add(check);\n check();\n if (settled) return;\n\n if (options.timeoutMs > 0) {\n timer = setTimeout(() => {\n const text = this.text;\n this.text = \"\";\n finish({ status: \"timeout\", text });\n }, options.timeoutMs);\n // Never hold a Node process open just to time out a wait nobody wants.\n (timer as unknown as { unref?: () => void }).unref?.();\n }\n\n options.exited?.then(\n (exit) => {\n // No re-check here, deliberately. `append` wakes every waiter the\n // instant data lands, so a process that prints its answer and then\n // exits has already matched by the time this runs — `settled` is\n // true and this returns. A re-check looked like it was guarding that\n // race and was in fact unreachable, which is worse than absent: it\n // read as a guarantee while the actual guarantee lived elsewhere.\n if (settled) return;\n const text = this.text;\n this.text = \"\";\n finish({ status: \"exited\", text, exitCode: exit.exitCode, signal: exit.signal });\n },\n () => {},\n );\n });\n }\n}\n","import { getTerminalHost, type TerminalSession, type TerminalSessionSpec } from \"../registry/capabilities\";\nimport { TerminalTranscript } from \"./terminal-transcript\";\nimport type { FlowGraph, FlowNode } from \"../types\";\n\n/**\n * One terminal per terminal lane, for the length of a run.\n *\n * ## The lifetime, and why it is not per-node\n *\n * A terminal node is only useful if the process it talks to is the SAME one the\n * last node talked to. `cd` has to persist; an agent TUI has to still be\n * running with its conversation intact. A session opened per node would give\n * every node a fresh shell and quietly turn a sequence of steps into a series\n * of unrelated ones — each individually correct, the whole thing meaningless.\n *\n * So the session is keyed on the LANE, opened lazily by the first node inside\n * it, and closed once when the run ends. A graph that never reaches a terminal\n * node spawns no process at all, which is what makes it safe for the lane to\n * exist on a canvas that mostly does other things.\n *\n * ## Why membership is `parentId`\n *\n * It is what the canvas already means by \"inside\", and it already persists into\n * the WorkflowSchema — so a headless runtime resolves exactly the grouping a\n * person drew, with no second association to keep in step. The alternative, a\n * lane id typed into each node's config, is the same fact in two places and\n * would drift the first time somebody dragged a node out of a lane.\n *\n * Nesting is followed to the nearest terminal lane, so an ordinary lane inside\n * a terminal lane still resolves — grouping for looks should not change which\n * terminal a node talks to.\n */\nexport class TerminalSessions {\n private readonly open = new Map<string, Promise<TerminalSession>>();\n\n private readonly laneOf = new Map<string, string | null>();\n\n private readonly transcripts = new Map<string, TerminalTranscript>();\n\n private readonly listening = new Map<string, () => void>();\n\n constructor(private readonly graph: FlowGraph) {}\n\n /**\n * The terminal lane a node belongs to, or null.\n *\n * Walks up `parentId` rather than checking only the immediate parent, and\n * caches per node id — a graph is walked once per run, and the answer cannot\n * change while it runs.\n */\n laneFor(nodeId: string, isTerminalLane: (node: FlowNode) => boolean): string | null {\n const cached = this.laneOf.get(nodeId);\n if (cached !== undefined) return cached;\n\n const byId = new Map(this.graph.nodes.map((n) => [n.id, n]));\n const seen = new Set<string>();\n\n let current = byId.get(nodeId);\n let answer: string | null = null;\n\n while (current) {\n // A cycle in `parentId` is malformed rather than impossible — a dragged\n // node with a stale parent can produce one — and walking it forever would\n // hang the run rather than fail it.\n if (seen.has(current.id)) break;\n seen.add(current.id);\n\n if (current.id !== nodeId && isTerminalLane(current)) {\n answer = current.id;\n break;\n }\n\n const parentId = (current as unknown as { parentId?: string }).parentId;\n current = parentId ? byId.get(parentId) : undefined;\n }\n\n this.laneOf.set(nodeId, answer);\n return answer;\n }\n\n /**\n * The session for a lane, opening it on first use.\n *\n * The PROMISE is cached, not the resolved session. Two nodes cannot run\n * concurrently in the current engine, but a caller that awaits a\n * half-finished open would otherwise start a second process — and two shells\n * where a graph says one is the failure this class exists to prevent, arriving\n * only under concurrency and therefore only sometimes.\n */\n session(laneId: string, spec: TerminalSessionSpec): Promise<TerminalSession> {\n const existing = this.open.get(laneId);\n if (existing) return existing;\n\n const host = getTerminalHost();\n\n if (!host) {\n // Named as a MISSING HOST rather than a failed open. A node in a terminal\n // lane with no host registered is a configuration problem — the desktop\n // app did not install one — and reporting it as \"the terminal failed\"\n // sends someone to debug a process that was never started.\n const failed = Promise.reject(\n new Error(\n \"No terminal host is registered. A terminal lane needs one — call registerTerminalHost() \"\n + \"from the desktop app, or install @particle-academy/fancy-flow/terminal/fancy-term-host.\",\n ),\n );\n // Cached so every node in the lane fails the same way rather than the\n // first one failing and the rest re-asking a question already answered.\n this.open.set(laneId, failed);\n // Nothing awaits this until a node does; keep node from warning meanwhile.\n failed.catch(() => {});\n return failed;\n }\n\n // Subscribed the moment the session resolves, not when a node first waits.\n //\n // A process answers on its own schedule, and the node that types at it and\n // the node that reads the reply are two separate steps. Anything printed in\n // between is unrecoverable if the buffer starts when the WAIT does — so a\n // fast process would be missed and a slow one caught, which is the same bug\n // presenting as flakiness rather than as a bug.\n const opening = Promise.resolve(host.open(spec)).then((session) => {\n const transcript = this.transcriptFor(laneId);\n this.listening.set(laneId, session.onData((chunk) => transcript.append(chunk)));\n return session;\n });\n\n this.open.set(laneId, opening);\n opening.catch(() => {});\n return opening;\n }\n\n /**\n * The accumulated output for a lane.\n *\n * Created on demand and kept for the run, so it exists before the session\n * resolves and survives every node that reads it. Consuming is the reader's\n * job — see `TerminalTranscript.waitFor`.\n */\n transcriptFor(laneId: string): TerminalTranscript {\n const existing = this.transcripts.get(laneId);\n if (existing) return existing;\n\n const created = new TerminalTranscript();\n this.transcripts.set(laneId, created);\n return created;\n }\n\n /** True once a lane has a session — used to avoid opening one during teardown. */\n isOpen(laneId: string): boolean {\n return this.open.has(laneId);\n }\n\n /**\n * Close every session this run opened.\n *\n * Every close is attempted even if one throws: a host that fails to close one\n * PTY must not strand the others, which would leave processes alive after the\n * run reported that it had finished. Errors are returned rather than thrown,\n * because teardown runs in a `finally` and throwing there would replace the\n * run's real error with a cleanup error.\n */\n async closeAll(): Promise<Error[]> {\n const errors: Error[] = [];\n\n for (const [laneId, pending] of this.open) {\n try {\n // Unsubscribe BEFORE closing. A host that emits a final chunk while\n // shutting down would otherwise append to a transcript nobody will read\n // again, and a listener outliving its session is how a closed terminal\n // keeps a run's objects alive.\n this.listening.get(laneId)?.();\n this.listening.delete(laneId);\n\n const session = await pending;\n await session.close();\n } catch (e) {\n errors.push(e instanceof Error ? e : new Error(`${laneId}: ${String(e)}`));\n }\n }\n\n this.open.clear();\n this.listening.clear();\n this.transcripts.clear();\n return errors;\n }\n}\n\n/** The spec a terminal lane node declares. */\nexport function specForLane(lane: FlowNode): TerminalSessionSpec {\n const config = ((lane.data as { config?: Record<string, unknown> } | undefined)?.config ?? {}) as Record<\n string,\n unknown\n >;\n\n const text = (key: string): string | undefined => {\n const value = config[key];\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n };\n\n const env = config.env;\n\n return {\n command: text(\"command\"),\n cwd: text(\"cwd\"),\n env:\n env && typeof env === \"object\" && !Array.isArray(env)\n ? Object.fromEntries(\n Object.entries(env as Record<string, unknown>).map(([k, v]) => [k, String(v)]),\n )\n : undefined,\n };\n}\n","import type { WorkflowInput } from \"../types\";\n\n/**\n * Resolving what a caller passed against what a workflow declared.\n *\n * Kept in its own module, and deliberately a pure function over two plain\n * objects, because the PHP and Python runtimes implement the same rules and\n * `suites/flow/workflow-props` in `@particle-academy/fancy-conformance` is the\n * table all three run. A rule that lives inside a runner is a rule each runtime\n * re-derives; a rule that is a function over maps is one they can share a\n * fixture for.\n *\n * ## Every branch here exists to make a mistake LOUD\n *\n * The failure this replaces was silence. `initialInputs` was keyed by node id,\n * so a caller passed `{ t: { topic: \"otters\" } }` and had to know the trigger\n * was named `t`; and nothing declared what a workflow accepted, so a\n * misspelled key was not an error — the value sat unread, the node saw\n * nothing, and the run reported success with output that was quietly wrong.\n *\n * So: an unknown key fails, a missing required value fails, and a wrong type\n * fails. None of those is a warning. A warning on a queue worker is a line in a\n * log nobody opens.\n */\n\n/**\n * Why a resolution failed, in a vocabulary that is the same in every runtime.\n *\n * The MESSAGE is English prose and each runtime words it slightly differently,\n * which is fine for a human and useless for a shared fixture table. The CODE is\n * what `suites/flow/workflow-props` asserts, so parity is pinned on the\n * decision rather than on the phrasing — otherwise the three implementations\n * would be held to a translation instead of a behaviour.\n */\nexport type PropsErrorCode = \"unknown_input\" | \"missing_required\" | \"type_mismatch\";\n\n/** The outcome of checking a caller's props against a declaration. */\nexport type PropsResolution =\n | { ok: true; props: Record<string, unknown> }\n | { ok: false; code: PropsErrorCode; error: string };\n\n/**\n * The runtime type of a value, in the vocabulary a declaration uses.\n *\n * Arrays are checked before objects because `typeof []` is `\"object\"` and a\n * declaration that says `array` means a list — accepting `{}` there would be\n * the check passing while meaning nothing.\n */\nfunction typeOf(value: unknown): string {\n if (value === null) return \"null\";\n if (Array.isArray(value)) return \"array\";\n return typeof value;\n}\n\n/**\n * Check and fill a caller's props.\n *\n * Returns the resolved map — declared defaults filled in, nothing else added —\n * or the first error. One error rather than a list, because a run stops at the\n * first one anyway and a caller fixing a call wants the thing to fix, not a\n * report.\n */\nexport function resolveWorkflowProps(\n declared: WorkflowInput[] | undefined,\n passed: Record<string, unknown> | undefined,\n): PropsResolution {\n const inputs = declared ?? [];\n const given = passed ?? {};\n const byName = new Map(inputs.map((input) => [input.name, input]));\n\n // UNKNOWN KEYS FIRST, and this is the check the whole feature is for.\n //\n // A caller who misspells `topic` as `topik` has configured nothing, and\n // before this the run went ahead and looked fine. Checking it before\n // anything else means the error names what they typed rather than\n // complaining that the thing they thought they passed is missing.\n for (const name of Object.keys(given)) {\n if (!byName.has(name)) {\n const known = inputs.map((input) => input.name);\n const suffix = known.length === 0\n ? \"this workflow declares no inputs\"\n : `known inputs: ${known.join(\", \")}`;\n\n return {\n ok: false,\n code: \"unknown_input\",\n error: `Unknown workflow input \"${name}\" — ${suffix}.`,\n };\n }\n }\n\n const resolved: Record<string, unknown> = {};\n\n for (const input of inputs) {\n // `hasOwnProperty`, not a truthiness or `??` check. `0`, `false` and `\"\"`\n // are real values a caller meant to pass, and a default applied over them\n // is a silent override — a limit of 0 quietly becoming 10 is not an error\n // anybody sees.\n const supplied = Object.prototype.hasOwnProperty.call(given, input.name);\n const hasDefault = Object.prototype.hasOwnProperty.call(input, \"default\");\n\n if (!supplied) {\n if (hasDefault) {\n resolved[input.name] = input.default;\n continue;\n }\n\n if (input.required) {\n return {\n ok: false,\n code: \"missing_required\",\n error: `Missing required workflow input \"${input.name}\"${\n input.type ? ` (${input.type})` : \"\"\n }.`,\n };\n }\n\n // Not supplied, no default, not required — absent rather than\n // `undefined`, so `{{ $props.x }}` resolves to null on both runtimes\n // instead of one of them inventing a key.\n continue;\n }\n\n const value = given[input.name];\n\n // An undeclared type accepts anything. \"I am not asserting a shape\" must\n // not degrade into \"nothing is allowed\".\n if (input.type !== undefined) {\n const actual = typeOf(value);\n if (actual !== input.type) {\n return {\n ok: false,\n code: \"type_mismatch\",\n error: `Workflow input \"${input.name}\" expects ${input.type}, got ${actual}.`,\n };\n }\n }\n\n resolved[input.name] = value;\n }\n\n return { ok: true, props: resolved };\n}\n","import type {\n ExecutorRegistry,\n FlowEdge,\n FlowGraph,\n FlowNode,\n NodeExecutor,\n RunEvent,\n} from \"../types\";\n// Both modules are React-free by design — the `/engine` entry must not pull in\n// React. Import them directly rather than via the `registry` barrel, which\n// re-exports the RegistryNode component.\nimport { getNodeKind, kindIds } from \"../registry/registry\";\nimport { resolveNodePorts } from \"../registry/ports\";\nimport { RunIdentity, type RunIdentityJson } from \"./run-identity\";\nimport { TerminalSessions, specForLane } from \"./terminal-sessions\";\nimport { resolveWorkflowProps } from \"./workflow-props\";\n\nexport type RunOptions = {\n /** Stop the run after this many ms. Default: no timeout. */\n timeoutMs?: number;\n /** Abort signal — host can cancel the run. */\n signal?: AbortSignal;\n /** Initial inputs supplied to entry-point nodes (no incoming edges). */\n initialInputs?: Record<string, Record<string, unknown>>;\n /**\n * Values for the inputs the graph DECLARES, passed by name.\n *\n * The flat, node-id-free way to configure a run. `initialInputs` is keyed by\n * node id, so a caller had to know the trigger was called `t` and a rename\n * broke every caller while the graph stayed valid. Props are checked against\n * `graph.inputs`, so a misspelling fails the run instead of sitting unread.\n */\n props?: Record<string, unknown>;\n /**\n * Which ENTRY POINTS are live — the ids of nodes with NO incoming edges this\n * run should start from. Omit it and every entry point runs, exactly as\n * before the option existed.\n *\n * A graph may hold more than one trigger — a `manual_trigger` for\n * hand-testing beside the event trigger that runs it for real — and a trigger\n * has no inbound edges, which IS the readiness rule. So without this, every\n * trigger's branch runs on every run, whichever one fired. The triggers\n * themselves are harmless; everything DOWNSTREAM of the ones that did not\n * fire is not. A `user_input` stranded on the manual branch parks an\n * event-driven run to ask a person for data the event already supplied,\n * which from outside looks like the event trigger being ignored.\n *\n * Naming the live entry points makes the others INACTIVE, and the existing\n * \"at least one active inbound edge\" rule then skips everything reachable\n * only from them. No new routing logic.\n *\n * Three edges, each pinned by `flow/entry-points` in\n * `@particle-academy/fancy-conformance`:\n * - `undefined` is NOT `[]`. Unset runs every entry point; an empty array\n * says none is live and runs nothing.\n * - A node reachable from SEVERAL entry points still runs when any one of\n * them fires — one active inbound edge is enough, as always.\n * - Naming a node that HAS inbound edges names no entry point, so every real\n * entry is inactive and nothing runs. That falls out of the rule rather\n * than being special-cased; validate your ids if you want a typo to be\n * loud, because the runtime cannot tell one from a deliberate empty\n * selection.\n */\n entryNodes?: string[];\n /** Nesting depth — set by `subflow` when it runs a child graph. */\n depth?: number;\n /**\n * Who is running, so a writing node can derive a stable idempotency key.\n *\n * A bare string is taken as the run key. **Deliberately not defaulted:** a\n * minted-per-call key would change on every whole-run retry, which is exactly\n * the failure an idempotency key exists to prevent — so a host that has not\n * supplied one gets `ctx.run === undefined` and a connector that declines to\n * write blind, rather than a plausible-looking key that double-charges.\n */\n run?: RunIdentity | RunIdentityJson | string;\n /**\n * Outputs already checkpointed for this run, keyed by node id.\n *\n * A node present here is **republished, not re-executed** — its stored value\n * goes back onto the same ports, so downstream routing reproduces exactly\n * what it did the first time. This is what makes a per-node durable driver\n * possible without a second copy of the routing rules, and it is how the PHP\n * and Python runtimes have always resumed.\n */\n resumeOutputs?: Record<string, unknown>;\n};\n\nexport type RunResult = {\n ok: boolean;\n /** Outputs collected per node, keyed by node id. */\n outputs: Record<string, unknown>;\n /** Error captured if any node threw. */\n error?: string;\n};\n\n/**\n * runFlow — topological execution of a FlowGraph against an ExecutorRegistry.\n *\n * Each node runs once, when all upstream nodes have produced outputs on the\n * connected ports. Decision nodes (or any executor that returns `{ branch:\n * 'true' }`) can short-circuit specific output ports — only edges leaving\n * an \"active\" port propagate to downstream nodes.\n *\n * Cycles are detected and abort the run with an error.\n *\n * The `onEvent` callback receives a stream of `RunEvent`s — wire it to a\n * status feed, log panel, or store.\n */\nexport async function runFlow(\n graph: FlowGraph,\n executors: ExecutorRegistry,\n onEvent: (event: RunEvent) => void = () => {},\n options: RunOptions = {},\n): Promise<RunResult> {\n const { signal, initialInputs = {}, timeoutMs, depth = 0, resumeOutputs = {}, entryNodes } = options;\n const run = options.run === undefined ? undefined : RunIdentity.from(options.run);\n const outputs: Record<string, unknown> = {};\n const portValues = new Map<string, unknown>(); // key: `${nodeId}:${portId}`\n const completed = new Set<string>();\n const errors: string[] = [];\n\n // Topological order via Kahn's algorithm. We allow nodes to run as soon\n // as their incoming edges' source ports have produced values, so the\n // order here is just a deterministic baseline used for cycle detection.\n const order = topoSort(graph);\n if (order === null) {\n const msg = \"Cycle detected in flow graph — aborting.\";\n onEvent({ type: \"run-error\", error: msg });\n return { ok: false, outputs, error: msg };\n }\n\n // Props are checked BEFORE anything runs, and a failure aborts the run.\n //\n // Before a node executes, not after: a workflow whose third node needed a\n // value the caller misspelled would otherwise do two nodes' worth of real\n // work — sending, writing, charging — and only then discover the call was\n // malformed. Validation that happens after a side effect is not validation.\n const propsCheck = resolveWorkflowProps(graph.inputs, options.props);\n if (!propsCheck.ok) {\n onEvent({ type: \"run-error\", error: propsCheck.error });\n return { ok: false, outputs, error: propsCheck.error };\n }\n const props = propsCheck.props;\n const declaresProps = (graph.inputs?.length ?? 0) > 0;\n\n const incomingByNode = indexIncoming(graph.edges);\n\n // Terminal lanes. Constructed unconditionally and costing nothing until a\n // node inside one actually runs — a graph with no terminal lane never asks\n // for a host, so nothing spawns and nothing needs one registered.\n const sessions = new TerminalSessions(graph);\n const isTerminalLane = (candidate: FlowNode): boolean =>\n getNodeKind(candidate.type ?? \"\")?.name === \"@particle-academy/terminal_lane\";\n\n const terminalAccessorFor = (node: FlowNode) => {\n const laneId = sessions.laneFor(node.id, isTerminalLane);\n if (laneId === null) return undefined;\n\n const lane = graph.nodes.find((n) => n.id === laneId);\n if (!lane) return undefined;\n\n // Returned as a FUNCTION rather than an open session, so the terminal opens\n // on first USE rather than when a node in the lane starts. A node that\n // never touches its terminal never spawns one, which is what makes the\n // lane safe to draw around nodes that mostly do other things.\n return {\n session: () => sessions.session(laneId, specForLane(lane)),\n // Awaits the session first on purpose. A transcript handed out before\n // anything is feeding it would look perfectly healthy and match nothing,\n // and \"waited and nothing came\" is the hardest failure here to tell apart\n // from a process that is simply slow.\n transcript: async () => {\n await sessions.session(laneId, specForLane(lane));\n return sessions.transcriptFor(laneId);\n },\n };\n };\n\n const timer = timeoutMs ? setTimeout(() => errors.push(`Run timed out after ${timeoutMs}ms`), timeoutMs) : null;\n\n onEvent({ type: \"run-start\" });\n\n try {\n for (const node of order) {\n if (signal?.aborted) throw new Error(\"aborted\");\n if (errors.length) break;\n\n // A checkpointed node is republished, never re-executed. Publishing the\n // stored value back onto its own ports is what makes the resume exact:\n // the branch it took, the ports it lit and the inputs its successors\n // collect are all reproduced by the engine's own rules rather than by a\n // driver's recollection of them.\n if (Object.prototype.hasOwnProperty.call(resumeOutputs, node.id)) {\n const stored = resumeOutputs[node.id];\n outputs[node.id] = stored;\n const activated = activatedPorts(node, stored);\n for (const portId of activated.ports) {\n portValues.set(`${node.id}:${portId}`, activated.value);\n onEvent({ type: \"node-output\", nodeId: node.id, portId, value: activated.value });\n }\n completed.add(node.id);\n onEvent({ type: \"node-status\", nodeId: node.id, status: \"done\", text: \"resumed\" });\n continue;\n }\n\n const incoming = incomingByNode.get(node.id) ?? [];\n\n // An ENTRY POINT this run did not start from is inactive.\n //\n // A node with no inbound edges is unconditionally ready -- that IS the\n // readiness rule -- so a graph with two triggers ran both branches on\n // every run, whichever trigger actually fired. Marking the unnamed ones\n // inactive here lets the \"at least one active inbound edge\" test below\n // skip everything reachable only from them, with no new routing logic.\n //\n // Gates only nodes with NO incoming edges: a node further down the graph\n // is not an entry point, and its readiness is still decided by its edges.\n if (incoming.length === 0 && entryNodes !== undefined && !entryNodes.includes(node.id)) {\n onEvent({ type: \"node-status\", nodeId: node.id, status: \"idle\", text: \"skipped\" });\n continue;\n }\n\n // Run a node once any upstream branch reaches it. We iterate in\n // topological order, so by the time we reach this node every upstream\n // node has been processed — each incoming edge is therefore *settled*\n // (active or dead, never still-pending). Requiring ALL incoming edges to\n // be active wrongly skipped MERGE POINTS: when a Decision routes down one\n // branch, the other branch's edge stays dead forever, so an `every` check\n // skipped the shared continuation node and halted the run after the first\n // branch (#1). Run when AT LEAST ONE incoming edge is active —\n // collectInputs() only reads from the active ones. A genuine parallel\n // join still works: in topo order both of its inputs are already active.\n if (incoming.length > 0) {\n const anyActive = incoming.some((e) => portValues.has(`${e.source}:${e.sourceHandle ?? \"out\"}`));\n if (!anyActive) {\n onEvent({ type: \"node-status\", nodeId: node.id, status: \"idle\", text: \"skipped\" });\n continue;\n }\n }\n\n // Notes/annotations + layout (lane/pool) nodes are visual only — never\n // executed and never fed to runners. Their config (a note's text, a lane's\n // title) stays in the document for editors + MCP tools, but the engine\n // walks straight past them. Edges cross lanes freely, so grouping never\n // affects topology.\n const visualKind = getNodeKind(node.type ?? \"\");\n const isLayout = visualKind?.category === \"layout\";\n const isAnnotation = node.type === \"note\" || visualKind?.category === \"annotation\";\n if (isLayout || isAnnotation) {\n onEvent({\n type: \"node-status\",\n nodeId: node.id,\n status: \"idle\",\n text: isLayout ? \"lane\" : \"annotation\",\n });\n continue;\n }\n\n onEvent({ type: \"node-status\", nodeId: node.id, status: \"running\" });\n announce(onEvent, node, \"start\");\n\n const inputs = collectInputs(node, incoming, portValues, initialInputs, props, declaresProps);\n const exec = pickExecutor(executors, node);\n if (!exec) {\n // Name what was LOOKED FOR, not just what the node calls itself.\n //\n // This said `kind=${node.type}` — so a registry keyed under one of the\n // kind's other ids produced \"kind=manual_trigger is missing\" about a\n // kind that exists AND is registered, just under a different key. The\n // consumer who reported it reasonably read that as the kind being\n // absent and went looking for a missing package.\n // The wildcard is part of `executorLookupIds` now, so it is already in\n // the list — appending \"and the wildcard\" as well made the message name\n // it twice, and the test that reads the ids back out of the message\n // parsed the prose between the two quoted stars as an id.\n const tried = executorLookupIds(node);\n const msg = `No executor registered for kind=${node.type}`\n + ` — tried ${tried.map((id) => `\"${id}\"`).join(\", \")}`\n + `. Key your registry by one of those.`;\n errors.push(msg);\n onEvent({ type: \"node-status\", nodeId: node.id, status: \"error\", text: msg });\n onEvent({ type: \"log\", nodeId: node.id, level: \"error\", message: msg });\n break;\n }\n\n try {\n const result = await Promise.resolve(\n exec({\n node,\n inputs,\n abort: (reason) => { throw new Error(reason ?? \"aborted\"); },\n emit: onEvent,\n executors,\n depth,\n run,\n terminal: terminalAccessorFor(node),\n }),\n );\n outputs[node.id] = result;\n\n // Decide which output ports were activated. Three conventions:\n // 1) If result is `{ __port: \"out\", value: x }`, only that port emits.\n // 2) If result has `branch: <portId>`, only that port emits (decision sugar).\n // 3) Otherwise, the value is published on every declared output port.\n const activated = activatedPorts(node, result);\n for (const portId of activated.ports) {\n portValues.set(`${node.id}:${portId}`, activated.value);\n onEvent({ type: \"node-output\", nodeId: node.id, portId, value: activated.value });\n }\n completed.add(node.id);\n onEvent({ type: \"node-status\", nodeId: node.id, status: \"done\" });\n // Only on the success path, and deliberately so: a `stoppingMsg` of\n // \"Analysis complete\" emitted after a throw tells a human the opposite\n // of what happened, in the part of the UI they trust most. A failure\n // reports through node-status/log, which is what those exist for.\n announce(onEvent, node, \"end\");\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n errors.push(msg);\n onEvent({ type: \"node-status\", nodeId: node.id, status: \"error\", text: msg });\n onEvent({ type: \"log\", nodeId: node.id, level: \"error\", message: msg });\n break;\n }\n }\n } finally {\n if (timer) clearTimeout(timer);\n\n // Terminals close HERE, in the same `finally` that clears the timer, so\n // they go away on the error and abort paths too — not only when a run ends\n // tidily. A PTY that outlives its run is a process nobody is watching and\n // nothing will close.\n //\n // Failures are reported and swallowed rather than thrown: this is the\n // teardown path, and throwing would replace the run's real error with a\n // cleanup error, hiding what actually went wrong behind the consequence.\n for (const error of await sessions.closeAll()) {\n onEvent({ type: \"log\", level: \"warn\", message: `terminal close failed: ${error.message}` });\n }\n }\n\n const ok = errors.length === 0;\n onEvent({ type: \"run-end\", ok });\n return ok ? { ok, outputs } : { ok, outputs, error: errors[0] };\n}\n\nfunction indexIncoming(edges: FlowEdge[]): Map<string, FlowEdge[]> {\n const map = new Map<string, FlowEdge[]>();\n for (const e of edges) {\n const list = map.get(e.target) ?? [];\n list.push(e);\n map.set(e.target, list);\n }\n return map;\n}\n\nfunction topoSort(graph: FlowGraph): FlowNode[] | null {\n const inDegree = new Map<string, number>();\n for (const n of graph.nodes) inDegree.set(n.id, 0);\n for (const e of graph.edges) inDegree.set(e.target, (inDegree.get(e.target) ?? 0) + 1);\n const queue: string[] = [];\n for (const [id, d] of inDegree) if (d === 0) queue.push(id);\n const ordered: string[] = [];\n while (queue.length) {\n const id = queue.shift()!;\n ordered.push(id);\n for (const e of graph.edges) {\n if (e.source !== id) continue;\n const next = (inDegree.get(e.target) ?? 0) - 1;\n inDegree.set(e.target, next);\n if (next === 0) queue.push(e.target);\n }\n }\n if (ordered.length !== graph.nodes.length) return null;\n const byId = new Map(graph.nodes.map((n) => [n.id, n]));\n return ordered.map((id) => byId.get(id)!).filter(Boolean);\n}\n\nfunction collectInputs(\n node: FlowNode,\n incoming: FlowEdge[],\n portValues: Map<string, unknown>,\n initial: Record<string, Record<string, unknown>>,\n props: Record<string, unknown>,\n declaresProps: boolean,\n): Record<string, unknown> {\n const inputs: Record<string, unknown> = { ...(initial[node.id] ?? {}) };\n\n // ENTRY POINTS are seeded with the props by their bare names.\n //\n // This is what lets an existing graph keep working unchanged. A trigger that\n // reads `{{ topic }}` was fed by `initialInputs[triggerId].topic`; a caller\n // moving to props passes `{ topic }` and the node sees exactly what it saw\n // before. Only entry points, because a node in the middle of a graph reading\n // a bare `topic` would be shadowing whatever its upstream edge is called.\n //\n // Never clobbers: a value already seeded by the host is the host's.\n if (incoming.length === 0) {\n for (const [name, value] of Object.entries(props)) {\n if (!(name in inputs)) inputs[name] = value;\n }\n }\n for (const e of incoming) {\n const portId = e.targetHandle ?? \"in\";\n const key = `${e.source}:${e.sourceHandle ?? \"out\"}`;\n // A branch that never fired has no entry in portValues. Assigning its\n // `undefined` would CLOBBER the value the branch that DID fire already\n // contributed on this same handle — emptying every merge point downstream\n // of a decision, silently, with the run still reporting success.\n //\n // This is the other half of the merge-point bug above: that fix stopped the\n // shared continuation node being skipped, but it still arrived with nothing\n // whenever a later inactive edge happened to be last in `incoming`.\n if (!portValues.has(key)) continue;\n inputs[portId] = portValues.get(key);\n\n // ALSO address it by the SOURCE NODE'S ID, when the edge named no handle.\n //\n // Authors reach for node ids -- every graph tool addresses nodes that way,\n // so `{{ n2.text }}` is the first thing written, by people and far more\n // often by assistants generating graphs. That resolved to nothing, and\n // NOTHING FAILED: an unresolvable path yields \"\", so the node ran, the run\n // reported success, and the damage was output that was quietly wrong. A\n // consumer shipped a file named `document.md` containing the literal text\n // of its own template, on a green run (fancy-flow-php#8).\n //\n // `targetHandle` already covers this and stays the right mechanism for\n // reading something other than the immediate predecessor -- but it is set\n // on the EDGE, which is not where an author is looking while writing a\n // node's config. The model was not wrong; the obvious spelling meant\n // nothing.\n //\n // Only for edges that declared NO handle: an edge that named one said what\n // it meant, and a second key under the source id would quietly widen a\n // deliberate contract. `??=` so nothing already seeded -- by the host's\n // initialInputs or an earlier edge -- is ever clobbered.\n if (e.targetHandle == null && !(e.source in inputs)) {\n inputs[e.source] = portValues.get(key);\n }\n }\n\n // EVERY node gets `$props` — but ONLY when the workflow declares inputs.\n //\n // The first half is what makes props usable at depth. Seeding entry points\n // alone would mean a node six hops downstream had the value threaded through\n // every edge in between, and every hop is somewhere it can be dropped. It\n // costs nothing to resolve because `$props` is an ORDINARY KEY in the inputs\n // object: `resolvePath` already walks dot-paths against it, so\n // `{{ $props.topic }}` works with no change to any expression resolver in any\n // of the three runtimes.\n //\n // The second half is a CORRECTION, and the golden parity fixtures caught it.\n // An earlier draft wrote `$props` unconditionally, justified as \"so\n // `{{ $props.x }}` resolves to null rather than throwing\" — which is not\n // true. `resolvePath` returns null for any unresolvable path, so on a graph\n // declaring nothing the key changes no behaviour at all. What it DOES do is\n // add a key to every executor's inputs, on every graph, forever — which\n // showed up instantly as a diff in every stored golden.\n //\n // `ConnectorFacet::from` states the same rule for the same reason: a payload\n // gaining a key on every entry is a wire change for no gain, and the ABSENCE\n // of a key is already the honest way to say \"this one takes no props\".\n //\n // Keyed on the DECLARATION rather than on whether a value arrived: a workflow\n // whose inputs are all optional and all omitted still declared a contract, so\n // `$props` is present and empty.\n if (declaresProps) inputs.$props = props;\n\n return inputs;\n}\n\n/**\n * Every key a node's executor may legitimately be registered under, in\n * precedence order. **This is the resolution rule** — `pickExecutor` walks this\n * list and takes the first hit, and the failure message lists the same ids.\n *\n * That sharing is the point, and it used to be a claim rather than a fact: this\n * docblock already said \"shared by the lookup and by its failure message\" while\n * `pickExecutor` re-implemented the walk beside it. The two agreed until the\n * precedence changed, and then the message listed an id the lookup no longer\n * tried — sending a reader to check something that never happened, which the\n * comment correctly named as worse than listing nothing. **Prose next to a check\n * is not the check.** One list now, walked by both, so they cannot drift.\n *\n * The order, and why:\n *\n * 1. `node.id` — the per-node override. First so a graph can pin ONE node to a\n * stub without unbinding that kind for every other node using it.\n * 2. `node.type`, then every id its kind answers to — **if `node.type` names a\n * registered kind, it is authoritative and `data.kind` is not consulted at\n * all.** A node that says it is an `llm_call` must never quietly run another\n * kind's code; it fails closed instead.\n * 3. Otherwise `data.kind` and its kind's ids. A `node.type` naming no\n * registered kind is not a claim about behaviour — usually it is an xyflow\n * RENDERER type (`\"fancyNode\"`), which is ordinary practice, and then\n * `data.kind` is the only real answer. This branch also covers `type` absent.\n * 4. `\"*\"` — the wildcard, last, and a sentinel rather than a kind: it is never\n * expanded through the alias machinery, or every unmatched node would bind to\n * whatever a kind literally named `*` aliased to.\n *\n * Pinned as `flow/executor-resolution` in `@particle-academy/fancy-conformance`.\n */\nfunction executorLookupIds(node: FlowNode): string[] {\n const ids: string[] = [node.id];\n if (node.type) ids.push(node.type);\n\n const typeKind = node.type ? getNodeKind(node.type) : null;\n\n if (typeKind) {\n for (const id of kindIds(typeKind)) ids.push(id);\n } else {\n const declared = (node.data as { kind?: unknown } | undefined)?.kind;\n const kindName = typeof declared === \"string\" && declared !== \"\" ? declared : null;\n\n if (kindName) {\n ids.push(kindName);\n const dataKind = getNodeKind(kindName);\n if (dataKind) {\n for (const id of kindIds(dataKind)) ids.push(id);\n }\n }\n }\n\n ids.push(\"*\");\n\n return [...new Set(ids)];\n}\n\nfunction pickExecutor(\n executors: ExecutorRegistry,\n node: FlowNode,\n): NodeExecutor | undefined {\n // The whole rule lives in `executorLookupIds` -- see its docblock. Walking\n // that one list is what keeps the resolution and the failure message from\n // ever disagreeing about which keys were tried.\n //\n // The HOST registry is consulted first, and that order is the contract: a\n // kind ships an executor as a default, and a host that registers its own\n // takes over. Reversing it would make a builtin unoverridable.\n for (const id of executorLookupIds(node)) {\n if (executors[id]) return executors[id];\n }\n\n // Then the kind's own, for the kinds that ship one.\n //\n // This fallback did not exist, and `NodeKindDefinition.executor` was\n // therefore a field nothing read. `subflow` and `llm_router` have both\n // declared one since they were written, and both were unreachable through\n // `runFlow`: a consumer who called `registerBuiltinKinds()` and ran a graph\n // containing a subflow node got \"No executor registered for kind=subflow\"\n // about a kind that ships its executor in the same object as its schema.\n //\n // It survived because the two are unit-tested by calling the executor\n // directly — which proves the executor works and says nothing about whether\n // anything can reach it. A declared capability with no reader is the shape\n // this estate keeps finding, and the only reliable way to catch it is a test\n // that goes through the front door.\n return getNodeKind(node.type ?? \"\")?.executor;\n}\n\nfunction activatedPorts(node: FlowNode, result: unknown): { ports: string[]; value: unknown } {\n if (result && typeof result === \"object\") {\n const r = result as Record<string, unknown>;\n if (typeof r.__port === \"string\") {\n return { ports: [r.__port], value: r.value };\n }\n if (typeof r.branch === \"string\") {\n // `Object.hasOwn`, NOT `??`. The two are different questions:\n // no `value` key at all -> the whole result IS the payload (the case\n // this fallback exists for)\n // `value` present, null -> the payload is null; pass null on\n // `r.value ?? r` cannot tell them apart, so a branch whose payload was\n // null leaked the WRAPPER downstream -- every following node received\n // `{ branch, value }`, two fields no kind declares, while the fields it\n // does declare were absent. The reachable path is an upstream `transform`\n // whose dot-path did not resolve, which is exactly the silent-null case.\n // `Port.only`'s `?? null` never had it. All four runtimes shared this,\n // identically -- so no parity table could catch it; they agreed on being\n // wrong.\n return { ports: [r.branch], value: Object.prototype.hasOwnProperty.call(r, \"value\") ? r.value : r };\n }\n }\n // Resolve through the shared helper so the ports the runtime activates are\n // the same ones the canvas drew — including config-driven ports, which the\n // node's `data` does not carry. Falls back to a lone `out` when a node\n // declares nothing.\n const kind = getNodeKind((node.data as any)?.kind ?? node.type ?? \"\") ?? undefined;\n const declared = resolveNodePorts(node, kind).outputs?.map((p) => p.id);\n return { ports: declared?.length ? declared : [\"out\"], value: result };\n}\n\n/**\n * Emit a node's own status message for one phase of its execution, if it\n * declared one.\n *\n * Opt-in by absence: a node with no `startingMsg` / `stoppingMsg` says nothing,\n * because most nodes in a real graph are plumbing and narrating all of them\n * buries the two or three steps a person actually wants to follow.\n *\n * A message must be a non-empty string after trimming. An empty string is the\n * shape a cleared editor field takes, and a blank line in a progress feed is\n * indistinguishable from a real message that happens to render as nothing —\n * so it is treated as \"not set\" rather than as \"announce nothing visible\".\n */\nfunction announce(\n onEvent: (event: RunEvent) => void,\n node: FlowNode,\n phase: \"start\" | \"end\",\n): void {\n const data = node.data as { startingMsg?: unknown; stoppingMsg?: unknown } | undefined;\n const raw = phase === \"start\" ? data?.startingMsg : data?.stoppingMsg;\n if (typeof raw !== \"string\") return;\n\n const message = raw.trim();\n if (message === \"\") return;\n\n onEvent({ type: \"node-message\", nodeId: node.id, phase, message });\n}\n"]}