@particle-academy/fancy-flow 0.15.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,15 +53,50 @@ type LlmClient = {
53
53
  /** Install the host's LLM client. Returns an unregister function. */
54
54
  declare function registerLlmClient(client: LlmClient): () => void;
55
55
  declare function getLlmClient(): LlmClient | null;
56
+ /**
57
+ * Why a workflow reference could not be resolved.
58
+ *
59
+ * `missing` and `version-mismatch` are deliberately distinct. Collapsing them
60
+ * into a bare null makes "no such workflow" indistinguishable from "that
61
+ * workflow exists, but it is not the one you pinned" — and the second wants an
62
+ * error naming both versions, because it is the interesting failure.
63
+ */
64
+ type WorkflowResolutionFailure = {
65
+ reason: "missing" | "version-mismatch";
66
+ /** The version the host actually holds, when it holds one. */
67
+ available?: number;
68
+ message?: string;
69
+ };
70
+ type WorkflowResolution = FlowGraph | WorkflowResolutionFailure | null;
56
71
  /**
57
72
  * Resolve a workflow reference to a runnable graph.
58
73
  *
59
74
  * `subflow` names another workflow rather than embedding it, so the host owns
60
- * where workflows live — a database, a file, an API. Returning null means "no
61
- * such workflow", which the node reports as an error rather than silently
62
- * running nothing.
75
+ * where workflows live — a database, a file, an API.
76
+ *
77
+ * ## Why `version` is here
78
+ *
79
+ * A workflow another workflow depends on is an INTERFACE, and interfaces need
80
+ * pins. Without a version, a parent goes on calling `invoice-triage`, someone
81
+ * edits that child, and the parent now runs different logic having reported
82
+ * success the whole time — correct-looking, no error, wrong behaviour. The same
83
+ * failure family as the 0.9.0 routing divergence.
84
+ *
85
+ * The parameter lives on the resolver rather than being encoded into the ref
86
+ * string (`invoice-triage@3`) because a stringly-typed protocol is one every
87
+ * host invents differently — the "three vocabularies for one node" problem.
88
+ *
89
+ * Raised by the MOIC Suite consumer, whose `workflow_ref` pins versions and
90
+ * fails loudly on mismatch. Their point: a host COULD NOT implement pinning
91
+ * before this, because the node had no way to ask and the resolver no way to
92
+ * receive.
93
+ *
94
+ * Returning `null` still means "no such workflow". Return a
95
+ * {@link WorkflowResolutionFailure} to distinguish a version mismatch.
63
96
  */
64
- type WorkflowResolver = (ref: string) => Promise<FlowGraph | null> | FlowGraph | null;
97
+ type WorkflowResolver = (ref: string, version?: number) => Promise<WorkflowResolution> | WorkflowResolution;
98
+ /** Narrow a resolver's return value to an explicit failure. */
99
+ declare function isResolutionFailure(value: WorkflowResolution): value is WorkflowResolutionFailure;
65
100
  /** Install the host's workflow resolver. Returns an unregister function. */
66
101
  declare function registerWorkflowResolver(resolver: WorkflowResolver): () => void;
67
102
  declare function getWorkflowResolver(): WorkflowResolver | null;
@@ -74,4 +109,4 @@ type CapabilityId = "llm" | "workflow_resolver" | "document";
74
109
  */
75
110
  declare function capabilityStatus(): Record<CapabilityId, boolean>;
76
111
 
77
- export { type CapabilityId as C, type LlmRouteRequest as L, type WorkflowResolver as W, type LlmClient as a, type LlmRoute as b, type LlmRouteChoice as c, capabilityStatus as d, getWorkflowResolver as e, registerWorkflowResolver as f, getLlmClient as g, registerLlmClient as r };
112
+ export { type CapabilityId as C, type LlmRouteRequest as L, type WorkflowResolution as W, type LlmClient as a, type LlmRoute as b, type LlmRouteChoice as c, type WorkflowResolutionFailure as d, type WorkflowResolver as e, capabilityStatus as f, getLlmClient as g, getWorkflowResolver as h, isResolutionFailure as i, registerWorkflowResolver as j, registerLlmClient as r };
@@ -53,15 +53,50 @@ type LlmClient = {
53
53
  /** Install the host's LLM client. Returns an unregister function. */
54
54
  declare function registerLlmClient(client: LlmClient): () => void;
55
55
  declare function getLlmClient(): LlmClient | null;
56
+ /**
57
+ * Why a workflow reference could not be resolved.
58
+ *
59
+ * `missing` and `version-mismatch` are deliberately distinct. Collapsing them
60
+ * into a bare null makes "no such workflow" indistinguishable from "that
61
+ * workflow exists, but it is not the one you pinned" — and the second wants an
62
+ * error naming both versions, because it is the interesting failure.
63
+ */
64
+ type WorkflowResolutionFailure = {
65
+ reason: "missing" | "version-mismatch";
66
+ /** The version the host actually holds, when it holds one. */
67
+ available?: number;
68
+ message?: string;
69
+ };
70
+ type WorkflowResolution = FlowGraph | WorkflowResolutionFailure | null;
56
71
  /**
57
72
  * Resolve a workflow reference to a runnable graph.
58
73
  *
59
74
  * `subflow` names another workflow rather than embedding it, so the host owns
60
- * where workflows live — a database, a file, an API. Returning null means "no
61
- * such workflow", which the node reports as an error rather than silently
62
- * running nothing.
75
+ * where workflows live — a database, a file, an API.
76
+ *
77
+ * ## Why `version` is here
78
+ *
79
+ * A workflow another workflow depends on is an INTERFACE, and interfaces need
80
+ * pins. Without a version, a parent goes on calling `invoice-triage`, someone
81
+ * edits that child, and the parent now runs different logic having reported
82
+ * success the whole time — correct-looking, no error, wrong behaviour. The same
83
+ * failure family as the 0.9.0 routing divergence.
84
+ *
85
+ * The parameter lives on the resolver rather than being encoded into the ref
86
+ * string (`invoice-triage@3`) because a stringly-typed protocol is one every
87
+ * host invents differently — the "three vocabularies for one node" problem.
88
+ *
89
+ * Raised by the MOIC Suite consumer, whose `workflow_ref` pins versions and
90
+ * fails loudly on mismatch. Their point: a host COULD NOT implement pinning
91
+ * before this, because the node had no way to ask and the resolver no way to
92
+ * receive.
93
+ *
94
+ * Returning `null` still means "no such workflow". Return a
95
+ * {@link WorkflowResolutionFailure} to distinguish a version mismatch.
63
96
  */
64
- type WorkflowResolver = (ref: string) => Promise<FlowGraph | null> | FlowGraph | null;
97
+ type WorkflowResolver = (ref: string, version?: number) => Promise<WorkflowResolution> | WorkflowResolution;
98
+ /** Narrow a resolver's return value to an explicit failure. */
99
+ declare function isResolutionFailure(value: WorkflowResolution): value is WorkflowResolutionFailure;
65
100
  /** Install the host's workflow resolver. Returns an unregister function. */
66
101
  declare function registerWorkflowResolver(resolver: WorkflowResolver): () => void;
67
102
  declare function getWorkflowResolver(): WorkflowResolver | null;
@@ -74,4 +109,4 @@ type CapabilityId = "llm" | "workflow_resolver" | "document";
74
109
  */
75
110
  declare function capabilityStatus(): Record<CapabilityId, boolean>;
76
111
 
77
- export { type CapabilityId as C, type LlmRouteRequest as L, type WorkflowResolver as W, type LlmClient as a, type LlmRoute as b, type LlmRouteChoice as c, capabilityStatus as d, getWorkflowResolver as e, registerWorkflowResolver as f, getLlmClient as g, registerLlmClient as r };
112
+ export { type CapabilityId as C, type LlmRouteRequest as L, type WorkflowResolution as W, type LlmClient as a, type LlmRoute as b, type LlmRouteChoice as c, type WorkflowResolutionFailure as d, type WorkflowResolver as e, capabilityStatus as f, getLlmClient as g, getWorkflowResolver as h, isResolutionFailure as i, registerWorkflowResolver as j, registerLlmClient as r };
@@ -3,7 +3,7 @@ import { runFlow } from './chunk-L4AX73Q6.js';
3
3
  import { resolveNodePorts, nodeConfig } from './chunk-TITD5W4Y.js';
4
4
  import { getNodeKind, categoryAccent, registerNodeKind, listNodeKinds, kindIds } from './chunk-U5F22BHV.js';
5
5
  import { RichInputPreview } from './chunk-F5RPRB7A.js';
6
- import { getWorkflowResolver, getLlmClient } from './chunk-BB45F6S3.js';
6
+ import { getWorkflowResolver, isResolutionFailure, getLlmClient } from './chunk-USL4FMFU.js';
7
7
  import { memo, useMemo, createElement } from 'react';
8
8
  import { jsxs, jsx } from 'react/jsx-runtime';
9
9
 
@@ -36,7 +36,14 @@ var subflowExecutor = async (ctx) => {
36
36
  `subflow depth limit reached (${maxDepth}) at "${ref}" \u2014 a workflow is referencing itself, directly or through a chain.`
37
37
  );
38
38
  }
39
- const child = await resolver(ref);
39
+ const pinned = config.version === void 0 || config.version === "" ? void 0 : Number(config.version);
40
+ if (pinned !== void 0 && !Number.isInteger(pinned)) {
41
+ ctx.abort(`subflow "${ref}" has a non-integer version pin (${String(config.version)}).`);
42
+ }
43
+ const resolved = await resolver(ref, pinned);
44
+ const child = isResolutionFailure(resolved) ? ctx.abort(
45
+ resolved.reason === "version-mismatch" ? resolved.message ?? `subflow "${ref}" is pinned to version ${pinned}, but the host has ${resolved.available ?? "a different version"}.` : resolved.message ?? `subflow could not resolve workflow "${ref}"`
46
+ ) : resolved;
40
47
  if (!child) ctx.abort(`subflow could not resolve workflow "${ref}"`);
41
48
  const mode = subflowMode(config);
42
49
  const streaming = mode === "stream" || mode === "both";
@@ -226,15 +233,32 @@ function DefaultBody({ config, kind }) {
226
233
  ] })
227
234
  ] });
228
235
  }
236
+ var truncate = (s, n = 30) => s.length > n ? s.slice(0, n - 1) + "\u2026" : s;
237
+ function itemLabel(item) {
238
+ if (item && typeof item === "object") {
239
+ const o = item;
240
+ const name = o.label ?? o.name ?? o.key ?? o.title ?? o.id;
241
+ if (typeof name === "string" && name) return name;
242
+ if (typeof name === "number") return String(name);
243
+ return "item";
244
+ }
245
+ return String(item ?? "");
246
+ }
229
247
  function previewValue(v) {
230
- if (typeof v === "string") return v.length > 30 ? v.slice(0, 27) + "\u2026" : v;
248
+ if (v === null || v === void 0) return "";
249
+ if (typeof v === "string") return truncate(v);
231
250
  if (typeof v === "number" || typeof v === "boolean") return String(v);
232
- try {
233
- const j = JSON.stringify(v);
234
- return j.length > 30 ? j.slice(0, 27) + "\u2026" : j;
235
- } catch {
236
- return "[object]";
251
+ if (Array.isArray(v)) {
252
+ if (v.length === 0) return "none";
253
+ const names = v.slice(0, 3).map(itemLabel).filter(Boolean).join(", ");
254
+ const rest = v.length > 3 ? `, +${v.length - 3}` : "";
255
+ return names ? truncate(names + rest) : `${v.length} item${v.length === 1 ? "" : "s"}`;
256
+ }
257
+ if (typeof v === "object") {
258
+ const keys = Object.keys(v);
259
+ return keys.length === 0 ? "empty" : `${keys.length} field${keys.length === 1 ? "" : "s"}`;
237
260
  }
261
+ return "\u2026";
238
262
  }
239
263
  function casePorts(cases) {
240
264
  const byPort = /* @__PURE__ */ new Map();
@@ -419,6 +443,12 @@ var KINDS = [
419
443
  placeholder: "onboarding-v2",
420
444
  description: "Reference resolved by the host's registerWorkflowResolver()."
421
445
  },
446
+ {
447
+ type: "number",
448
+ key: "version",
449
+ label: "Pin to version",
450
+ description: "Optional. Leave blank to always run the child's current version. Pinning fails the run loudly if the child has moved on \u2014 without it, someone edits the child and this flow silently runs different logic."
451
+ },
422
452
  {
423
453
  type: "select",
424
454
  key: "mode",
@@ -987,5 +1017,5 @@ function buildNodeTypes() {
987
1017
  }
988
1018
 
989
1019
  export { BUILTIN_KINDS, DEFAULT_MAX_DEPTH, RegistryNode, buildNodeTypes, declaredRoutes, llmRouterExecutor, registerBuiltinKinds, resolveFallbackPort, subflowExecutor, subflowMode, subflowPorts };
990
- //# sourceMappingURL=chunk-ZQBWPYTI.js.map
991
- //# sourceMappingURL=chunk-ZQBWPYTI.js.map
1020
+ //# sourceMappingURL=chunk-532A5QA3.js.map
1021
+ //# sourceMappingURL=chunk-532A5QA3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/registry/subflow.ts","../src/registry/llm-router.ts","../src/registry/RegistryNode.tsx","../src/registry/builtin.ts","../src/registry/index.ts"],"names":[],"mappings":";;;;;;;;;;AAuBO,IAAM,iBAAA,GAAoB;AAI1B,SAAS,YAAY,MAAA,EAA8C;AACxE,EAAA,MAAM,OAAO,MAAA,CAAO,IAAA;AACpB,EAAA,OAAO,IAAA,KAAS,QAAA,IAAY,IAAA,KAAS,MAAA,GAAS,IAAA,GAAO,QAAA;AACvD;AAGO,SAAS,aAAa,MAAA,EAAiC;AAC5D,EAAA,MAAM,IAAA,GAAO,YAAY,MAAM,CAAA;AAC/B,EAAA,MAAM,QAAQ,CAAC,EAAE,IAAI,KAAA,EAAO,KAAA,EAAO,UAAU,CAAA;AAC7C,EAAA,IAAI,IAAA,KAAS,QAAA,IAAY,IAAA,KAAS,MAAA,EAAQ,KAAA,CAAM,OAAA,CAAQ,EAAE,EAAA,EAAI,QAAA,EAAU,KAAA,EAAO,QAAA,EAAU,CAAA;AACzF,EAAA,OAAO,KAAA;AACT;AAEO,IAAM,eAAA,GAAgC,OAAO,GAAA,KAAQ;AAC1D,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAAc,UAAU,EAAC;AACnD,EAAA,M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AAA,EAAQ,KAAA,EAAO,QAAO,EAAG,EAAE,OAAO,OAAA,EAAS,KAAA,EAAO,SAAS;AAAA,OAAE;AAAA,MACpH,EAAE,IAAA,EAAM,YAAA,EAAc,GAAA,EAAK,SAAA,EAAW,OAAO,SAAA,EAAW,QAAA,EAAU,IAAA,EAAM,OAAA,EAAS,aAAA;AAAc;AACjG;AAEJ,CAAA;AAGO,SAAS,oBAAA,GAA6B;AAC3C,EAAA,KAAA,MAAW,CAAA,IAAK,KAAA,EAAO,gBAAA,CAAiB,CAAC,CAAA;AAC3C;AAGO,IAAM,aAAA,GAAsC;;;AC5iB5C,SAAS,cAAA,GAA4B;AAC1C,EAAA,MAAM,MAAiB,EAAC;AACxB,EAAA,KAAA,MAAW,CAAA,IAAK,eAAc,EAAG;AAK/B,IAAA,KAAA,MAAW,MAAM,OAAA,CAAQ,CAAC,CAAA,EAAG,GAAA,CAAI,EAAE,CAAA,GAAI,YAAA;AAAA,EACzC;AACA,EAAA,OAAO,GAAA;AACT","file":"chunk-532A5QA3.js","sourcesContent":["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 (config.executors 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 },\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","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 { memo, useMemo } from \"react\";\nimport { Handle, Position, type NodeProps } from \"@xyflow/react\";\nimport type { FlowNode, NodeRunStatus, PortDescriptor } from \"../types\";\nimport { categoryAccent, getNodeKind } from \"./registry\";\nimport { nodeConfig, resolveNodePorts } from \"./ports\";\n\n/**\n * RegistryNode — generic node renderer that looks up the node's kind in\n * the registry and applies its `accent`/`label`/`icon`/`renderBody`. Used\n * as the xyflow node component for every registered kind.\n */\nfunction RegistryNodeInner(props: NodeProps<FlowNode>) {\n const kindName = (props.data as any).kind ?? props.type;\n const kind = useMemo(() => getNodeKind(kindName), [kindName]);\n\n if (!kind) {\n return (\n <div className=\"ff-node ff-node--unknown\">\n <div className=\"ff-node__header\" style={{ background: \"#71717a\" }}>\n <span className=\"ff-node__tag\">UNKNOWN</span>\n <span className=\"ff-node__label\">{kindName}</span>\n </div>\n <p className=\"ff-node__desc\">No registered kind for \"{kindName}\".</p>\n </div>\n );\n }\n\n const data = props.data;\n const status: NodeRunStatus = data.status ?? \"idle\";\n const accent = kind.accent ?? categoryAccent(kind.category);\n const resolved = resolveNodePorts(props, kind);\n const inputs: PortDescriptor[] = resolved.inputs ?? defaultInputs(kind.category);\n const outputs: PortDescriptor[] = resolved.outputs ?? defaultOutputs(kind.category);\n const config = nodeConfig(props);\n const label = data.label ?? kind.label;\n\n return (\n <div\n className={[\n \"ff-node\",\n `ff-node--status-${status}`,\n `ff-node--cat-${kind.category}`,\n props.selected ? \"ff-node--selected\" : \"\",\n ].filter(Boolean).join(\" \")}\n style={{ borderColor: props.selected ? accent : undefined }}\n >\n <header className=\"ff-node__header\" style={{ background: accent }}>\n {kind.icon && <span className=\"ff-node__icon\" aria-hidden>{kind.icon}</span>}\n <span className=\"ff-node__tag\">{kind.label.toUpperCase()}</span>\n <span className=\"ff-node__label\">{label}</span>\n {status !== \"idle\" && <span className={`ff-node__dot ff-node__dot--${status}`} aria-label={`status ${status}`} />}\n </header>\n\n {data.description && <p className=\"ff-node__desc\">{data.description}</p>}\n\n <div className=\"ff-node__body\">\n {kind.renderBody\n ? kind.renderBody({ nodeId: props.id, config: config as any, selected: props.selected ?? false })\n : <DefaultBody config={config} kind={kind.configSchema} />}\n </div>\n\n {data.statusText && <p className=\"ff-node__status-text\">{data.statusText}</p>}\n\n {inputs.map((p, i) => (\n <Handle\n key={p.id}\n type=\"target\"\n position={Position.Left}\n id={p.id}\n style={portStyle(i, inputs.length)}\n title={p.label ?? p.id}\n />\n ))}\n {outputs.map((p, i) => (\n <Handle\n key={p.id}\n type=\"source\"\n position={Position.Right}\n id={p.id}\n style={portStyle(i, outputs.length)}\n title={p.label ?? p.id}\n />\n ))}\n </div>\n );\n}\n\nexport const RegistryNode = memo(RegistryNodeInner);\n\nfunction defaultInputs(category: string): PortDescriptor[] {\n return category === \"trigger\" ? [] : [{ id: \"in\" }];\n}\nfunction defaultOutputs(category: string): PortDescriptor[] {\n return category === \"output\" ? [] : [{ id: \"out\" }];\n}\n\nfunction portStyle(i: number, total: number): React.CSSProperties {\n if (total <= 1) return {};\n const slot = (100 / (total + 1)) * (i + 1);\n return { top: `${slot}%` };\n}\n\n/**\n * DefaultBody — compact summary of the config values for nodes that\n * don't provide a custom renderBody. Skips fields that look empty.\n */\nfunction DefaultBody({ config, kind }: { config: Record<string, unknown>; kind?: import(\"./types\").ConfigField[] }) {\n const fields = kind ?? [];\n const visible = fields\n .map((f) => ({ field: f, value: config[f.key] }))\n .filter(({ value }) => value !== undefined && value !== \"\" && value !== null);\n if (visible.length === 0) {\n return <div className=\"ff-node__body-empty\">— configure in the panel</div>;\n }\n return (\n <ul className=\"ff-node__summary\">\n {visible.slice(0, 4).map(({ field, value }) => (\n <li key={field.key}>\n <span className=\"ff-node__summary-key\">{field.label}:</span>\n <span className=\"ff-node__summary-value\">{previewValue(value)}</span>\n </li>\n ))}\n {visible.length > 4 && <li className=\"ff-node__summary-more\">+ {visible.length - 4} more</li>}\n </ul>\n );\n}\n\nconst truncate = (s: string, n = 30): string => (s.length > n ? s.slice(0, n - 1) + \"…\" : s);\n\n/** A short, human name for one item in a repeater/list value. */\nfunction itemLabel(item: unknown): string {\n if (item && typeof item === \"object\") {\n const o = item as Record<string, unknown>;\n const name = o.label ?? o.name ?? o.key ?? o.title ?? o.id;\n if (typeof name === \"string\" && name) return name;\n if (typeof name === \"number\") return String(name);\n return \"item\";\n }\n return String(item ?? \"\");\n}\n\n/**\n * A node card's job is to read at a glance, not to be a data dump — so a value\n * is summarised, never `JSON.stringify`d. An array becomes its item names (or a\n * count), an object becomes a field count. Raw JSON on a card was the specific\n * thing to kill: `Fields: [{\"key\":\"answer\",…}]` reads as noise.\n */\nexport function previewValue(v: unknown): string {\n if (v === null || v === undefined) return \"\";\n if (typeof v === \"string\") return truncate(v);\n if (typeof v === \"number\" || typeof v === \"boolean\") return String(v);\n if (Array.isArray(v)) {\n if (v.length === 0) return \"none\";\n const names = v.slice(0, 3).map(itemLabel).filter(Boolean).join(\", \");\n const rest = v.length > 3 ? `, +${v.length - 3}` : \"\";\n return names ? truncate(names + rest) : `${v.length} item${v.length === 1 ? \"\" : \"s\"}`;\n }\n if (typeof v === \"object\") {\n const keys = Object.keys(v as object);\n return keys.length === 0 ? \"empty\" : `${keys.length} field${keys.length === 1 ? \"\" : \"s\"}`;\n }\n return \"…\";\n}\n","import { createElement } from \"react\";\nimport { registerNodeKind } from \"./registry\";\nimport { RichInputPreview } from \"./rich-input\";\nimport { llmRouterExecutor } from \"./llm-router\";\nimport { subflowExecutor, subflowPorts, DEFAULT_MAX_DEPTH } from \"./subflow\";\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 * 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 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 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 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 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\" },\n ],\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 // Preview the authored page inside a FauxClient frame, so the canvas shows\n // what the person hitting this step will actually see.\n renderBody: (ctx) => createElement(RichInputPreview, { config: (ctx.config ?? {}) as Record<string, unknown> }),\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 aliases: [\"branch\", \"@fancy/branch\"],\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 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 aliases: [\"for_each\", \"@fancy/for_each\"],\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 aliases: [\"merge\", \"@fancy/merge\"],\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 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 aliases: [\"transform\", \"@fancy/transform\"],\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 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 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 { type: \"credential\", key: \"credential\", label: \"API credential\", credentialType: \"llm_credential\" },\n ],\n },\n {\n name: \"@particle-academy/llm_router\",\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 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 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 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 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 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 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 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\n/** Register every built-in kind. Idempotent via the registry. */\nexport function registerBuiltinKinds(): void {\n for (const k of KINDS) registerNodeKind(k);\n}\n\n/** Exported list for hosts that want to selectively re-register. */\nexport const BUILTIN_KINDS: NodeKindDefinition[] = KINDS;\n","export type {\n ConfigField,\n TextConfigField,\n TextareaConfigField,\n NumberConfigField,\n SelectConfigField,\n SwitchConfigField,\n JsonConfigField,\n ExpressionConfigField,\n CredentialConfigField,\n RepeaterConfigField,\n RepeaterRowField,\n KeyValueConfigField,\n DocumentConfigField,\n NodeCategory,\n NodeKindDefinition,\n PortSpec,\n RenderBodyContext,\n} from \"./types\";\n\nexport { resolvePortSpec, resolveNodePorts, nodeConfig } from \"./ports\";\n\n/** Host capabilities — core declares the contract, the host supplies the impl. */\nexport {\n registerLlmClient,\n getLlmClient,\n registerWorkflowResolver,\n getWorkflowResolver,\n capabilityStatus,\n type LlmClient,\n type LlmRoute,\n type LlmRouteRequest,\n type LlmRouteChoice,\n type WorkflowResolver,\n type WorkflowResolution,\n type WorkflowResolutionFailure,\n type CapabilityId,\n isResolutionFailure,\n} from \"./capabilities\";\n\n/**\n * The human-pause contract — a run waiting for a person, not a failure.\n * `decodePause` is the one function a durable runner needs.\n */\nexport {\n pauseForHuman,\n encodePause,\n decodePause,\n isPause,\n PAUSE_PREFIX,\n LEGACY_PAUSE_PREFIXES,\n type PauseAwaiting,\n type PauseSignal,\n} from \"./pause\";\n\nexport { subflowExecutor, subflowPorts, subflowMode, DEFAULT_MAX_DEPTH, type SubflowMode } from \"./subflow\";\nexport { llmRouterExecutor, declaredRoutes, resolveFallbackPort } from \"./llm-router\";\n/** @deprecated Renamed to `llmRouterExecutor` — the id and label now match. */\nexport { llmRouterExecutor as llmBranchExecutor } from \"./llm-router\";\n\nexport {\n registerRichInputAdapter,\n getRichInputAdapter,\n isRichInputEnabled,\n onRichInputAdapterChanged,\n RichInputPreview,\n type RichInputAdapter,\n} from \"./rich-input\";\n\nexport {\n registerNodeKind,\n getNodeKind,\n resolveKindId,\n kindIds,\n listNodeKinds,\n onNodeKindsChanged,\n defaultConfigFor,\n validateConfig,\n categoryAccent,\n} from \"./registry\";\n\nexport { RegistryNode } from \"./RegistryNode\";\nexport { registerBuiltinKinds, BUILTIN_KINDS } from \"./builtin\";\n\nimport type { NodeTypes } from \"@xyflow/react\";\nimport { RegistryNode } from \"./RegistryNode\";\nimport { kindIds, listNodeKinds } from \"./registry\";\n\n/**\n * Build an xyflow `nodeTypes` map from the registry — every registered\n * kind gets `RegistryNode` as its renderer. Refresh manually via\n * `useNodeTypes()` (a hook that subscribes to registry changes).\n */\nexport function buildNodeTypes(): NodeTypes {\n const map: NodeTypes = {};\n for (const k of listNodeKinds()) {\n // Key on every id the kind answers to, not just the canonical one. xyflow\n // looks the renderer up by `node.type` BEFORE RegistryNode gets a chance to\n // resolve aliases, so a graph still carrying pre-namespace types would fall\n // through to the unknown-node placeholder.\n for (const id of kindIds(k)) map[id] = RegistryNode;\n }\n return map;\n}\n"]}
@@ -9,6 +9,9 @@ function registerLlmClient(client) {
9
9
  function getLlmClient() {
10
10
  return llmClient;
11
11
  }
12
+ function isResolutionFailure(value) {
13
+ return typeof value === "object" && value !== null && "reason" in value && value.reason !== void 0;
14
+ }
12
15
  var workflowResolver = null;
13
16
  function registerWorkflowResolver(resolver) {
14
17
  workflowResolver = resolver;
@@ -33,6 +36,6 @@ function capabilityStatus() {
33
36
  };
34
37
  }
35
38
 
36
- export { capabilityStatus, getLlmClient, getWorkflowResolver, registerLlmClient, registerWorkflowResolver };
37
- //# sourceMappingURL=chunk-BB45F6S3.js.map
38
- //# sourceMappingURL=chunk-BB45F6S3.js.map
39
+ export { capabilityStatus, getLlmClient, getWorkflowResolver, isResolutionFailure, registerLlmClient, registerWorkflowResolver };
40
+ //# sourceMappingURL=chunk-USL4FMFU.js.map
41
+ //# sourceMappingURL=chunk-USL4FMFU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/registry/capabilities.ts"],"names":[],"mappings":";AAwDA,IAAI,SAAA,GAA8B,IAAA;AAG3B,SAAS,kBAAkB,MAAA,EAA+B;AAC/D,EAAA,SAAA,GAAY,MAAA;AACZ,EAAA,OAAO,MAAM;AACX,IAAA,IAAI,SAAA,KAAc,QAAQ,SAAA,GAAY,IAAA;AAAA,EACxC,CAAA;AACF;AAEO,SAAS,YAAA,GAAiC;AAC/C,EAAA,OAAO,SAAA;AACT;AAqDO,SAAS,oBAAoB,KAAA,EAA+D;AACjG,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,QAAA,IAAY,KAAA,IACX,MAAoC,MAAA,KAAW,MAAA;AAEpD;AAEA,IAAI,gBAAA,GAA4C,IAAA;AAGzC,SAAS,yBAAyB,QAAA,EAAwC;AAC/E,EAAA,gBAAA,GAAmB,QAAA;AACnB,EAAA,OAAO,MAAM;AACX,IAAA,IAAI,gBAAA,KAAqB,UAAU,gBAAA,GAAmB,IAAA;AAAA,EACxD,CAAA;AACF;AAEO,SAAS,mBAAA,GAA+C;AAC7D,EAAA,OAAO,gBAAA;AACT;AAYO,SAAS,gBAAA,GAAkD;AAGhE,EAAA,IAAI,aAAA,GAAgB,KAAA;AACpB,EAAA,IAAI;AAEF,IAAA,aAAA,GAAgB,OAAA,CAAS,WAAmB,0BAA0B,CAAA;AAAA,EACxE,CAAA,CAAA,MAAQ;AACN,IAAA,aAAA,GAAgB,KAAA;AAAA,EAClB;AACA,EAAA,OAAO;AAAA,IACL,KAAK,SAAA,KAAc,IAAA;AAAA,IACnB,mBAAmB,gBAAA,KAAqB,IAAA;AAAA,IACxC,QAAA,EAAU;AAAA,GACZ;AACF","file":"chunk-USL4FMFU.js","sourcesContent":["import type { FlowGraph } from \"../types\";\n\n/**\n * Host capabilities — the services core nodes need but must never depend on.\n *\n * A node that imports a provider SDK forces every consumer to install it: a\n * workflow app that never calls a model should not inherit an LLM dependency.\n * So core declares the CONTRACT and the host supplies the implementation, the\n * same arrangement `renderDocumentField` already uses for documents.\n *\n * That keeps opinionated nodes in core without their opinions: `llm_branch`\n * ships the routing semantics, port derivation and config UI, while whichever\n * client the host registers — Prism, an OpenAI SDK, a local model, a fake in a\n * test — decides how the question actually gets asked.\n *\n * Registration is deliberately explicit and typed per capability rather than a\n * stringly-keyed bag, so a missing one is a clear error at the seam instead of\n * an undefined somewhere downstream.\n */\n\n// ── LLM ─────────────────────────────────────────────────────────────────────\n\nexport type LlmRoute = { port: string; description?: string };\n\nexport type LlmRouteRequest = {\n /** Optional framing for the decision. */\n system?: string;\n /** What the model is deciding about. */\n prompt: string;\n /** The ports it must choose between. */\n routes: LlmRoute[];\n provider?: string;\n model?: string;\n /** Host-resolved credential reference, never a raw key. */\n credential?: string;\n};\n\nexport type LlmRouteChoice = {\n /** Must be one of the requested route ports. */\n port: string;\n /** Why — carried down the chosen port so a run is explainable afterwards. */\n reason?: string;\n};\n\n/**\n * The only thing core asks of an LLM: given routes, pick one.\n *\n * Deliberately not a general chat interface. A narrow contract is one a host\n * can satisfy in a few lines over any SDK, and it keeps the choice\n * machine-checkable — an implementation should constrain the model to the\n * declared ports (structured output / enum) rather than parsing prose.\n */\nexport type LlmClient = {\n chooseRoute: (request: LlmRouteRequest) => Promise<LlmRouteChoice> | LlmRouteChoice;\n};\n\nlet llmClient: LlmClient | null = null;\n\n/** Install the host's LLM client. Returns an unregister function. */\nexport function registerLlmClient(client: LlmClient): () => void {\n llmClient = client;\n return () => {\n if (llmClient === client) llmClient = null;\n };\n}\n\nexport function getLlmClient(): LlmClient | null {\n return llmClient;\n}\n\n// ── Workflow resolution ─────────────────────────────────────────────────────\n\n/**\n * Why a workflow reference could not be resolved.\n *\n * `missing` and `version-mismatch` are deliberately distinct. Collapsing them\n * into a bare null makes \"no such workflow\" indistinguishable from \"that\n * workflow exists, but it is not the one you pinned\" — and the second wants an\n * error naming both versions, because it is the interesting failure.\n */\nexport type WorkflowResolutionFailure = {\n reason: \"missing\" | \"version-mismatch\";\n /** The version the host actually holds, when it holds one. */\n available?: number;\n message?: string;\n};\n\nexport type WorkflowResolution = FlowGraph | WorkflowResolutionFailure | null;\n\n/**\n * Resolve a workflow reference to a runnable graph.\n *\n * `subflow` names another workflow rather than embedding it, so the host owns\n * where workflows live — a database, a file, an API.\n *\n * ## Why `version` is here\n *\n * A workflow another workflow depends on is an INTERFACE, and interfaces need\n * pins. Without a version, a parent goes on calling `invoice-triage`, someone\n * edits that child, and the parent now runs different logic having reported\n * success the whole time — correct-looking, no error, wrong behaviour. The same\n * failure family as the 0.9.0 routing divergence.\n *\n * The parameter lives on the resolver rather than being encoded into the ref\n * string (`invoice-triage@3`) because a stringly-typed protocol is one every\n * host invents differently — the \"three vocabularies for one node\" problem.\n *\n * Raised by the MOIC Suite consumer, whose `workflow_ref` pins versions and\n * fails loudly on mismatch. Their point: a host COULD NOT implement pinning\n * before this, because the node had no way to ask and the resolver no way to\n * receive.\n *\n * Returning `null` still means \"no such workflow\". Return a\n * {@link WorkflowResolutionFailure} to distinguish a version mismatch.\n */\nexport type WorkflowResolver = (\n ref: string,\n version?: number,\n) => Promise<WorkflowResolution> | WorkflowResolution;\n\n/** Narrow a resolver's return value to an explicit failure. */\nexport function isResolutionFailure(value: WorkflowResolution): value is WorkflowResolutionFailure {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"reason\" in value &&\n (value as WorkflowResolutionFailure).reason !== undefined\n );\n}\n\nlet workflowResolver: WorkflowResolver | null = null;\n\n/** Install the host's workflow resolver. Returns an unregister function. */\nexport function registerWorkflowResolver(resolver: WorkflowResolver): () => void {\n workflowResolver = resolver;\n return () => {\n if (workflowResolver === resolver) workflowResolver = null;\n };\n}\n\nexport function getWorkflowResolver(): WorkflowResolver | null {\n return workflowResolver;\n}\n\n// ── Introspection ───────────────────────────────────────────────────────────\n\nexport type CapabilityId = \"llm\" | \"workflow_resolver\" | \"document\";\n\n/**\n * Which capabilities are currently satisfied.\n *\n * Exists so a host (or the CLI, or an agent over MCP) can answer \"what does\n * this graph need that I haven't wired?\" BEFORE a run fails halfway through.\n */\nexport function capabilityStatus(): Record<CapabilityId, boolean> {\n // Imported lazily to avoid dragging the React-dependent rich-input module\n // into the headless engine.\n let documentReady = false;\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, no-undef\n documentReady = Boolean((globalThis as any).__fancyFlowDocumentAdapter);\n } catch {\n documentReady = false;\n }\n return {\n llm: llmClient !== null,\n workflow_resolver: workflowResolver !== null,\n document: documentReady,\n };\n}\n"]}