Download the PHP package hardimpactdev/opencode-sdk-laravel without Composer
On this page you can find all versions of the php package hardimpactdev/opencode-sdk-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hardimpactdev/opencode-sdk-laravel
More information about hardimpactdev/opencode-sdk-laravel
Files in hardimpactdev/opencode-sdk-laravel
Package opencode-sdk-laravel
Short Description Laravel SDK for the OpenCode AI coding agent API
License MIT
Homepage https://github.com/hardimpactdev/opencode-sdk-laravel
Informations about the package opencode-sdk-laravel
OpenCode SDK for Laravel
A Laravel SDK for the OpenCode AI coding agent HTTP API, built with Saloon.
Requirements
- PHP 8.4+
- Laravel 11 or 12
Installation
The package auto-registers its service provider via Laravel's package discovery.
Configuration
Publish the config file:
Usage
Using the Facade
Using Dependency Injection
Without Laravel
Sessions
Sending Messages
Slash Commands
Session Operations
Permissions (Questions)
When OpenCode needs approval for tool usage (file edits, bash commands, etc.), permissions appear as events. Respond programmatically:
Event Streaming (SSE)
Monitor real-time state changes via Server-Sent Events:
Projects
Providers
Session Management
The SDK includes an Eloquent model (OpenCodeSession) and a SessionManager for tracking and managing session lifecycles in your application.
OpenCodeSession Model
SessionManager
The SessionManager provides session lifecycle management with assessment heuristics and Laravel event dispatching.
All lifecycle methods are idempotent — calling them on a session already in the target state is a no-op.
Tolerant Deserialization
The SDK handles unknown enum values from the API gracefully. Unknown part types, message roles, and tool statuses are mapped to Unknown enum cases instead of throwing exceptions:
Error Handling
DTO-returning methods (e.g. sessions()->get(), sessions()->messages()) throw on HTTP errors. Boolean-returning methods (e.g. sessions()->delete(), sessions()->abort()) return false on failure instead of throwing.
Feature Parity
Comparison with the official OpenCode SDKs (JS, Go).
Session
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| Create session | Y | Y | Y |
| List sessions | Y | Y | Y |
| Get session | Y | Y | Y |
| Update session | Y | - | Y |
| Delete session | Y | Y | Y |
| Abort session | Y | Y | Y |
| Send message (sync) | Y | Y | Y |
| Send message (async) | Y | - | - |
| Get messages | Y | Y | Y |
| Get single message | - | - | Y |
| Run slash command | Y | - | Y |
| Run shell command | - | - | Y |
| Init session | Y | Y | Y |
| Summarize session | Y | Y | Y |
| Revert session | Y | Y | Y |
| Unrevert session | Y | Y | Y |
| Share session | Y | Y | Y |
| Unshare session | Y | Y | Y |
| Get child sessions | - | - | Y |
Permissions
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| List pending | Y | - | - |
| Respond (once/always/reject) | Y | - | Y |
Events
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| SSE event stream | Y | Y | Y |
Providers
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| List providers + models | Y | Y | Y |
App
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| Get app info | - | Y | - |
| Init app | - | Y | - |
| Log | - | Y | Y |
| List modes | - | Y | - |
Config
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| Get config | - | Y | Y |
File
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| List files | - | - | Y |
| Read file | - | Y | Y |
| File status (git) | - | Y | Y |
Find
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| Find files | - | Y | Y |
| Find symbols | - | Y | Y |
| Find text | - | Y | Y |
Agent
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| List agents | - | - | Y |
Project
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| List projects | Y | - | Y |
| Current project | Y | - | Y |
| Update project | Y | - | - |
Session Management (Laravel-only)
| Feature | Laravel | JS | Go |
|---|---|---|---|
| OpenCodeSession Eloquent model | Y | - | - |
| SessionManager (lifecycle + assess) | Y | - | - |
| Laravel event dispatching | Y | - | - |
| Tolerant enum deserialization | Y | - | - |
Command
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| List commands | - | - | Y |
Path
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| Get paths | - | - | Y |
TUI
| Endpoint | Laravel | JS | Go |
|---|---|---|---|
| Append/clear/submit prompt | - | Y | Y |
| Open help/models/sessions/themes | - | Y | Y |
| Execute command | - | - | Y |
| Show toast | - | - | Y |
Testing
Static Analysis
Code Style
License
MIT
All versions of opencode-sdk-laravel with dependencies
illuminate/contracts Version ^11.0||^12.0||^13.0
illuminate/database Version ^11.0||^12.0||^13.0
saloonphp/saloon Version ^4.0
spatie/laravel-data Version ^4.0
spatie/laravel-package-tools Version ^1.16