@kognitivedev/flows
v0.2.29
Published
Cloud flow SDK for Kognitive flow builder and execution APIs
Downloads
38
Maintainers
Readme
@kognitivedev/flows
Cloud flow SDK for Kognitive's panel-authored flow APIs.
Installation
bun add @kognitivedev/flowsUsage
@kognitivedev/flows exposes two API surfaces over the same project API key:
- published flow execution under
flows.* - flow authoring and management under
flows.management.*
Use a project API key for both:
import { createCloudFlow, KognitiveFlowsClient, map, nodes } from "@kognitivedev/flows";
const flows = new KognitiveFlowsClient({
baseUrl: "http://localhost:3001",
apiKey: process.env.KOGNITIVE_API_KEY,
});
const flow = await flows.flows.get("my-flow");
const result = await flows.flows.execute("my-flow", { text: "hello" });
const runs = await flows.flows.runs.list("my-flow");
const created = await flows.flows.management.create({
name: "Support Triage",
slug: "support-triage",
description: "Panel-authored cloud flow",
definition: {
nodes: [
{ id: "start", type: "start", label: "Start" },
{ id: "end", type: "end", label: "End" },
],
edges: [{ source: "start", target: "end" }],
},
});
const drafts = await flows.flows.management.list();
const current = await flows.flows.management.get("support-triage");
const updated = await flows.flows.management.update("support-triage", {
description: "Updated description",
});
await flows.flows.management.publish("support-triage");
await flows.flows.management.unpublish("support-triage");
await flows.flows.management.delete("support-triage");You can also build definitions with typed node factories:
const definition = createCloudFlow()
.add(
nodes.start({ id: "start" }),
nodes.agent({
id: "classify",
instructions: "Classify the request.",
prompt: "{{ input.text }}",
model: "openai/gpt-4o-mini",
outputKey: "classification",
}),
nodes.end({
id: "end",
responseMode: "mapping",
mappings: [
map.entry("result", "result", map.nodeOutput("classify")),
],
}),
)
.connect("start", "classify")
.connect("classify", "end")
.build();Auth Notes
flows.list,flows.get,flows.execute,flows.runs.*, andflows.resumetarget/api/cloud/flows/*.flows.management.*also targets/api/cloud/flows/*, using the same project API key auth model.- Management methods are slug-based for single-flow operations.
