acpx/examples/flows/echo.flow.ts
Onur Solmaz ead133cfb2
feat: validate flow definitions and require defineFlow (#219)
* docs: clarify structured flow design

* docs: require conventional PR titles

* docs: detail zod flow validation direction

* feat: validate flow definitions with zod

* fix: allow extension fields in flow validation

* fix: reject ambiguous flow edge shapes

* fix: improve flow validation errors

* fix: validate plain exported flows before permission checks

* style: format flow CLI imports

* fix: preserve staged flow assembly

* feat: require defineFlow for flow modules

* fix: keep flow runner validation structural

* fix: resolve acpx flows in test builds
2026-04-05 15:34:56 +02:00

31 lines
755 B
TypeScript

import { acp, compute, defineFlow, extractJsonObject } from "acpx/flows";
type EchoInput = {
request?: string;
};
export default defineFlow({
name: "example-echo",
startAt: "reply",
nodes: {
reply: acp({
async prompt({ input }) {
const request = (input as EchoInput).request ?? "Say hello in one short sentence.";
return [
"Return exactly one JSON object with this shape:",
"{",
' "reply": "short response"',
"}",
"",
`Request: ${request}`,
].join("\n");
},
parse: (text) => extractJsonObject(text),
}),
finalize: compute({
run: ({ outputs }) => outputs.reply,
}),
},
edges: [{ from: "reply", to: "finalize" }],
});