SysProM
    Preparing search index...
    • Create a callable operation from a definition. The returned function validates input against the Zod schema before delegating to the implementation.

      Type Parameters

      • TInput extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
      • TOutput extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

      Parameters

      Returns DefinedOperation<TInput, TOutput>

      A callable function with .def, .inputSchema, and .outputSchema attached.

      If the input fails Zod validation.

      const myOp = defineOperation({
      name: "greet",
      description: "Say hello",
      input: z.object({ name: z.string() }),
      output: z.string(),
      fn: ({ name }) => `Hello, ${name}!`,
      });
      myOp({ name: "world" }); // => "Hello, world!"