feat: CLI --user flag and ability-level user_id for multi-agent scoping (#566)#574
Open
feat: CLI --user flag and ability-level user_id for multi-agent scoping (#566)#574
Conversation
…nt (#565) Phase 2 of multi-agent support: directives now read the correct agent's files based on user_id from the execution context. Pipeline path: - RunFlowAbility propagates flow's user_id to job record and engine snapshot - AIStep extracts user_id from engine snapshot into payload Chat path: - ChatOrchestrator threads user_id through options into loop_context - All three callers (processChat, processContinue, processPing) pass user_id Directives: - CoreMemoryFilesDirective resolves user_id from payload, passes to DirectoryManager::get_agent_directory() - MemoryFilesReader::read() accepts user_id param (default 0 for compat) - PipelineMemoryFilesDirective and FlowMemoryFilesDirective pass user_id through to MemoryFilesReader All changes default to user_id=0 — existing single-agent installs keep working without configuration. Refs: #565, #560
…lti-agent scoping (#566) Phase 3 of multi-agent support: CLI and ability-level user scoping. Abilities layer: - AgentMemoryAbilities: add user_id to all 4 input_schema definitions and extract from input in execute methods - FileAbilities: add user_id to input_schema for list, get, write, delete, and upload abilities; pass through to agent-scoped private methods (listAgentFiles, getAgentFile, writeAgentFile, deleteAgentFile, uploadToAgent) - GetPipelinesAbility: add user_id input param, pass to get_all_pipelines() DB query - GetFlowsAbility: add user_id input param, pass through to getAllFlowsPaginated/countAllFlows helpers - GetJobsAbility: add user_id input param, pass to DB query args - FlowHelpers: update getAllFlowsPaginated/countAllFlows to accept optional user_id and use get_all_flows() when filtering CLI layer: - New UserResolver class: resolves --user flag (ID, login, or email) to WordPress user ID, returns 0 when omitted - MemoryCommand: wire --user through all subcommands (read, sections, write, search, daily, files) to ability calls and DirectoryManager - PipelinesCommand: resolve --user, pass to executeGetPipelines - FlowsCommand: resolve --user, pass to executeAbility - JobsCommand: resolve --user, pass to executeGetJobs - New AgentsCommand: wp datamachine agents list — shows shared agent and all WP users with pipelines, flows, or agent directories - Bootstrap: register agents command REST API: - Files.php: accept user_id query param on list, get, put, delete agent file endpoints; pass through to FileAbilities
Unit tests:
- UserResolverTest: validates resolve() contract — static, accepts
array, returns int, returns 0 for empty/null/missing --user flag
- AgentsCommandTest: validates class structure — extends BaseCommand,
has list_agents method with correct signature
Integration tests (WP_UnitTestCase):
- MultiAgentScopingTest: 16 tests covering end-to-end scoping:
- AgentMemoryAbilities: all 4 input_schemas include user_id,
getMemory defaults to user_id=0, explicit zero matches default
- FileAbilities: input_schemas include user_id, agent file
listing is scoped by user_id, write creates user-scoped
directory, delete is scoped (cross-agent delete fails)
- GetPipelinesAbility: input_schema includes user_id, listing
filtered correctly (agent A sees only their pipelines),
no filter returns all
- GetFlowsAbility: input_schema includes user_id
- GetJobsAbility: input_schema includes user_id, listing
filtered by user_id returns only matching jobs
- DirectoryManager: directories isolated by user_id,
shared uses legacy path, user-scoped uses agent-{id} path
Homeboy Results —
|
…oader Homeboy's WP test bootstrap loads the plugin on plugins_loaded, but the plugin requires vendor/autoload.php (PSR-4 autoloader). Without running composer install, no DataMachine classes are autoloadable, causing 'Class not found' fatals in PHPUnit.
BaseCommand extends WP_CLI_Command, which isn't available in the test environment without this dependency. WordPress core doesn't include WP-CLI.
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
Phase 3 of multi-agent support (#560, #566): adds
--userflag to all relevant CLI commands anduser_idinput parameter to abilities, enabling per-agent scoping of pipelines, flows, jobs, and agent files.Changes
Abilities Layer
user_idadded to all 4 input schemas + extracted in execute methodsuser_idflows through list, get, write, delete, upload for agent-scoped opsuser_idfilter on pipeline listinguser_idfilter viagetAllFlowsPaginated/countAllFlowshelpersuser_idfilter on job listinggetAllFlowsPaginated/countAllFlowsaccept optional$user_idCLI Layer
UserResolver: resolves--user=<id|login|email>to WP user ID (0 when omitted)--userwired throughread,sections,write,search,daily,files--userfilters pipeline listing--userfilters flow listing--userfilters job listingAgentsCommand:wp datamachine agents list— shows all configured agentsREST API
user_idquery param on agent file list/get/put/delete endpointsBackward Compatibility
user_idparams default to0(shared/legacy agent)--useron CLI preserves existing behaviorTesting
php -lpasses on all 14 changed filesDepends On
Closes #566