self::ID, 'label' => __( 'Retry Templately Full Site Import', 'templately' ), 'description' => __( 'Resume a full-site import that reported a recoverable error, continuing from where it stopped (does not restart). Keep polling full-site-import-status afterward.', 'templately' ), 'input_schema' => [ 'type' => 'object', 'properties' => [ 'handle' => [ 'type' => 'string' ], ], 'required' => [ 'handle' ], 'additionalProperties' => false, ], 'output_schema' => [ 'type' => 'object', 'properties' => [ 'handle' => [ 'type' => 'string' ], 'status' => [ 'type' => 'string' ], 'progress' => [ 'type' => 'integer' ], 'phase' => [ 'type' => 'string' ], ], ], 'execute_callback' => [ self::class, 'execute' ], 'permission_callback' => [ Permissions::class, 'can_use_abilities' ], 'access_level' => ToolDescriptor::ACCESS_FULL, 'annotations' => [ 'readonly' => false, 'destructive' => false, 'idempotent' => false ], ]; } /** * @param array $input * @return array|WP_Error */ public static function execute( array $input ) { $handle = FullSiteImportStatusAbility::sanitize_handle( $input['handle'] ?? '' ); if ( is_wp_error( $handle ) ) { return $handle; } $session_data = SessionData::get_data( $handle ); if ( empty( $session_data ) || ! is_array( $session_data ) ) { return new WP_Error( 'expired_handle', __( 'Unknown or expired import handle.', 'templately' ) ); } $active = FsiActiveImportGuard::get_active( get_current_user_id() ); if ( empty( $active ) || ( $active['session_id'] ?? '' ) !== $handle ) { return new WP_Error( 'not_retryable', __( 'This import has already finished and cannot be retried.', 'templately' ) ); } return FullSiteImportStatusAbility::advance( $handle, 0, true ); } }