Skip to main content

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​

ParameterTypeDescription
workflowDefinition<Input, Output>An executable workflow definition containing its name and main execution function.

Definition fields​

FieldTypeDescription
namestringA stable workflow name used by local runtime UI, logs, and structural analysis.
run(input, context) => OutputThe main execution function. It usually calls workflow.runNode or workflow.runStreamNode.

run arguments​

NameDescription
inputBusiness input. In a Workflow project it comes from the selected entrypoint's createInput(context); in a Conversation project it comes from executor.createInput(context).
contextThe runtime-provided RunContext, including providers, KV, conversation, files, metadata, node hooks, and an abort signal.

Return values​

ValueTypeDescription
Workflow definitionDefinition<Input, Output>The original definition object, for an executor to reference.
run resultOutputRead by the runtime during execution. Project output payloads must extend RunPayload.

Execution flow​

PhaseInputResult
ExecutorCLI arguments or form valuesInput
Workflow runInput and RunContextOutput
Runtime reportOutputStandard 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​

RuleDescription
Do not import runtime APIs from "steamharness"The platform injects the global workflow object into business workflows.
Output must extend RunPayloadOn success, return errCode: 0 and errMessage: "".
The runtime wraps exceptionsUnknown errors thrown from run are converted to HarnessError and included in the execution report.