e670047e6a
- add command auto-detects .ts vs .esm.js input - .ts: Bun.build → bundle + descriptor extraction + JSON Schema → .d.ts - .esm.js: requires .yaml alongside, .d.ts optional - JSON Schema → TypeScript type converter - hello-world example workflow - 63 tests pass, biome clean Closes #7 小橘 <xiaoju@shazhou.work>
32 lines
706 B
TypeScript
32 lines
706 B
TypeScript
import { createRoleModerator, END, type Role } from "@uncaged/workflow";
|
|
|
|
type Roles = {
|
|
greeter: { greeting: string };
|
|
};
|
|
|
|
export const descriptor = {
|
|
description: "A simple hello world workflow",
|
|
roles: {
|
|
greeter: {
|
|
description: "Generates a greeting",
|
|
schema: {
|
|
type: "object",
|
|
properties: { greeting: { type: "string" } },
|
|
required: ["greeting"],
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
const greeter: Role<Roles["greeter"]> = async (ctx) => ({
|
|
content: `Hello, ${ctx.start.content}`,
|
|
meta: { greeting: "Hello!" },
|
|
});
|
|
|
|
export default createRoleModerator<Roles>({
|
|
roles: { greeter },
|
|
moderator(ctx) {
|
|
return ctx.steps.length === 0 ? "greeter" : END;
|
|
},
|
|
});
|