defineProject
Use workflow.defineProject<Input, Output>() to define a business workflow. It returns the definition object unchanged; an executor or local CLI runtime performs the actual execution.
Signature
workflow.defineProject<Input, Output>(
workflow: Definition<Input, Output>,
): Definition<Input, Output>
Parameters
| Parameter | Type | Description |
|---|---|---|
workflow | Definition<Input, Output> | An executable workflow definition containing its name and main execution function. |
Definition fields
| Field | Type | Description |
|---|---|---|
name | string | A stable workflow name used by local runtime UI, logs, and structural analysis. |
run | (input, context) => Output | The main execution function. It usually calls workflow.runNode or workflow.runStreamNode. |
run arguments
| Name | Description |
|---|---|
input | Business input. In a Workflow project it comes from the selected entrypoint's createInput(context); in a Conversation project it comes from executor.createInput(context). |
context | The runtime-provided RunContext, including providers, KV, conversation, files, metadata, node hooks, and an abort signal. |
Return values
| Value | Type | Description |
|---|---|---|
| Workflow definition | Definition<Input, Output> | The original definition object, for an executor to reference. |
run result | Output | Read by the runtime during execution. Project output payloads must extend RunPayload. |
Execution flow
| Phase | Input | Result |
|---|---|---|
| Executor | CLI arguments or form values | Input |
Workflow run | Input and RunContext | Output |
| Runtime report | Output | Standard execution report and final payload |
Example
import type { RunPayload } from "steamharness";
interface Input {
message: string;
}
interface Output extends RunPayload {
items: Array<{
id: string;
title: string;
content: unknown;
contentType?: "markdown" | "text" | "json" | "audio";
collapsed?: boolean;
}>;
}
export const exampleProject = workflow.defineProject<Input, Output>({
name: "example",
async run(input, context) {
const parsed = await workflow.runNode(inputNode, input, context);
return workflow.runNode(outputNode, parsed, context);
},
});
Notes
| Rule | Description |
|---|---|
Do not import runtime APIs from "steamharness" | The platform injects the global workflow object into business workflows. |
Output must extend RunPayload | On success, return errCode: 0 and errMessage: "". |
| The runtime wraps exceptions | Unknown errors thrown from run are converted to HarnessError and included in the execution report. |