Summary
frontend-agent-chat migration PR Extra-Chill/frontend-agent-chat#9 exposed that Agents API has the generic access contracts, but no frontend-friendly helper/ability for common product questions:
- Can the current principal chat with this agent?
- Which agents can the current principal access?
- What display metadata should a client render for each accessible agent?
Agents API already has the lower-level pieces:
WP_Agent_Access_Grant
WP_Agent_Access_Store
WP_Agent_Authorization_Policy
WP_Agent_WordPress_Authorization_Policy::can_access_agent()
But a standalone frontend plugin still has to know host-specific storage, currently Data Machine's PermissionHelper, to answer these questions.
Proposed API
Add canonical abilities and/or helpers:
wp_agent_current_user_can_access_agent( string $agent_slug, string $minimum_role = 'viewer' ): bool
wp_agent_list_accessible_agents( string $minimum_role = 'viewer' ): array
Ability equivalents:
agents/can-access-agent
agents/list-accessible-agents
agents/list-accessible-agents should return registered agent metadata suitable for frontend selectors:
array(
'agents' => array(
array(
'slug' => 'site-assistant',
'label' => 'Site Assistant',
'description' => '...',
'role' => 'viewer',
'meta' => array(),
),
),
)
Host Extension Point
Hosts should provide concrete stores via a filter rather than consumers importing host classes:
apply_filters( 'wp_agent_access_store', null, $context )
apply_filters( 'wp_agent_authorization_policy', null, $context )
Data Machine can return its concrete access store or adapter. Other products can do the same.
Acceptance Criteria
- A frontend plugin can check access to an agent without importing Data Machine classes.
- A frontend plugin can list accessible agents for the current user/principal.
- Registered
WP_Agent definitions and host-materialized grants compose cleanly.
- Data Machine can keep its current storage while exposing it through Agents API contracts.
Related
Summary
frontend-agent-chatmigration PR Extra-Chill/frontend-agent-chat#9 exposed that Agents API has the generic access contracts, but no frontend-friendly helper/ability for common product questions:Agents API already has the lower-level pieces:
WP_Agent_Access_GrantWP_Agent_Access_StoreWP_Agent_Authorization_PolicyWP_Agent_WordPress_Authorization_Policy::can_access_agent()But a standalone frontend plugin still has to know host-specific storage, currently Data Machine's
PermissionHelper, to answer these questions.Proposed API
Add canonical abilities and/or helpers:
Ability equivalents:
agents/list-accessible-agentsshould return registered agent metadata suitable for frontend selectors:Host Extension Point
Hosts should provide concrete stores via a filter rather than consumers importing host classes:
Data Machine can return its concrete access store or adapter. Other products can do the same.
Acceptance Criteria
WP_Agentdefinitions and host-materialized grants compose cleanly.Related