acpx/examples/flows/shell.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
849 B
TypeScript

import { compute, defineFlow, extractJsonObject, shell } from "acpx/flows";
type ShellInput = {
text?: string;
};
export default defineFlow({
name: "example-shell",
startAt: "transform",
nodes: {
transform: shell({
async exec({ input }) {
const text = (input as ShellInput).text ?? "hello from shell";
return {
command: process.execPath,
args: [
"-e",
`process.stdout.write(JSON.stringify({ original: ${JSON.stringify(text)}, upper: ${JSON.stringify(text.toUpperCase())} }))`,
],
};
},
parse: (result) => extractJsonObject(result.stdout),
statusDetail: "Run native shell-backed action",
}),
finalize: compute({
run: ({ outputs }) => outputs.transform,
}),
},
edges: [{ from: "transform", to: "finalize" }],
});