Workflow.execute()
.execute()
メソッドは、入力データを使ってステップを実行し、その出力を返します。これにより、ワークフロー内でデータを処理することができます。
使い方
const inputSchema = z.object({
inputValue: z.string(),
});
const myStep = createStep({
id: "my-step",
description: "Does something useful",
inputSchema,
outputSchema: z.object({
outputValue: z.string(),
}),
resumeSchema: z.object({
resumeValue: z.string(),
}),
suspendSchema: z.object({
suspendValue: z.string(),
}),
execute: async ({
inputData,
mastra,
getStepResult,
getInitData,
runtimeContext,
}) => {
const otherStepOutput = getStepResult(step2);
const initData = getInitData<typeof inputSchema>(); // typed as the input schema variable (zod schema)
return {
outputValue: `Processed: ${inputData.inputValue}, ${initData.startValue} (runtimeContextValue: ${runtimeContext.get("runtimeContextValue")})`,
};
},
});
パラメーター
params:
object
ステップを実行するための設定オブジェクト
z.infer<TInput>
ResumeSchema
(suspendPayload: any) => Promise<void>
object
object
Mastra
戻り値
result:
Promise<z.infer<TOutput>>
実行されたステップの出力に解決されるプロミス