waaseyaa / ai-agent
AI agent orchestration and tool execution for Waaseyaa
Requires
- php: >=8.5
- symfony/messenger: ^7.0
- symfony/uid: ^7.0
- waaseyaa/access: ^0.1.0-alpha.188
- waaseyaa/ai-observability: ^0.1.0-alpha.188
- waaseyaa/ai-schema: ^0.1.0-alpha.188
- waaseyaa/ai-tools: ^0.1.0-alpha.188
- waaseyaa/api: ^0.1.0-alpha.188
- waaseyaa/database-legacy: ^0.1.0-alpha.188
- waaseyaa/entity: ^0.1.0-alpha.188
- waaseyaa/entity-storage: ^0.1.0-alpha.188
- waaseyaa/foundation: ^0.1.0-alpha.188
- waaseyaa/http-client: ^0.1.0-alpha.188
Requires (Dev)
- phpunit/phpunit: ^10.5
- dev-main / 0.1.x-dev
- v0.1.0-alpha.188
- v0.1.0-alpha.187
- v0.1.0-alpha.186
- v0.1.0-alpha.185
- v0.1.0-alpha.184
- v0.1.0-alpha.183
- v0.1.0-alpha.182
- v0.1.0-alpha.181
- v0.1.0-alpha.180
- v0.1.0-alpha.179
- v0.1.0-alpha.178
- v0.1.0-alpha.177
- v0.1.0-alpha.176
- v0.1.0-alpha.175
- v0.1.0-alpha.174
- v0.1.0-alpha.173
- v0.1.0-alpha.172
- v0.1.0-alpha.171
- v0.1.0-alpha.170
- v0.1.0-alpha.169
- v0.1.0-alpha.168
- v0.1.0-alpha.167
- v0.1.0-alpha.166
- v0.1.0-alpha.165
- v0.1.0-alpha.164
- v0.1.0-alpha.163
- v0.1.0-alpha.162
- v0.1.0-alpha.161
- v0.1.0-alpha.160
- v0.1.0-alpha.159
- v0.1.0-alpha.158
- v0.1.0-alpha.157
- v0.1.0-alpha.156
- v0.1.0-alpha.155
- v0.1.0-alpha.154
- v0.1.0-alpha.153
- v0.1.0-alpha.152
- v0.1.0-alpha.151
- v0.1.0-alpha.150
- v0.1.0-alpha.149
- v0.1.0-alpha.148
- v0.1.0-alpha.147
- v0.1.0-alpha.146
- v0.1.0-alpha.145
- v0.1.0-alpha.143
- v0.1.0-alpha.142
- v0.1.0-alpha.141
- v0.1.0-alpha.140
- v0.1.0-alpha.139
- v0.1.0-alpha.138
- v0.1.0-alpha.137
- v0.1.0-alpha.136
- v0.1.0-alpha.135
- v0.1.0-alpha.134
- v0.1.0-alpha.133
- v0.1.0-alpha.132
- v0.1.0-alpha.131
- v0.1.0-alpha.130
- v0.1.0-alpha.129
- v0.1.0-alpha.128
- v0.1.0-alpha.127
- v0.1.0-alpha.126
- v0.1.0-alpha.125
- v0.1.0-alpha.124
- v0.1.0-alpha.123
- v0.1.0-alpha.122
- v0.1.0-alpha.121
- v0.1.0-alpha.120
- v0.1.0-alpha.119
- v0.1.0-alpha.118
- v0.1.0-alpha.117
- v0.1.0-alpha.116
- v0.1.0-alpha.115
- v0.1.0-alpha.114
- v0.1.0-alpha.113
- v0.1.0-alpha.112
- v0.1.0-alpha.111
- v0.1.0-alpha.110
- v0.1.0-alpha.109
- v0.1.0-alpha.108
- v0.1.0-alpha.107
- v0.1.0-alpha.106
- v0.1.0-alpha.105
- v0.1.0-alpha.104
- v0.1.0-alpha.103
- v0.1.0-alpha.102
- v0.1.0-alpha.101
- v0.1.0-alpha.100
- v0.1.0-alpha.99
- v0.1.0-alpha.98
- v0.1.0-alpha.97
- v0.1.0-alpha.96
- v0.1.0-alpha.95
- v0.1.0-alpha.94
- v0.1.0-alpha.93
- v0.1.0-alpha.92
- v0.1.0-alpha.91
- v0.1.0-alpha.90
- v0.1.0-alpha.89
- v0.1.0-alpha.88
- v0.1.0-alpha.87
- v0.1.0-alpha.86
- v0.1.0-alpha.85
- v0.1.0-alpha.84
- v0.1.0-alpha.83
- v0.1.0-alpha.82
- v0.1.0-alpha.81
- v0.1.0-alpha.80
- v0.1.0-alpha.79
- v0.1.0-alpha.78
- v0.1.0-alpha.77
- v0.1.0-alpha.76
- v0.1.0-alpha.75
- v0.1.0-alpha.74
- v0.1.0-alpha.73
- v0.1.0-alpha.72
- v0.1.0-alpha.71
- v0.1.0-alpha.70
- v0.1.0-alpha.69
- v0.1.0-alpha.68
- v0.1.0-alpha.67
- v0.1.0-alpha.66
- v0.1.0-alpha.65
- v0.1.0-alpha.64
- v0.1.0-alpha.63
- v0.1.0-alpha.62
- v0.1.0-alpha.61
- v0.1.0-alpha.58
- v0.1.0-alpha.57
- v0.1.0-alpha.56
- v0.1.0-alpha.55
- v0.1.0-alpha.54
- v0.1.0-alpha.53
- v0.1.0-alpha.52
- v0.1.0-alpha.51
- v0.1.0-alpha.50
- v0.1.0-alpha.49
- v0.1.0-alpha.48
- v0.1.0-alpha.47
- v0.1.0-alpha.46
- v0.1.0-alpha.45
- v0.1.0-alpha.44
- v0.1.0-alpha.43
- v0.1.0-alpha.42
- v0.1.0-alpha.41
- v0.1.0-alpha.40
- v0.1.0-alpha.39
- v0.1.0-alpha.38
- v0.1.0-alpha.37
- v0.1.0-alpha.36
- v0.1.0-alpha.35
- v0.1.0-alpha.34
- v0.1.0-alpha.33
- v0.1.0-alpha.32
- v0.1.0-alpha.31
- v0.1.0-alpha.30
- v0.1.0-alpha.29
- v0.1.0-alpha.28
- v0.1.0-alpha.27
- v0.1.0-alpha.26
- v0.1.0-alpha.25
- v0.1.0-alpha.24
- v0.1.0-alpha.23
- v0.1.0-alpha.22
- v0.1.0-alpha.21
- v0.1.0-alpha.20
- v0.1.0-alpha.19
- v0.1.0-alpha.18
- v0.1.0-alpha.17
- v0.1.0-alpha.16
- v0.1.0-alpha.15
- v0.1.0-alpha.14
- v0.1.0-alpha.13
- v0.1.0-alpha.12
- v0.1.0-alpha.11
- v0.1.0-alpha.10
- v0.1.0-alpha.9
- v0.1.0-alpha.8
- v0.1.0-alpha.7
- v0.1.0-alpha.6
- v0.1.0-alpha.5
- v0.1.0-alpha.4
- v0.1.0-alpha.3
- v0.1.0-alpha.2
- v0.1.0-alpha.1
This package is auto-updated.
Last update: 2026-05-21 02:03:29 UTC
README
Layer 5 — AI
Waaseyaa agent runtime: the executor, the run service, the Messenger handler, and the in-process audit-log persistence. This package turns a registered AgentDefinition and an initiator account into a persisted AgentRun with real-time SSE progress, token / cost accounting, HITL approvals, and an append-only audit trail.
Where to start
The canonical doctrine spec is docs/specs/agent-executor.md. It owns the success criteria, NFR thresholds, audit invariants, SSE event vocabulary, HITL state machine, security posture, and the Waaseyaa\AI\Tools\ToolRegistryInterface contract.
For the tool catalogue (8 stock tools + remote MCP source) see packages/ai-tools/README.md.
Surfaces
| Surface | Entry point | Notes |
|---|---|---|
| CLI | packages/cli/src/Command/Ai/{AiRunCommand,AiPurgeRunsCommand,AiReapStalledRunsCommand}.php |
bin/waaseyaa ai:run "<prompt>" --inline for sync; omit --inline for async enqueue. |
| HTTP | packages/ai-agent/src/Controller/AgentRunController.php (routes: packages/ai-agent/src/Routing/AgentRouteServiceProvider.php) |
POST /api/ai/agent/run, GET /api/ai/agent/run/{id}, DELETE /api/ai/agent/run/{id}, POST /api/ai/agent/run/{id}/approve. Per-route capability checks + initiator ownership via AgentRunAccessPolicy. |
| SSE | BroadcastStorage push on agent.run.<id> |
Consume via GET /broadcast?channels=agent.run.<id>. Events: run_started, iteration, tool_call, tool_result, approval_required, run_completed, run_failed, run_cancelled. |
| Messenger worker | packages/ai-agent/src/Message/{RunAgent,RunAgentHandler}.php |
Consumes the RunAgent message; CAS-guarded against duplicate delivery (NFR-015). |
| Scheduler | packages/scheduler/src/Schedule/Ai/AgentScheduleEntries.php |
Daily purge + 5-minute stalled-run reaper. |
Extension points
Register agent bundles and tools via attribute discovery — the package-manifest compiler scans both.
use Waaseyaa\AI\Agent\Attribute\AsAgentDefinition; #[AsAgentDefinition(id: 'my_agent', model: 'gpt-4o-mini')] final class MyAgent { /* prompt, tools, system, max_iterations, destructive_default, requires_capability */ } use Waaseyaa\AI\Tools\Attribute\AsAgentTool; #[AsAgentTool(name: 'my_tool', capability: 'my.feature', destructive: false)] final class MyTool extends \Waaseyaa\AI\Tools\AbstractAgentTool { /* execute() */ }
After adding new attributes run bin/waaseyaa optimize:manifest (or restart the dev server).
Persisted entities
| Entity | Purpose |
|---|---|
Waaseyaa\AI\Agent\Entity\AgentRun |
Run record: initiator, bundle snapshot, status, transcript (truncated at the configured cap), token/cost totals, approval state, timestamps. |
Waaseyaa\AI\Agent\Entity\AgentAuditLog |
Append-only event log: one row per provider call / tool call / tool result / approval. Purged only by AiPurgeRunsCommand. |
Repositories live in packages/ai-agent/src/Repository/. The legacy in-memory Waaseyaa\AI\Agent\AgentAuditLog value-object list inside AgentExecutor is removed.
Services
| Class | Role |
|---|---|
AgentRunService |
enqueue() (async path) and runInline() (CLI/dev sync path). |
AgentExecutor |
Per-iteration loop: provider call, tool dispatch via ToolRegistryInterface, HITL gating, cancellation poll. |
AgentDefinitionRegistry |
Resolves AgentDefinition VOs by id. |
StalledRunReaper |
Transitions runs stuck past max_runtime_seconds to failed. |
Mcp\McpClientToolSource + StreamableHttpMcpClient |
Adapts remote MCP servers into the local tool registry; capability prefix tool.mcp.<server>.<name>. |
Quality gates
Every change to this package MUST keep the following green:
bin/check-package-layers— ai-agent imports only from layer ≤ 5 (entity, entity-storage, access, queue, ai-schema, ai-tools).bin/check-dead-code— no new findings beyondphpstan-dead-code-baseline.neon.composer check-composer-policy— CP002 / CP003 / CP-NEW.composer phpstan— level 5.composer cs-check— PHP-CS-Fixer dry-run.- Bulk-edit gate —
occurrence_map.yamlvalidates; zeroBLOCKrows in the diff-compliance report.
Tests:
./vendor/bin/phpunit packages/ai-agent/tests/ ./vendor/bin/phpunit tests/Integration/PhaseN/AgentRuntime/