agent-state-language/asl
Composer 安装命令:
composer require agent-state-language/asl
包简介
A JSON-based domain-specific language for defining configurable, composable AI agent workflows
README 文档
README
A JSON-based domain-specific language for defining configurable, composable AI agent workflows.
Overview
Agent State Language extends the concepts of AWS Step Functions' Amazon States Language with agent-native primitives for:
- 🧠 Memory & Context - Persistent memory, sliding context windows
- 🔧 Tool Orchestration - Permissions, rate limits, sandboxing
- 👤 Human-in-the-Loop - Approval gates, feedback collection
- 💬 Multi-Agent Communication - Debates, delegation, consensus
- 💰 Cost Management - Token budgets, model fallbacks
- 🛡️ Guardrails - Input/output validation, content moderation
- 📊 Observability - Reasoning traces, execution logs
Quick Start
Installation
composer require agent-state-language/asl
Define a Workflow
Create workflow.asl.json:
{
"Comment": "Simple greeting workflow",
"StartAt": "Greet",
"States": {
"Greet": {
"Type": "Task",
"Agent": "GreeterAgent",
"Parameters": {
"name.$": "$.userName"
},
"End": true
}
}
}
Run It
<?php use AgentStateLanguage\Engine\WorkflowEngine; use AgentStateLanguage\Agents\AgentRegistry; $registry = new AgentRegistry(); $registry->register('GreeterAgent', new MyGreeterAgent()); $engine = WorkflowEngine::fromFile('workflow.asl.json', $registry); $result = $engine->run(['userName' => 'Alice']); echo $result->getOutput(); // "Hello, Alice!"
State Types
Core States (AWS ASL Compatible)
| State | Description |
|---|---|
Task |
Execute an agent with parameters |
Choice |
Conditional branching |
Map |
Iterate over arrays |
Parallel |
Execute branches concurrently |
Pass |
Transform data |
Wait |
Pause execution |
Succeed |
End successfully |
Fail |
End with failure |
Agent-Native States (ASL Extensions)
| State | Description |
|---|---|
Approval |
Human-in-the-loop gate |
Debate |
Multi-agent deliberation |
Checkpoint |
Save/resume point |
Agent-Native Extensions
Memory Block
{
"AnalyzeCode": {
"Type": "Task",
"Agent": "Analyzer",
"Memory": {
"Read": ["project_patterns", "user_preferences"],
"Write": { "Key": "analysis_results", "TTL": "7d" }
}
}
}
Context Block
{
"GenerateResponse": {
"Type": "Task",
"Agent": "Responder",
"Context": {
"Strategy": "sliding_window",
"MaxTokens": 8000,
"Priority": ["$.currentTask", "$.recentHistory"]
}
}
}
Tools Block
{
"Research": {
"Type": "Task",
"Agent": "Researcher",
"Tools": {
"Allowed": ["web_search", "read_file"],
"Denied": ["write_file", "execute_shell"],
"RateLimits": { "web_search": { "MaxPerMinute": 10 } }
}
}
}
Budget Block
{
"Comment": "Workflow with cost controls",
"Budget": {
"MaxTokens": 100000,
"MaxCost": "$5.00",
"OnExceed": "PauseAndNotify"
}
}
Approval State
{
"ReviewChanges": {
"Type": "Approval",
"Prompt": "Review the proposed changes",
"Options": ["approve", "reject", "modify"],
"Timeout": "24h",
"Next": "ApplyChanges"
}
}
Debate State
{
"DebateSolution": {
"Type": "Debate",
"Agents": ["ProAgent", "ConAgent", "JudgeAgent"],
"Topic.$": "$.proposal",
"Rounds": 3,
"Consensus": { "Required": true, "Arbiter": "JudgeAgent" }
}
}
Documentation
- 📖 Specification - Complete language specification
- 🚀 Getting Started - First steps guide
- 📚 Tutorials - Step-by-step learning path
- 📘 Guides - Best practices and patterns
- 📋 Reference - API and syntax reference
Examples
| Example | Description |
|---|---|
| Task Breakdown | Recursive task decomposition |
| Code Review | Multi-agent review with approval |
| Research Assistant | Web search and synthesis |
| Customer Support | Intent routing and escalation |
| Content Pipeline | Generation and moderation |
Tutorial Path
Core Tutorials
- Hello World - Your first workflow
- Simple Workflow - Sequential states
- Conditional Logic - Choice states
- Parallel Execution - Concurrent branches
- Recursive Workflows - Map iterations
- Memory & Context - State persistence
- Tool Orchestration - Tool permissions
- Human Approval - Human-in-the-loop
- Multi-Agent Debate - Agent collaboration
- Cost Management - Budget controls
- Error Handling - Retry and catch
- Building Skills - Composition patterns
claude-php-agent Integration
- Integrating Claude PHP Agent - Wrapper pattern for ASL
- Tool-Enabled Agent Workflows - Tools in workflows
- Multi-Agent Orchestration - Parallel agent execution
- Loop Strategies in Workflows - ReAct, Reflection, Plan-Execute
- RAG-Enhanced Workflows - Knowledge-augmented agents
Requirements
- PHP 8.1 or higher
- Composer
License
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please read our Contributing Guide for details.
Related Projects
- claude-php-agent - PHP agent framework with ReAct, Reflection, and Plan-Execute loops
- Claude PHP SDK - Low-level PHP SDK for Claude API
- AWS Step Functions - Inspiration for ASL
Integration with claude-php-agent
ASL can be combined with claude-php-agent for advanced AI agent workflows:
use AgentStateLanguage\Engine\WorkflowEngine; use AgentStateLanguage\Agents\AgentRegistry; use ClaudeAgents\Agent; use ClaudePhp\ClaudePhp; // Create a claude-php-agent wrapped for ASL $client = ClaudePhp::make(getenv('ANTHROPIC_API_KEY')); $agent = Agent::create($client) ->withSystemPrompt('You are a helpful assistant.') ->withTools([...]); // Register with ASL $registry = new AgentRegistry(); $registry->register('Assistant', new ClaudeAgentAdapter('Assistant', $agent)); // Run workflow with advanced agent capabilities $engine = WorkflowEngine::fromFile('workflow.asl.json', $registry); $result = $engine->run(['task' => 'Analyze this code...']);
See Tutorial 13: Integrating Claude PHP Agent for complete integration guide.
agent-state-language/asl 适用场景与选型建议
agent-state-language/asl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「DSL」 「workflow」 「Agent」 「state-machine」 「ai」 「orchestration」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 agent-state-language/asl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 agent-state-language/asl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 agent-state-language/asl 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Workflow for NetCommons Plugin
Feature complete, object oriented, composable, extendable Elasticsearch query DSL builder for PHP.
Elasticsearch DSL library
Custom laravel monolog logger for datadog logs management, both api and agent ways
Workflow logger
Expression executor, which allow to implement domain-specific language
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-20