Documentation Index
Fetch the complete documentation index at: https://superwire.dev/llms.txt
Use this file to discover all available pages before exploring further.
Laravel applications use the Superwire\Laravel\Workflow fluent API to send workflows to the executor.
Run a workflow from a file
use Superwire\Laravel\Workflow;
$result = Workflow::fromFile(resource_path('workflows/reply.wire'))
->inputs([
'message' => 'Write a short welcome message.',
])
->secrets([
'api_key' => config('services.openai.key'),
])
->run();
$output = $result->output;
Run a workflow from source
use Superwire\Laravel\Workflow;
$source = <<<'WIRE'
input {
message: string
}
secrets {
api_key: string
}
provider llm from openai {
endpoint: "https://api.openai.com/v1"
api_key: secrets.api_key
}
model fast from llm {
id: "gpt-4.1-mini"
}
agent reply {
model: model.fast
instruction: "Reply to {{ input.message }}"
output {
message: string
}
}
output {
message: agent.reply.message
}
WIRE;
$result = Workflow::fromSource($source)
->inputs(['message' => 'Hello'])
->secrets(['api_key' => config('services.openai.key')])
->run();
Stream workflow events
stream() yields ExecutorEvent instances.
use Superwire\Laravel\Workflow;
foreach (
Workflow::fromFile(resource_path('workflows/reply.wire'))
->inputs(['message' => 'Hello'])
->secrets(['api_key' => config('services.openai.key')])
->stream() as $event
) {
if ($event->output() !== null) {
$partialOrFinalOutput = $event->output();
}
if ($event->isTerminal()) {
break;
}
}
streamToResult() consumes the stream and returns the final WorkflowResult.
$result = Workflow::fromFile(resource_path('workflows/reply.wire'))
->inputs(['message' => 'Hello'])
->secrets(['api_key' => config('services.openai.key')])
->streamToResult();
Event helpers
An ExecutorEvent exposes:
$event->kind;
$event->agentName;
$event->event;
$event->isTerminal();
$event->output();
$event->toArray();
Known event kinds include workflow started, workflow planned, agent started, agent completed, tool call started, tool call completed, tool call failed, MCP call started, MCP call completed, MCP call failed, workflow completed, and workflow failed.
$validation = Workflow::fromFile(resource_path('workflows/reply.wire'))
->secrets(['api_key' => config('services.openai.key')])
->validate();
$formatted = Workflow::fromFile(resource_path('workflows/reply.wire'))
->format();
Map output into a class
mapInto() maps the final output into a PHP class. If the class has a static from() method, it is used. Otherwise, array output is passed as named constructor arguments.
final readonly class ReplyOutput
{
public function __construct(
public string $message,
) {}
}
$result = Workflow::fromFile(resource_path('workflows/reply.wire'))
->inputs(['message' => 'Hello'])
->secrets(['api_key' => config('services.openai.key')])
->mapInto(ReplyOutput::class)
->run();
$output = $result->output;
Testing with fakes
use Superwire\Laravel\Workflow;
Workflow::fake([
'message' => 'Fake workflow output.',
]);
$result = Workflow::fromFile(resource_path('workflows/reply.wire'))
->inputs(['message' => 'Hello'])
->secrets(['api_key' => 'test-key'])
->run();
Workflow::restoreFake();
API summary
Workflow::fromFile($path);
Workflow::fromSource($source);
$workflow->inputs([...]);
$workflow->secrets([...]);
$workflow->mapInto(SomeOutput::class);
$workflow->run();
$workflow->stream();
$workflow->streamToResult();
$workflow->validate();
$workflow->format();
Workflow::fake([...]);
Workflow::restoreFake();