PHP SDK for AgentSkills Runtime - Install, manage, and execute AI agent skills with built-in runtime support.
- 🚀 Easy Installation: One-command runtime installation
- 🛠️ CLI & Programmatic API: Use via command line or PHP code
- 🔍 Skill Discovery: Search and install skills from multiple sources
- ⚡ Built-in Runtime: Automatic runtime download and management
- 🔧 Multi-Platform: Support for Windows, macOS, and Linux
- 📦 PSR Compliant: Follows PHP-FIG standards
composer require opencangjie/skillscomposer global require opencangjie/skillsMake sure your global Composer bin directory is in your PATH:
- Windows:
%USERPROFILE%\AppData\Roaming\Composer\vendor\bin - macOS/Linux:
~/.composer/vendor/binor~/.config/composer/vendor/bin
git clone https://github.com/UCTooCom/agentskills-runtime.git
cd agentskills-runtime/sdk/php
composer install# Using global installation
skills install-runtime
# Using local installation
./vendor/bin/skills install-runtimeEdit the .env file in the runtime directory:
- Windows:
%USERPROFILE%\.agentskills\runtime\win-x64\release\.env - macOS/Linux:
~/.agentskills/runtime/<platform>-<arch>/release/.env
Add your AI model API key:
# Example: DeepSeek
MODEL_PROVIDER=deepseek
MODEL_NAME=deepseek-chat
DEEPSEEK_API_KEY=your_api_key_hereskills start# Search for skills
skills find "python"
# Install a skill
skills add https://github.com/user/skill-repo
# Execute a skill
skills run <skill-id>The SDK provides a command-line interface for managing skills and runtime.
# Install runtime
skills install-runtime [--runtime-version 0.0.16]
# Start runtime
skills start [--port 8080] [--host 127.0.0.1] [--foreground]
# Stop runtime
skills stop
# Check status
skills status# Search for skills
skills find <query> [--source github] [--limit 10]
# Install skills
skills add <source> [--branch main] [--tag v1.0.0]
# List installed skills
skills list [--page 1] [--limit 20]
# Get skill info
skills info <skill-id>
# Execute skills
skills run <skill-id> [--tool <tool-name>] [--params '{"key": "value"}']
# Remove skills
skills remove <skill-id>
# Initialize new skill project
skills init <name> [--directory ./skills]
# Check for updates
skills checkuse AgentSkills\SkillsClient;
use AgentSkills\ClientConfig;
// Create client with default settings
$client = new SkillsClient();
// Create client with custom configuration
$config = new ClientConfig(
baseUrl: 'http://127.0.0.1:8080',
authToken: 'your-token',
timeout: 30000,
);
$client = new SkillsClient($config);use AgentSkills\RuntimeManager;
use AgentSkills\RuntimeOptions;
$runtime = new RuntimeManager();
// Check if runtime is installed
if (!$runtime->isInstalled()) {
$runtime->downloadRuntime();
}
// Start runtime
$options = new RuntimeOptions(
port: 8080,
detached: true,
);
$runtime->start($options);
// Check status
$status = $runtime->status();
if ($status->running) {
echo "Runtime version: " . $status->version . "\n";
}
// Stop runtime
$runtime->stop();$result = $client->listSkills([
'limit' => 10,
'page' => 0,
]);
foreach ($result->skills as $skill) {
echo $skill->name . " v" . $skill->version . "\n";
}$result = $client->searchSkills([
'query' => 'python',
'source' => 'github',
'limit' => 10,
]);
foreach ($result->results as $skill) {
echo $skill->full_name . "\n";
echo $skill->description . "\n";
}use AgentSkills\SkillInstallOptions;
$options = new SkillInstallOptions(
source: 'https://github.com/user/skill-repo',
branch: 'main',
);
$result = $client->installSkill($options);
if ($result->isMultiSkillRepo()) {
// Handle multi-skill repository
foreach ($result->available_skills as $skill) {
echo $skill->name . "\n";
}
} else {
echo "Installed: " . $result->name . "\n";
}// Execute skill
$result = $client->executeSkill('skill-id', [
'param1' => 'value1',
]);
if ($result->success) {
echo $result->output . "\n";
} else {
echo "Error: " . $result->errorMessage . "\n";
}
// Execute specific tool
$result = $client->executeSkillTool('skill-id', 'tool-name', [
'param1' => 'value1',
]);$skill = $client->getSkill('skill-id');
echo $skill->name . "\n";
echo $skill->description . "\n";
echo $skill->version . "\n";
foreach ($skill->tools as $tool) {
echo "Tool: " . $tool->name . "\n";
echo " " . $tool->description . "\n";
}$result = $client->uninstallSkill('skill-id');
if ($result['success']) {
echo "Skill removed successfully\n";
}// Get skill config
$config = $client->getSkillConfig('skill-id');
// Set skill config
$client->setSkillConfig('skill-id', [
'option1' => 'value1',
]);use AgentSkills\defineSkill;
use AgentSkills\ToolDefinition;
use AgentSkills\ToolParameter;
use AgentSkills\ToolParameterType;
$skill = defineSkill([
'metadata' => [
'name' => 'my-skill',
'version' => '1.0.0',
'description' => 'My custom skill',
'author' => 'Your Name',
],
'tools' => [
new ToolDefinition(
name: 'my-tool',
description: 'A tool that does something',
parameters: [
new ToolParameter(
name: 'input',
paramType: ToolParameterType::String,
description: 'Input parameter',
required: true,
),
],
),
],
]);The SDK reads configuration from environment variables prefixed with SKILL_:
use AgentSkills\getConfig;
$config = getConfig();
// Returns array with keys like 'API_URL', 'AUTH_TOKEN', etc.use AgentSkills\handleApiError;
use AgentSkills\ApiError;
try {
$client->installSkill($options);
} catch (\Exception $e) {
$error = handleApiError($e);
echo "Error {$error->errno}: {$error->errmsg}\n";
}Before starting the runtime, you need to configure the AI model API key. The runtime requires an AI model to process skill execution and natural language understanding.
Edit the .env file in the runtime directory:
- Windows:
%USERPROFILE%\.agentskills\runtime\win-x64\release\.env - macOS/Linux:
~/.agentskills/runtime/<platform>-<arch>/release/.env
Add your AI model configuration (choose one provider):
# Option 1: StepFun (阶跃星辰)
MODEL_PROVIDER=stepfun
MODEL_NAME=step-1-8k
STEPFUN_API_KEY=your_stepfun_api_key_here
STEPFUN_BASE_URL=https://api.stepfun.com/v1
# Option 2: DeepSeek
MODEL_PROVIDER=deepseek
MODEL_NAME=deepseek-chat
DEEPSEEK_API_KEY=your_deepseek_api_key_here
# Option 3: 华为云 MaaS
MODEL_PROVIDER=maas
MAAS_API_KEY=your_maas_api_key_here
MAAS_BASE_URL=https://api.modelarts-maas.com/v2
MAAS_MODEL_NAME=qwen3-coder-480b-a35b-instruct
# Option 4: Sophnet
MODEL_PROVIDER=sophnet
SOPHNET_API_KEY=your_sophnet_api_key_here
SOPHNET_BASE_URL=https://www.sophnet.com/api/open-apis/v1Note: Without proper AI model configuration, the runtime will fail to start with an error like "Get env variable XXX_API_KEY error."
- PHP 8.1 or higher
- Composer 2.0 or higher
- Extensions: json, phar, zip
composer testcomposer analyzecomposer cs-check
composer cs-fixcomposer checkPlease see CONTRIBUTING.md for details.
MIT License - see LICENSE file for details.