Formats (TS, YAML, JSON)

Kortyx currently supports all three authoring formats.

FormatBest forNotes
TypeScriptapp codebasesbest DX, direct node imports
YAMLdeclarative workflow fileshuman-readable, comments
JSONgenerated/exported configsmachine-friendly

TypeScript

TS
import { defineWorkflow } from "kortyx"; import { chatNode } from "@/nodes/chat.node"; export const wf = defineWorkflow({ id: "general-chat", version: "1.0.0", nodes: { chat: { run: chatNode, params: {} }, }, edges: [ ["__start__", "chat"], ["chat", "__end__"], ], });

YAML

YAML
id: general-chat version: 1.0.0 nodes: chat: run: ../nodes/chat.node.ts#chatNode params: {} edges: - ["__start__", "chat"] - ["chat", "__end__"]

JSON

JSON
{ "id": "general-chat", "version": "1.0.0", "nodes": { "chat": { "run": "../nodes/chat.node.js#chatNode", "params": {} } }, "edges": [["__start__", "chat"], ["chat", "__end__"]] }

How loading works in current packages

  • @kortyx/core/loadWorkflow parses string | Buffer | object
  • JSON text starts with { / [ and is parsed as JSON
  • otherwise it is parsed as YAML (js-yaml)
  • @kortyx/runtime/createFileWorkflowRegistry scans these file extensions:
    • .workflow.ts, .workflow.mts, .workflow.js, .workflow.mjs
    • .workflow.json, .workflow.yml, .workflow.yaml