Define Workflows
The core contract lives in @kortyx/core and is exposed through kortyx.
TypeScript workflow (recommended)
TS
import { defineWorkflow } from "kortyx";
import { classifyNode } from "@/nodes/classify.node";
import { answerNode } from "@/nodes/answer.node";
export const supportWorkflow = defineWorkflow({
id: "support",
version: "1.0.0",
description: "Simple support flow",
nodes: {
classify: {
run: classifyNode,
params: { model: "google:gemini-2.5-flash" },
behavior: {
retry: { maxAttempts: 2, delayMs: 200 },
},
},
answer: {
run: answerNode,
params: {},
},
},
edges: [
["__start__", "classify"],
["classify", "answer", { when: "support.answer" }],
["answer", "__end__"],
],
});Node return shape
Nodes return a subset of NodeResult:
TS
return {
data: { key: "value" },
ui: { message: "Rendered to user" },
condition: "support.answer",
intent: "optional-routing-token",
transitionTo: "another-workflow-id",
};Important fields in practice:
data: merged into runtime state and forwarded as future inputui.message: emitted as a final message eventui.structured: emitted asstructured-datacondition/intent: used for conditional edge routingtransitionTo: triggers workflow handoff
Node behavior currently implemented
From WorkflowNodeBehavior and runtime code:
behavior.retry.maxAttemptsbehavior.retry.delayMsbehavior.checkpoint
Note: onError.mode exists in schema types but is not currently applied by createLangGraph.
Validation
You can validate directly:
TS
import { validateWorkflow } from "kortyx";
const result = validateWorkflow(candidate);
if (!result.ok) {
console.error(result.errors);
}