Workflow interface defines the structure and components of a workflow, including its execution environment, available tools and guards, event handlers, context, and state machine definition.
Structure
Server Configuration
Specifies the server configuration for executing the workflow. This defines how and where tools will be invoked during the workflow execution.
domain: The domain that Solmyr’s Deno environment will permit you to make requests to.toolWebhookUrl: The base URL that Solmyr will use as the prefix for invoking tools by URL.headers: HTTP headers to be included with every tool call.
Guards
Defines conditional checks that can be used within the workflow’s state machine. Each guard is a TypeScript expression that evaluates to a boolean.
Tools
Defines the tools available for use within the workflow. Tools can be either remote functions (invoked via HTTP) or local functions executed in the Deno environment.
- If the value is
null, Solmyr will calltoolWebhookUrl/toolNamewith the entire state as the body. - If the value is a string containing a TypeScript function, Solmyr will execute it locally.
Events
Defines the events that the workflow can handle, along with their expected parameters.
- If an event requires parameters, the value is a JSON Schema string describing the expected structure.
- Use
zodToJsonSchemato generate JSON Schema from Zod schemas for type safety.
Context
Defines the structure of the workflow’s context (state). This represents the data that persists throughout the workflow execution and can be modified by tools and events.
State Machine
The
machine property in our Workflow interface corresponds to XState’s machine configuration. While our structure is a subset of XState’s full capabilities, it’s compatible with XState’s core concepts.Defines the state machine that governs the workflow’s behavior.
initial: The name of the initial state when the workflow starts.states: A record of all possible states in the workflow.