feat(system-task): DispatchMessageTask wrapping agents/dispatch-message#2051
Merged
Conversation
…essage Adds the DM-side adapter that lets a scheduled flow trigger an outbound message through whatever channel runtime is registered against the agents/dispatch-message ability (agents-api v0.107.0+). Mirrors the shape of AgentCallTask: thin wrapper, no transport knowledge, canonical output forwarded into the job result envelope. Refs #2049
Covers four behaviour paths for the new dispatch_message task:
1. Source-level registration in SystemAgentServiceProvider and
transport-neutrality of the task file (no kimaki/discord/slack/etc.
names leak into the wrapper).
2. Ability-missing path — wp_get_ability returns null, task fails the
job with a clear message naming the ability slug and the agents-api
substrate.
3. Handler success path — canonical output (sent, channel, recipient,
message_id, metadata) flows into the job result envelope alongside
a completed_at timestamp, and the canonical input is forwarded to
the ability untouched.
4. Handler WP_Error path — error code + message propagate as a job
failure.
Also pins the flat-shape passthrough (params on the top-level array)
since both shapes appear in handler_config wiring.
Refs #2049
Member
Author
|
<@532385681268408341> ready for review — implements #2049, 46/46 smoke assertions passing, lint clean, transport-neutral. Two conventional commits: |
Contributor
Homeboy Results —
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
DispatchMessageTask— a thin system_task wrapper around the canonicalagents/dispatch-messageability (agents-api v0.107.0+). This is the DM-side bridge that lets a scheduled flow tick hand an outbound message off to whichever channel runtime is registered via thewp_agent_dispatch_message_handlerfilter, without DM needing any knowledge of the underlying transport (CLI runtime in DMC, future Slack/WhatsApp/etc. runtimes, …).The shape mirrors
AgentCallTaskexactly: resolve the ability, forward params, surface canonical output orWP_Errorinto the job result envelope.Closes #2049
Files
inc/Engine/AI/System/Tasks/DispatchMessageTask.php(new) — newSystemTasksubclass.getTaskType()returnsdispatch_message.executeTask()resolveswp_get_ability( 'agents/dispatch-message' ), forwards the canonical input (channel,recipient,message, plus optionalconversation_id/attachments/client_context/metadata), and routes the result intocompleteJob()orfailJob()per the SystemTask base contract. Handles both wrapped ({ task, params: { … } }) and flat ({ channel, recipient, message }) handler_config shapes, stripping SystemTask scaffolding before forwarding to the ability.inc/Engine/AI/System/SystemAgentServiceProvider.php— registers\$tasks['dispatch_message'] = DispatchMessageTask::class;adjacent to the existingagent_callsibling.tests/dispatch-message-task-smoke.php(new) — pure-PHP smoke covering source-level registration, ability-missing failure, handler success envelope,WP_Errorpropagation, and flat-shape passthrough.Acceptance criteria (from #2049)
task: dispatch_messageis a recognized system_task type (registered inSystemAgentServiceProvider::getBuiltInTasks()).agents/dispatch-messageonce per execution (executeTask resolves the ability and calls\$ability->execute( \$input )exactly once per invocation).kimaki / discord / slack / telegram / whatsapp / cc-connect. Channel resolution stays inside the ability + its registered handler.feat(system-task): …andtest(system-task): …). No CHANGELOG edits. No version bumps.Smoke test output
```
$ php tests/dispatch-message-task-smoke.php
dispatch-message task smoke (#2049)
[1] task file + provider registration:
✓ DispatchMessageTask.php exists
✓ class extends SystemTask
✓ getTaskType returns dispatch_message
✓ task references the canonical ability slug
✓ provider imports DispatchMessageTask
✓ provider maps dispatch_message task id
✓ provider maps to DispatchMessageTask::class
[2] no transport-specific names in the new code:
✓ task source contains no 'kimaki'
✓ task source contains no 'discord'
✓ task source contains no 'slack'
✓ task source contains no 'telegram'
✓ task source contains no 'whatsapp'
✓ task source contains no 'cc-connect'
[3] ability-missing path fails the job cleanly:
✓ ability missing: no job completed
✓ ability missing: job failed once
✓ ability missing: failed job id propagated
✓ ability missing: error mentions ability slug
✓ ability missing: error mentions agents-api substrate
[4] handler success path completes the job with canonical output:
✓ success: job completed once
✓ success: no job failures
✓ success: completed job id propagated
✓ success: sent flag in envelope
✓ success: channel in envelope
✓ success: recipient in envelope
✓ success: message_id in envelope
✓ success: metadata in envelope
✓ success: completed_at timestamp present
✓ success: channel forwarded
✓ success: recipient forwarded
✓ success: message forwarded
✓ success: conversation_id forwarded as null
✓ success: attachments forwarded
✓ success: client_context forwarded
✓ success: metadata forwarded
✓ success: SystemTask wrapper key task is stripped
[5] handler WP_Error path fails the job with the error message:
✓ wp_error: no job completed
✓ wp_error: job failed once
✓ wp_error: failed job id propagated
✓ wp_error: error code surfaced
✓ wp_error: error message surfaced
[6] flat-shape params (no nested params key) also work:
✓ flat shape: job completed
✓ flat shape: channel forwarded
✓ flat shape: recipient forwarded
✓ flat shape: message forwarded
✓ flat shape: task scaffolding stripped
✓ flat shape: task_type scaffolding stripped
46 / 46 passed
All assertions passed.
```
Reproduce with: `php tests/dispatch-message-task-smoke.php` from the repo root.
Transport-neutrality confirmation
```
$ grep -iE 'kimaki|discord|slack|telegram|whatsapp|cc-connect' \
inc/Engine/AI/System/Tasks/DispatchMessageTask.php
(zero matches)
```
The only matches in `tests/dispatch-message-task-smoke.php` are inside the banned-list array that powers the assertion itself — not transport coupling in production code.
Lint
`vendor/bin/phpcs inc/Engine/AI/System/Tasks/DispatchMessageTask.php inc/Engine/AI/System/SystemAgentServiceProvider.php tests/dispatch-message-task-smoke.php` is clean (zero findings against the repo's default standard). Per AGENTS.md, no attempt was made to address unrelated pre-existing lint debt on `main`.
Handler config example
An example flow handler_config is documented in #2049:
```json
{
"task": "dispatch_message",
"params": {
"channel": "",
"recipient": "",
"message": "",
"conversation_id": null,
"attachments": [],
"client_context": {},
"metadata": {}
}
}
```
Required input: `channel`, `recipient`, `message`. Everything else passes through to the ability untouched.
Out of scope (per #2049)
cc <@532385681268408341> when ready for review.