Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/homeboy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, pdo_sqlite, mysqli
tools: composer:v2
coverage: none

- name: Install project dependencies
run: composer install --no-interaction --prefer-dist

- uses: Extra-Chill/homeboy-action@v1
with:
version: '0.53.0'
extension: wordpress
commands: lint,test,audit
component: data-machine
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"description": "WordPress plugin for automated data collection, AI processing, and multi-platform publishing",
"version": "0.10.2",
"license": "GPL-2.0-or-later",
"require": {
"php": ">=8.2",
"monolog/monolog": "^3.9",
"woocommerce/action-scheduler": "^3.9",
"chubes4/ai-http-client": "^2.0.13"
},
"require": {
"php": ">=8.2",
"monolog/monolog": "^3.9",
"woocommerce/action-scheduler": "^3.9",
"chubes4/ai-http-client": "^2.0.13"
},
"require-dev": {
"php-stubs/wordpress-stubs": "^6.9",
"wp-coding-standards/wpcs": "^3.1",
Expand Down
2 changes: 2 additions & 0 deletions inc/Abilities/Engine/RunFlowAbility.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public function execute( array $input ): array {
'flow_id' => $flow_id,
'source' => 'pipeline',
'label' => $flow['flow_name'] ?? null,
'user_id' => (int) ( $flow['user_id'] ?? 0 ),
)
);
if ( ! $job_id ) {
Expand Down Expand Up @@ -167,6 +168,7 @@ public function execute( array $input ): array {
'job_id' => $job_id,
'flow_id' => $flow_id,
'pipeline_id' => $pipeline_id,
'user_id' => (int) ( $flow['user_id'] ?? 0 ),
'created_at' => current_time( 'mysql', true ),
),
'flow' => array(
Expand Down
24 changes: 12 additions & 12 deletions inc/Abilities/Flow/CreateFlowAbility.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ private function registerAbility(): void {
'type' => 'object',
'properties' => array(
'success' => array( 'type' => 'boolean' ),
'flow_id' => array( 'type' => 'integer' ),
'flow_name' => array( 'type' => 'string' ),
'pipeline_id' => array( 'type' => 'integer' ),
'synced_steps' => array( 'type' => 'integer' ),
'flow_data' => array( 'type' => 'object' ),
'created_count' => array( 'type' => 'integer' ),
'failed_count' => array( 'type' => 'integer' ),
'created' => array( 'type' => 'array' ),
'errors' => array( 'type' => 'array' ),
'partial' => array( 'type' => 'boolean' ),
'message' => array( 'type' => 'string' ),
'error' => array( 'type' => 'string' ),
'flow_id' => array( 'type' => array( 'integer', 'null' ) ),
'flow_name' => array( 'type' => array( 'string', 'null' ) ),
'pipeline_id' => array( 'type' => array( 'integer', 'null' ) ),
'synced_steps' => array( 'type' => array( 'integer', 'null' ) ),
'flow_data' => array( 'type' => array( 'object', 'null' ) ),
'created_count' => array( 'type' => array( 'integer', 'null' ) ),
'failed_count' => array( 'type' => array( 'integer', 'null' ) ),
'created' => array( 'type' => array( 'array', 'null' ) ),
'errors' => array( 'type' => array( 'array', 'null' ) ),
'partial' => array( 'type' => array( 'boolean', 'null' ) ),
'message' => array( 'type' => array( 'string', 'null' ) ),
'error' => array( 'type' => array( 'string', 'null' ) ),
),
),
'execute_callback' => array( $this, 'execute' ),
Expand Down
28 changes: 14 additions & 14 deletions inc/Abilities/Pipeline/CreatePipelineAbility.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ private function registerAbility(): void {
'type' => 'object',
'properties' => array(
'success' => array( 'type' => 'boolean' ),
'pipeline_id' => array( 'type' => 'integer' ),
'pipeline_name' => array( 'type' => 'string' ),
'flow_id' => array( 'type' => 'integer' ),
'flow_name' => array( 'type' => 'string' ),
'steps_created' => array( 'type' => 'integer' ),
'flow_step_ids' => array( 'type' => 'array' ),
'creation_mode' => array( 'type' => 'string' ),
'created_count' => array( 'type' => 'integer' ),
'failed_count' => array( 'type' => 'integer' ),
'created' => array( 'type' => 'array' ),
'errors' => array( 'type' => 'array' ),
'partial' => array( 'type' => 'boolean' ),
'message' => array( 'type' => 'string' ),
'error' => array( 'type' => 'string' ),
'pipeline_id' => array( 'type' => array( 'integer', 'null' ) ),
'pipeline_name' => array( 'type' => array( 'string', 'null' ) ),
'flow_id' => array( 'type' => array( 'integer', 'null' ) ),
'flow_name' => array( 'type' => array( 'string', 'null' ) ),
'steps_created' => array( 'type' => array( 'integer', 'null' ) ),
'flow_step_ids' => array( 'type' => array( 'array', 'null' ) ),
'creation_mode' => array( 'type' => array( 'string', 'null' ) ),
'created_count' => array( 'type' => array( 'integer', 'null' ) ),
'failed_count' => array( 'type' => array( 'integer', 'null' ) ),
'created' => array( 'type' => array( 'array', 'null' ) ),
'errors' => array( 'type' => array( 'array', 'null' ) ),
'partial' => array( 'type' => array( 'boolean', 'null' ) ),
'message' => array( 'type' => array( 'string', 'null' ) ),
'error' => array( 'type' => array( 'string', 'null' ) ),
),
),
'execute_callback' => array( $this, 'execute' ),
Expand Down
13 changes: 11 additions & 2 deletions inc/Api/Chat/ChatOrchestrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public static function processChat(
'max_turns' => $max_turns,
'selected_pipeline_id' => $selected_pipeline_id ? $selected_pipeline_id : null,
'agent_type' => AgentType::CHAT,
'user_id' => $user_id,
)
);

Expand Down Expand Up @@ -289,6 +290,7 @@ public static function processContinue( string $session_id, int $user_id ): arra
'max_turns' => $max_turns,
'selected_pipeline_id' => $selected_pipeline_id,
'agent_type' => AgentType::CHAT,
'user_id' => (int) ( $session['user_id'] ?? 0 ),
)
);

Expand Down Expand Up @@ -389,7 +391,10 @@ public static function processPing( string $message, string $provider, string $m
$messages,
$provider,
$model,
array( 'agent_type' => AgentType::CHAT )
array(
'agent_type' => AgentType::CHAT,
'user_id' => $user_id,
)
);

if ( is_wp_error( $result ) ) {
Expand Down Expand Up @@ -544,7 +549,11 @@ public static function executeConversationTurn(
$tool_manager = new ToolManager();
$all_tools = $tool_manager->getAvailableToolsForChat();

$loop_context = array( 'session_id' => $session_id );
$user_id = $options['user_id'] ?? 0;
$loop_context = array(
'session_id' => $session_id,
'user_id' => $user_id,
);
if ( $selected_pipeline_id ) {
$loop_context['selected_pipeline_id'] = $selected_pipeline_id;
}
Expand Down
5 changes: 5 additions & 0 deletions inc/Core/Steps/AI/AIStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,17 @@ protected function executeStep(): array {

$max_turns = PluginSettings::get( 'max_turns', 12 );

// Resolve user_id from engine snapshot (set by RunFlowAbility).
$job_snapshot = $this->engine->get( 'job' );
$user_id = (int) ( $job_snapshot['user_id'] ?? 0 );

$payload = array(
'job_id' => $this->job_id,
'flow_step_id' => $this->flow_step_id,
'step_id' => $pipeline_step_id,
'data' => $this->dataPackets,
'engine' => $this->engine,
'user_id' => $user_id,
);

$navigator = new \DataMachine\Engine\StepNavigator();
Expand Down
4 changes: 3 additions & 1 deletion inc/Core/Steps/AI/Directives/FlowMemoryFilesDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public static function get_outputs( string $provider_name, array $tools, ?string
$db_flows = new Flows();
$memory_files = $db_flows->get_flow_memory_files( $flow_id );

return MemoryFilesReader::read( $memory_files, 'Flow', $flow_id );
$user_id = (int) ( $payload['user_id'] ?? 0 );

return MemoryFilesReader::read( $memory_files, 'Flow', $flow_id, $user_id );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public static function get_outputs( string $provider_name, array $tools, ?string
}

$memory_files = $db_pipelines->get_pipeline_memory_files( (int) $pipeline_id );
$user_id = (int) ( $payload['user_id'] ?? 0 );

return MemoryFilesReader::read( $memory_files, 'Pipeline', (int) $pipeline_id );
return MemoryFilesReader::read( $memory_files, 'Pipeline', (int) $pipeline_id, $user_id );
}
}

Expand Down
4 changes: 2 additions & 2 deletions inc/Engine/AI/Directives/CoreMemoryFilesDirective.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public static function get_outputs( string $provider_name, array $tools, ?string
DirectoryManager::ensure_agent_files();

$directory_manager = new DirectoryManager();
// TODO: Multi-agent Phase 2 — resolve user_id from execution context (#565).
$agent_dir = $directory_manager->get_agent_directory();
$user_id = (int) ( $payload['user_id'] ?? 0 );
$agent_dir = $directory_manager->get_agent_directory( $user_id );
$outputs = array();

foreach ( $filenames as $filename ) {
Expand Down
9 changes: 6 additions & 3 deletions inc/Engine/AI/Directives/MemoryFilesReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@ class MemoryFilesReader {
* @param array $memory_files Array of memory filenames.
* @param string $scope_label Label for logging (e.g. 'Pipeline', 'Flow').
* @param int $scope_id Entity ID for logging (e.g. pipeline_id, flow_id).
* @param int $user_id WordPress user ID. 0 = legacy shared directory.
* @return array Array of directive outputs (type => system_text, content => ...).
*/
public static function read( array $memory_files, string $scope_label, int $scope_id ): array {
/**
* @since 0.37.0 Added $user_id parameter for multi-agent partitioning.
*/
public static function read( array $memory_files, string $scope_label, int $scope_id, int $user_id = 0 ): array {
if ( empty( $memory_files ) ) {
return array();
}

$directory_manager = new DirectoryManager();
// TODO: Multi-agent Phase 2 — resolve user_id from execution context (#565).
$agent_dir = $directory_manager->get_agent_directory();
$agent_dir = $directory_manager->get_agent_directory( $user_id );
$outputs = array();

foreach ( $memory_files as $filename ) {
Expand Down
Loading