Skip to content

Expose a generic frontend chat REST adapter for agents/chat #161

@chubes4

Description

@chubes4

Summary

agents/chat is a useful runtime seam, but browser clients still need a stable HTTP surface. The frontend-agent-chat migration had to implement its own REST adapter that translates @extrachill/chat requests into the canonical agents/chat ability.

That adapter proves the seam works, but every frontend agent widget should not need to recreate it.

Current State

Agents API provides:

agents/chat ability
wp_agent_chat_handler filter
agents_chat_permission filter

But it does not provide a generic REST controller for browser clients.

Proposed Surface

Add a generic REST endpoint, ability-backed and handler-agnostic:

POST /wp-json/agents/v1/chat

Input should mirror agents/chat:

{
  "agent": "site-assistant",
  "message": "What changed today?",
  "session_id": "optional-session-id",
  "attachments": [],
  "client_context": {
    "source": "rest",
    "client_name": "frontend-agent-chat",
    "connector_id": "frontend-agent-chat"
  }
}

Output should mirror the canonical ability output:

{
  "session_id": "...",
  "reply": "...",
  "messages": [],
  "completed": true,
  "metadata": {}
}

Acceptance Criteria

  • Browser clients can call agents/chat without product-specific REST adapters.
  • Permission checks go through the same agents_chat_permission path as direct ability calls.
  • Runtime selection remains host-owned via wp_agent_chat_handler.
  • The endpoint does not depend on Data Machine or any other product plugin.

Why It Matters

This lets two plugins that do not depend on each other both consume the same Agents API seam:

frontend-agent-chat -> Agents API REST -> agents/chat -> Data Machine handler

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions